diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java
index 0880f4ae..46e847de 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java
@@ -80,7 +80,7 @@ public class ScriptCommand extends SWCommand {
});
swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand));
});
- for (int i = 0; i < 9 + 3; i++) {
+ for (int i = 0; i < 9; i++) {
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> {
}), null));
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Convert.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Convert.java
new file mode 100644
index 00000000..ad9784b3
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Convert.java
@@ -0,0 +1,65 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2021 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+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.SpecialCommand;
+import de.steamwar.bausystem.linkage.LinkageType;
+import de.steamwar.bausystem.linkage.Linked;
+import org.bukkit.Material;
+
+@Linked(LinkageType.SCRIPT_COMMAND)
+public class Convert implements SpecialCommand {
+
+ @Override
+ public String[] description() {
+ return new String[]{
+ "§econvert §8<§7Variable§8> §8<§7Value§8>",
+ "",
+ "Konvertiere den Value zu 'number' wenn es eine Zahl ist, oder zu 'boolean' bei 'true' oder 'false' und behalte 'text' bei wenn nichts zutrifft.",
+ };
+ }
+
+ @Override
+ public Material material() {
+ return Material.ENDER_CHEST;
+ }
+
+ @Override
+ public String command() {
+ return "convert";
+ }
+
+ @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;
+ }
+
+ scriptExecutor.getLocalVariables().putValue(command[1], scriptExecutor.parse(command[2]));
+ return true;
+ }
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Isset.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Isset.java
new file mode 100644
index 00000000..d686efab
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Isset.java
@@ -0,0 +1,66 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2021 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+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.SpecialCommand;
+import de.steamwar.bausystem.features.script.variables.Value;
+import de.steamwar.bausystem.linkage.LinkageType;
+import de.steamwar.bausystem.linkage.Linked;
+import org.bukkit.Material;
+
+@Linked(LinkageType.SCRIPT_COMMAND)
+public class Isset implements SpecialCommand {
+
+ @Override
+ public String[] description() {
+ return new String[]{
+ "§eisset §8<§7Variable§8> §8<§7Variable§8>",
+ "",
+ "Schreibt in eine Variable true/false rein, ob in die zweiten Variable existiert."
+ };
+ }
+
+ @Override
+ public Material material() {
+ return Material.REDSTONE_TORCH;
+ }
+
+ @Override
+ public String command() {
+ return "isset";
+ }
+
+ @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;
+ }
+
+ scriptExecutor.getLocalVariables().putValue(command[1], scriptExecutor.isVariable(command[2]) ? new Value.BooleanValue(true) : new Value.BooleanValue(false));
+ return true;
+ }
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Vartype.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Vartype.java
new file mode 100644
index 00000000..c96494ab
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Vartype.java
@@ -0,0 +1,70 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2021 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+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.SpecialCommand;
+import de.steamwar.bausystem.features.script.variables.Value;
+import de.steamwar.bausystem.linkage.LinkageType;
+import de.steamwar.bausystem.linkage.Linked;
+import org.bukkit.Material;
+
+@Linked(LinkageType.SCRIPT_COMMAND)
+public class Vartype implements SpecialCommand {
+
+ @Override
+ public String[] description() {
+ return new String[]{
+ "§evartype §8<§7Variable§8> §8<§7Variable§8>",
+ "",
+ "Schreibt in eine Variable den Type der zweiten Variable rein. Wenn die zweite Variable nicht gesetzt ist wird false in die erste geschrieben. Ansonsten gibt es die Werte: 'text', 'number' und 'boolean'",
+ };
+ }
+
+ @Override
+ public Material material() {
+ return Material.CHEST;
+ }
+
+ @Override
+ public String command() {
+ return "vartype";
+ }
+
+ @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;
+ }
+
+ if (!scriptExecutor.isVariable(command[2])) {
+ scriptExecutor.getLocalVariables().putValue(command[1], new Value.BooleanValue(false));
+ }
+ Value value = scriptExecutor.getOrItselfValue(command[2]);
+ scriptExecutor.getLocalVariables().putValue(command[1], new Value.StringValue(value.type()));
+ return true;
+ }
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Context.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Context.java
index 1ad1e22b..e1662028 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Context.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Context.java
@@ -10,7 +10,11 @@ public class Context {
public void putValue(String variableName, Value value) {
if (variables.containsKey(variableName)) {
- variables.get(variableName).fromValue(value);
+ if (variables.get(variableName).type().equals(value.type())) {
+ variables.get(variableName).fromValue(value);
+ } else {
+ variables.put(variableName, value);
+ }
} else {
variables.put(variableName, value);
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Value.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Value.java
index b70c776e..68fd935a 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Value.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Value.java
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.ToString;
public interface Value {
+ String type();
long asLong();
boolean asBoolean();
String asString();
@@ -16,6 +17,11 @@ public interface Value {
protected long value;
+ @Override
+ public String type() {
+ return "number";
+ }
+
@Override
public long asLong() {
return value;
@@ -43,6 +49,11 @@ public interface Value {
protected boolean value;
+ @Override
+ public String type() {
+ return "boolean";
+ }
+
@Override
public long asLong() {
return value ? 1 : 0;
@@ -70,6 +81,11 @@ public interface Value {
protected String value;
+ @Override
+ public String type() {
+ return "text";
+ }
+
@Override
public long asLong() {
try {