Add Equal, Greater, and Less
Dieser Commit ist enthalten in:
Ursprung
9b39252235
Commit
35540e8c6b
@ -38,12 +38,12 @@ public class Equal implements SpecialCommand {
|
||||
|
||||
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
|
||||
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
|
||||
Value result = null;
|
||||
Value result;
|
||||
if (v1.getClass() != v2.getClass()) {
|
||||
result = new Value.BooleanValue(false);
|
||||
} else if (v1.asString().equals(v2.asString())) {
|
||||
result = new Value.BooleanValue(true);
|
||||
} else if (command.length > 4) {
|
||||
} else {
|
||||
result = new Value.BooleanValue(false);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,59 @@
|
||||
package de.steamwar.bausystem.features.script.command.logic;
|
||||
|
||||
public class Greater {
|
||||
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 Greater implements SpecialCommand {
|
||||
|
||||
@Override
|
||||
public String[] description() {
|
||||
return new String[]{
|
||||
"§egreater §8<§7Variable§8> §8<§7Variable§8>",
|
||||
"§egreater §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
|
||||
"",
|
||||
"Vergleiche die letzten beiden Variablen und schreibe es in die erste."
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String command() {
|
||||
return "greater";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||
if (command.length <= 1) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
|
||||
return true;
|
||||
}
|
||||
if (command.length <= 2) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
|
||||
return true;
|
||||
}
|
||||
|
||||
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
|
||||
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
|
||||
if (v1.getClass() != Value.LongValue.class) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
|
||||
return true;
|
||||
}
|
||||
if (v2.getClass() != Value.LongValue.class) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
|
||||
return true;
|
||||
}
|
||||
Value result;
|
||||
if (v1.asLong() > v2.asLong()) {
|
||||
result = new Value.BooleanValue(true);
|
||||
} else {
|
||||
result = new Value.BooleanValue(false);
|
||||
}
|
||||
|
||||
scriptExecutor.getLocalVariables().putValue(command[1], result);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,59 @@
|
||||
package de.steamwar.bausystem.features.script.command.logic;
|
||||
|
||||
public class Less {
|
||||
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 Less implements SpecialCommand {
|
||||
|
||||
@Override
|
||||
public String[] description() {
|
||||
return new String[]{
|
||||
"§eless §8<§7Variable§8> §8<§7Variable§8>",
|
||||
"§eless §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
|
||||
"",
|
||||
"Vergleiche die letzten beiden Variablen und schreibe es in die erste."
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String command() {
|
||||
return "less";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||
if (command.length <= 1) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
|
||||
return true;
|
||||
}
|
||||
if (command.length <= 2) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
|
||||
return true;
|
||||
}
|
||||
|
||||
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
|
||||
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
|
||||
if (v1.getClass() != Value.LongValue.class) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
|
||||
return true;
|
||||
}
|
||||
if (v2.getClass() != Value.LongValue.class) {
|
||||
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
|
||||
return true;
|
||||
}
|
||||
Value result;
|
||||
if (v1.asLong() < v2.asLong()) {
|
||||
result = new Value.BooleanValue(true);
|
||||
} else {
|
||||
result = new Value.BooleanValue(false);
|
||||
}
|
||||
|
||||
scriptExecutor.getLocalVariables().putValue(command[1], result);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren