diff --git a/BauSystem_API/src/de/steamwar/bausystem/TabCompleteUtils.java b/BauSystem_API/src/de/steamwar/bausystem/TabCompleteUtils.java
new file mode 100644
index 0000000..b6be8a8
--- /dev/null
+++ b/BauSystem_API/src/de/steamwar/bausystem/TabCompleteUtils.java
@@ -0,0 +1,35 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 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;
+
+import java.util.List;
+
+public class TabCompleteUtils {
+
+ public static List manageList(List strings, String[] args, int index) {
+ for (int i = strings.size() - 1; i >= 0; i--) {
+ if (!strings.get(i).startsWith(args[index])) {
+ strings.remove(i);
+ }
+ }
+ return strings;
+ }
+
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java
index 60b7709..3b3db15 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java
@@ -100,6 +100,7 @@ public class BauSystem extends JavaPlugin implements Listener {
getCommand("simulator").setExecutor(new CommandSimulator());
getCommand("simulator").setTabCompleter(new CommandSimulatorTabCompleter());
getCommand("redstonetester").setExecutor(new CommandRedstoneTester());
+ getCommand("redstonetester").setTabCompleter(new CommandRedstoneTesterTabCompleter());
getCommand("gui").setExecutor(new CommandGUI());
Bukkit.getPluginManager().registerEvents(this, this);
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java
index 83d8e09..5dd1d6c 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java
@@ -29,16 +29,29 @@ import org.bukkit.entity.Player;
public class CommandRedstoneTester implements CommandExecutor {
+ private void help(Player player) {
+ player.sendMessage("§7Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
+ player.sendMessage("§8/§eredstonetester help §8- §7Zeigt diese Nachricht");
+ player.sendMessage("§8/§eredstonetester wand §8- §7Legt dir den Testerstab ins Inventar");
+ }
+
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if (!(commandSender instanceof Player))
return false;
Player player = (Player) commandSender;
- if (args.length != 0 && args[0].equalsIgnoreCase("help")) {
- player.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
+ if (args.length == 0) {
+ help(player);
return false;
}
- PlayerUtils.giveItemToPlayer(player, RedstoneListener.WAND);
+ switch (args[0].toLowerCase()) {
+ case "help":
+ help(player);
+ break;
+ case "wand":
+ PlayerUtils.giveItemToPlayer(player, RedstoneListener.WAND);
+ break;
+ }
return false;
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTesterTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTesterTabCompleter.java
new file mode 100644
index 0000000..98922b3
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTesterTabCompleter.java
@@ -0,0 +1,50 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 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.commands;
+
+import de.steamwar.bausystem.TabCompleteUtils;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.TabCompleter;
+import org.bukkit.entity.Player;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CommandRedstoneTesterTabCompleter implements TabCompleter {
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
+ if(!(sender instanceof Player)) return new ArrayList<>();
+ return commandTabComplete((Player) sender, args);
+ }
+
+ private List commandTabComplete(Player player, String[] args) {
+ List tabComplete = new ArrayList<>();
+ tabComplete.add("help");
+ tabComplete.add("wand");
+
+ if (args.length >= 2) {
+ return new ArrayList<>();
+ }
+ return TabCompleteUtils.manageList(tabComplete, args, 0);
+ }
+
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java
index 0103d30..488fe4e 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java
@@ -20,6 +20,7 @@
package de.steamwar.bausystem.commands;
+import de.steamwar.bausystem.TabCompleteUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
@@ -45,16 +46,7 @@ public class CommandSimulatorTabCompleter implements TabCompleter {
if (args.length >= 2) {
return new ArrayList<>();
}
- return manageList(tabComplete, args, 0);
- }
-
- private List manageList(List strings, String[] args, int index) {
- for (int i = strings.size() - 1; i >= 0; i--) {
- if (!strings.get(i).startsWith(args[index])) {
- strings.remove(i);
- }
- }
- return strings;
+ return TabCompleteUtils.manageList(tabComplete, args, 0);
}
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java
index dbc18b1..7b34983 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java
@@ -21,6 +21,7 @@
package de.steamwar.bausystem.commands;
+import de.steamwar.bausystem.TabCompleteUtils;
import de.steamwar.bausystem.world.Region;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -52,16 +53,7 @@ public class CommandTNTTabComplete implements TabCompleter {
if (args.length >= 2) {
return new ArrayList<>();
}
- return manageList(tabComplete, args, 0);
- }
-
- private List manageList(List strings, String[] args, int index) {
- for (int i = strings.size() - 1; i >= 0; i--) {
- if (!strings.get(i).startsWith(args[index])) {
- strings.remove(i);
- }
- }
- return strings;
+ return TabCompleteUtils.manageList(tabComplete, args, 0);
}
}