SteamWar/BauSystem
Archiviert
13
0

Update CommandGUI to new SWCommand system

Dieser Commit ist enthalten in:
yoyosource 2021-04-01 20:56:32 +02:00
Ursprung d2c23a1b47
Commit 5795291819
3 geänderte Dateien mit 16 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -98,7 +98,7 @@ public class BauSystem extends JavaPlugin implements Listener {
getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter());
new CommandSimulator(); new CommandSimulator();
new CommandRedstoneTester(); new CommandRedstoneTester();
getCommand("gui").setExecutor(new CommandGUI()); new CommandGUI();
Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this);

Datei anzeigen

@ -6,6 +6,7 @@ import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.tracer.record.RecordStateMachine; import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.show.TraceShowManager; import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.world.*; import de.steamwar.bausystem.world.*;
import de.steamwar.command.SWCommand;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory; 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 net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; 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.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -34,7 +32,7 @@ import org.bukkit.potion.PotionEffectType;
import java.util.*; import java.util.*;
public class CommandGUI implements CommandExecutor, Listener { public class CommandGUI extends SWCommand implements Listener {
private static final Set<Player> OPEN_INVS = new HashSet<>(); private static final Set<Player> OPEN_INVS = new HashSet<>();
private static final Set<Player> OPEN_TRACER_INVS = new HashSet<>(); private static final Set<Player> OPEN_TRACER_INVS = new HashSet<>();
@ -42,9 +40,21 @@ public class CommandGUI implements CommandExecutor, Listener {
private static boolean isRefreshing = false; private static boolean isRefreshing = false;
public CommandGUI() { public CommandGUI() {
super("gui");
Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20); 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) { public static void openBauGui(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau"); 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; 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 @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)

Datei anzeigen

@ -16,4 +16,3 @@ commands:
aliases: wv aliases: wv
lockschem: lockschem:
scriptvars: scriptvars:
gui: