Add Unvar and Unglobal and Global
Dieser Commit ist enthalten in:
Ursprung
f25fa86db9
Commit
194fce7da5
@ -1,4 +1,58 @@
|
|||||||
package de.steamwar.bausystem.features.script.command.variable;
|
package de.steamwar.bausystem.features.script.command.variable;
|
||||||
|
|
||||||
public class Global {
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.script.ScriptExecutor;
|
||||||
|
import de.steamwar.bausystem.features.script.SpecialCommand;
|
||||||
|
import de.steamwar.bausystem.features.script.variables.Value;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
|
||||||
|
@Linked(LinkageType.SCRIPT_COMMAND)
|
||||||
|
public class Global implements SpecialCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] description() {
|
||||||
|
return new String[]{
|
||||||
|
"§eglobal §8<§7Name§8> §8[§7Value§8(§7s§8)§8]",
|
||||||
|
"",
|
||||||
|
"Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text."
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String command() {
|
||||||
|
return "global";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||||
|
if (command.length <= 1) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (command.length <= 2) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Wert");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String varName = command[1];
|
||||||
|
StringBuilder varValue = new StringBuilder();
|
||||||
|
for (int i = 2; i < command.length; i++) {
|
||||||
|
if (varValue.length() != 0) {
|
||||||
|
varValue.append(" ");
|
||||||
|
}
|
||||||
|
varValue.append(command[i]);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
long value = Long.parseLong(varValue.toString());
|
||||||
|
scriptExecutor.getLocalVariables().putValue(varName, new Value.LongValue(value));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
String s = varValue.toString();
|
||||||
|
if (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false")) {
|
||||||
|
scriptExecutor.getGlobalVariables().putValue(varName, new Value.BooleanValue(s.equalsIgnoreCase("true")));
|
||||||
|
} else {
|
||||||
|
scriptExecutor.getGlobalVariables().putValue(varName, new Value.StringValue(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,35 @@
|
|||||||
package de.steamwar.bausystem.features.script.command.variable;
|
package de.steamwar.bausystem.features.script.command.variable;
|
||||||
|
|
||||||
public class Unglobal {
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.script.ScriptExecutor;
|
||||||
|
import de.steamwar.bausystem.features.script.SpecialCommand;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
|
||||||
|
@Linked(LinkageType.SCRIPT_COMMAND)
|
||||||
|
public class Unglobal implements SpecialCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] description() {
|
||||||
|
return new String[]{
|
||||||
|
"unglobal §8<§7Name§8>",
|
||||||
|
"",
|
||||||
|
"Lösche eine Globale variable"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String command() {
|
||||||
|
return "unglobal";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||||
|
if (command.length <= 1) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
scriptExecutor.getGlobalVariables().removeValue(command[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,35 @@
|
|||||||
package de.steamwar.bausystem.features.script.command.variable;
|
package de.steamwar.bausystem.features.script.command.variable;
|
||||||
|
|
||||||
public class Unvar {
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.script.ScriptExecutor;
|
||||||
|
import de.steamwar.bausystem.features.script.SpecialCommand;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
|
||||||
|
@Linked(LinkageType.SCRIPT_COMMAND)
|
||||||
|
public class Unvar implements SpecialCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] description() {
|
||||||
|
return new String[]{
|
||||||
|
"unvar §8<§7Name§8>",
|
||||||
|
"",
|
||||||
|
"Lösche eine Locale variable"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String command() {
|
||||||
|
return "unvar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||||
|
if (command.length <= 1) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
scriptExecutor.getLocalVariables().removeValue(command[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.steamwar.bausystem.features.script.command.variable;
|
package de.steamwar.bausystem.features.script.command.variable;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.script.ScriptExecutor;
|
import de.steamwar.bausystem.features.script.ScriptExecutor;
|
||||||
import de.steamwar.bausystem.features.script.SpecialCommand;
|
import de.steamwar.bausystem.features.script.SpecialCommand;
|
||||||
import de.steamwar.bausystem.features.script.variables.Value;
|
import de.steamwar.bausystem.features.script.variables.Value;
|
||||||
@ -26,9 +27,11 @@ public class Var implements SpecialCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||||
if (command.length <= 1) {
|
if (command.length <= 1) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (command.length <= 2) {
|
if (command.length <= 2) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Wert");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String varName = command[1];
|
String varName = command[1];
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren