From 8500fc136c9280db3b3a3cd4a6d22fa33c226dec Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:38:31 +0200 Subject: [PATCH] Update CommandRedstoneTester to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../commands/CommandRedstoneTester.java | 41 +++++++++---------- .../bausystem/commands/CommandReset.java | 3 -- BauSystem_Main/src/plugin.yml | 4 +- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 47fe646..04da67b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -97,7 +97,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("scriptvars").setExecutor(new CommandScriptVars()); getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); new CommandSimulator(); - getCommand("redstonetester").setExecutor(new CommandRedstoneTester()); + new CommandRedstoneTester(); 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 08c794a..d3fe7d1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -24,13 +24,29 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.world.RedstoneListener; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.core.VersionedRunnable; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class CommandRedstoneTester implements CommandExecutor { +public class CommandRedstoneTester extends SWCommand { + + public CommandRedstoneTester() { + super("redstonetester", "rt"); + } + + @Register + public void genericCommand(Player p) { + VersionedRunnable.call(new VersionedRunnable(() -> { + p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"); + }, 8), new VersionedRunnable(() -> { + if (!permissionCheck(p)) { + return; + } + p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); + SWUtils.giveItemToPlayer(p, RedstoneListener.WAND); + }, 15)); + } + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.build)) { @@ -40,21 +56,4 @@ public class CommandRedstoneTester implements CommandExecutor { return true; } - @Override - public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { - if (!(commandSender instanceof Player)) - return false; - Player player = (Player) commandSender; - VersionedRunnable.call(new VersionedRunnable(() -> { - player.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"); - }, 8), new VersionedRunnable(() -> { - if (!permissionCheck(player)) { - return; - } - player.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); - SWUtils.giveItemToPlayer(player, RedstoneListener.WAND); - }, 15)); - return false; - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 2e9358e..2ff81f8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -26,9 +26,6 @@ import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.io.IOException; diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index afac841..c59d1a4 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -21,6 +21,4 @@ commands: aliases: wv lockschem: scriptvars: - gui: - redstonetester: - aliases: rt \ No newline at end of file + gui: \ No newline at end of file