diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 2f13c79..75eeaca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -98,7 +98,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); new CommandSimulator(); new CommandRedstoneTester(); - getCommand("gui").setExecutor(new CommandGUI()); + new CommandGUI(); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 5038659..6260e03 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -6,6 +6,7 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.tracer.record.RecordStateMachine; import de.steamwar.bausystem.tracer.show.TraceShowManager; import de.steamwar.bausystem.world.*; +import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; @@ -19,9 +20,6 @@ import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,7 +32,7 @@ import org.bukkit.potion.PotionEffectType; import java.util.*; -public class CommandGUI implements CommandExecutor, Listener { +public class CommandGUI extends SWCommand implements Listener { private static final Set OPEN_INVS = new HashSet<>(); private static final Set OPEN_TRACER_INVS = new HashSet<>(); @@ -42,9 +40,21 @@ public class CommandGUI implements CommandExecutor, Listener { private static boolean isRefreshing = false; public CommandGUI() { + super("gui"); Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20); } + @Register + public void genericCommand(Player p) { + openBauGui(p); + OPEN_INVS.add(p); + } + + @Register({"item"}) + public void itemCommand(Player p) { + SWUtils.giveItemToPlayer(p, new ItemStack(Material.NETHER_STAR)); + } + public static void openBauGui(Player player) { Region region = Region.getRegion(player.getLocation()); SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau"); @@ -584,20 +594,6 @@ public class CommandGUI implements CommandExecutor, Listener { return base; } - @Override - public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { - if (!(commandSender instanceof Player)) - return false; - Player player = ((Player) commandSender); - if (strings.length == 0) { - openBauGui(player); - OPEN_INVS.add(player); - } else if ("item".equalsIgnoreCase(strings[0])) { - SWUtils.giveItemToPlayer(player, new ItemStack(Material.NETHER_STAR)); - } - return true; - } - @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 37f2ca9..79a1369 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -15,5 +15,4 @@ commands: watervision: aliases: wv lockschem: - scriptvars: - gui: \ No newline at end of file + scriptvars: \ No newline at end of file