From d55b6e8f5a87f58e1a482163ae9b85d891ddd8e8 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Fri, 25 Sep 2020 16:34:38 -0500 Subject: [PATCH] Fix several issues from #10 --- .../seanomik/energeticstorage/EnergeticStorage.java | 5 +++++ .../energeticstorage/commands/ESGiveCommand.java | 10 ++++++++-- .../energeticstorage/gui/ESSystemSecurityGUI.java | 2 +- .../energeticstorage/listeners/BlockBreakListener.java | 2 +- .../energeticstorage/listeners/BlockPlaceListener.java | 2 +- .../listeners/PlayerInteractListener.java | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java b/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java index c1cbd44..73ab769 100644 --- a/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java +++ b/src/main/java/net/seanomik/energeticstorage/EnergeticStorage.java @@ -16,6 +16,11 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; // @TODO: Add more config options +/* + * Change Log: + * - Fix /esgive command runner from getting kicked with "Illegal Characters" error. + * - Fix systems that were placed on the walls. + */ public final class EnergeticStorage extends JavaPlugin implements Listener { private static EnergeticStorage plugin; diff --git a/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java b/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java index 5943564..01792b1 100644 --- a/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java +++ b/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java @@ -19,6 +19,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static net.md_5.bungee.api.ChatColor.STRIP_COLOR_PATTERN; + public class ESGiveCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { @@ -33,14 +35,14 @@ public class ESGiveCommand implements TabExecutor { tab.addAll(Arrays.asList("1k", "4k", "16k", "64k")); } else if (args[0].equals("system")) { for (Player player : Bukkit.getServer().getOnlinePlayers()) { - tab.add(player.getDisplayName()); + tab.add(ChatColor.stripColor(player.getDisplayName())); } } break; case 3: if (args[0].equals("drive")) { for (Player player : Bukkit.getServer().getOnlinePlayers()) { - tab.add(player.getDisplayName()); + tab.add(ChatColor.stripColor(player.getDisplayName())); } } @@ -97,6 +99,8 @@ public class ESGiveCommand implements TabExecutor { if (sender instanceof Player) { Player player = (Player) sender; player.getInventory().addItem(ItemConstructor.createSystemBlock()); + + sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Gave an ES System to " + player.getDisplayName()); } else { sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Supply a player to run this command!"); sender.sendMessage(generateCommandUsage(args)); @@ -131,6 +135,8 @@ public class ESGiveCommand implements TabExecutor { if (sender instanceof Player) { Player player = (Player) sender; player.getInventory().addItem(ItemConstructor.createDrive(size, 0, 0)); + + sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Gave an ES Drive to " + player.getDisplayName()); } else { sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Supply a player to run this command!"); sender.sendMessage(generateCommandUsage(args)); diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java index c17b4a2..ca6cff7 100644 --- a/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java +++ b/src/main/java/net/seanomik/energeticstorage/gui/ESSystemSecurityGUI.java @@ -282,7 +282,7 @@ public class ESSystemSecurityGUI implements InventoryHolder, Listener { } } else { // At main menu - if (slot == 0) { + if (slot == 0) { // Back Reference.ES_TERMINAL_GUI.openInventory(player, openSystem); } else if (slot == 3) { // Add player new AnvilGUI.Builder() diff --git a/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java b/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java index cc00bb3..f4601d9 100644 --- a/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java +++ b/src/main/java/net/seanomik/energeticstorage/listeners/BlockBreakListener.java @@ -22,7 +22,7 @@ public class BlockBreakListener implements Listener { @EventHandler public void onBlockBreakListener(BlockBreakEvent event) { - if (event.getBlock().getType() == Material.PLAYER_HEAD) { + if (event.getBlock().getType() == Material.PLAYER_HEAD || event.getBlock().getType() == Material.PLAYER_WALL_HEAD) { Block block = event.getBlock(); Player player = event.getPlayer(); diff --git a/src/main/java/net/seanomik/energeticstorage/listeners/BlockPlaceListener.java b/src/main/java/net/seanomik/energeticstorage/listeners/BlockPlaceListener.java index 3a56082..3190d21 100644 --- a/src/main/java/net/seanomik/energeticstorage/listeners/BlockPlaceListener.java +++ b/src/main/java/net/seanomik/energeticstorage/listeners/BlockPlaceListener.java @@ -20,7 +20,7 @@ public class BlockPlaceListener implements Listener { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { - if (event.getBlock().getType() == Material.PLAYER_HEAD) { + if (event.getBlock().getType() == Material.PLAYER_HEAD || event.getBlock().getType() == Material.PLAYER_WALL_HEAD) { Block block = event.getBlock(); Player player = event.getPlayer(); diff --git a/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java b/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java index eaf05e6..1e97b8e 100644 --- a/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java +++ b/src/main/java/net/seanomik/energeticstorage/listeners/PlayerInteractListener.java @@ -18,7 +18,7 @@ public class PlayerInteractListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getHand() == EquipmentSlot.HAND) { - if (event.getClickedBlock().getType() == Material.PLAYER_HEAD) { + if (event.getClickedBlock().getType() == Material.PLAYER_HEAD || event.getClickedBlock().getType() == Material.PLAYER_WALL_HEAD) { Block block = event.getClickedBlock(); Player player = event.getPlayer();