diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java index 65abe1ca..941a82bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java @@ -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); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java index bfae8d10..628b0a84 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java @@ -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; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java index 78cc49d6..6052f313 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java @@ -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; + } }