SteamWar/BauSystem
Archiviert
13
0

Script Turing Completeness #152

Manuell gemergt
YoyoNow hat 14 Commits von ScriptBranches nach master 2021-01-09 20:40:17 +01:00 zusammengeführt
Nur Änderungen aus Commit 3ad8bc4a06 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -20,6 +20,12 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.commands.CommandFire;
import de.steamwar.bausystem.commands.CommandFreeze;
import de.steamwar.bausystem.commands.CommandNV;
import de.steamwar.bausystem.commands.CommandTNT;
import de.steamwar.bausystem.tracer.TraceManager;
import de.steamwar.bausystem.tracer.recorder.RecordManager;
import de.steamwar.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -182,7 +188,43 @@ public class ScriptListener implements Listener {
}
private static void infoCommand(ScriptExecutor scriptExecutor, String[] args) {
scriptExecutor.player.sendMessage(BauSystem.PREFIX + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
scriptExecutor.player.sendMessage("§eInfo§8» §7" + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
}
private class VariableHolder {
private Map<String, Integer> variables = new HashMap<>();
public void setValue(String key, String value) {
int internalValue = 0;
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes")) {
internalValue = 1;
} else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("no")) {
internalValue = 0;
} else {
try {
internalValue = Integer.parseInt(value);
} catch (NumberFormatException e) {
internalValue = 0;
}
}
variables.put(key, internalValue);
}
public int getValue(String key) {
switch (key) {
case "trace":
return RecordManager.getStatus().isTracing() ? 1 : 0;
case "tnt":
return CommandTNT.getInstance().isOn() ? 1 : 0;
case "freeze":
return CommandFreeze.getInstance().isOn() ? 1 : 0;
case "fire":
return CommandFire.getInstance().isOn() ? 1 : 0;
}
return variables.getOrDefault(key, 0);
}
}
}