From faa11415e0ed96a7d4b6388c68a9662317a3c4ba Mon Sep 17 00:00:00 2001 From: Trixkz Date: Thu, 26 Oct 2023 22:14:15 -0400 Subject: [PATCH] Fixed Some Bugs and Added Some More Values In The Configuration Files --- .../eventcore/managers/StaffManager.java | 5 +- .../managers/hotbar/ClickableItem.java | 57 ------------------- .../hotbar/types/StaffModeHotBar.java | 9 +-- .../eventcore/utils/Constants.java | 9 +++ src/main/resources/messages.yml | 6 +- 5 files changed, 22 insertions(+), 64 deletions(-) diff --git a/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java b/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java index af89618..d74ce41 100644 --- a/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java +++ b/src/main/java/com/loganmagnan/eventcore/managers/StaffManager.java @@ -4,6 +4,7 @@ import com.loganmagnan.eventcore.EventCore; import com.loganmagnan.eventcore.managers.hotbar.types.StaffModeHotBar; import com.loganmagnan.eventcore.utils.CachedInventory; import com.loganmagnan.eventcore.utils.ColorUtils; +import com.loganmagnan.eventcore.utils.Constants; import lombok.Getter; import lombok.Setter; import org.bukkit.GameMode; @@ -55,7 +56,7 @@ public class StaffManager { this.setVanish(player, true); this.staffModeHotBar.applyToPlayer(player, true); - player.sendMessage(ColorUtils.getMessageType("&bYou've &aenabled &bstaff mode")); + player.sendMessage(ColorUtils.getMessageType(Constants.COMMAND_MESSAGES.get("staff-mode.enabled").get(0))); } else { this.playersInStaffMode.remove(player.getUniqueId()); this.cachedInventories.get(player.getUniqueId()).applyToPlayer(player, false); @@ -64,7 +65,7 @@ public class StaffManager { this.setVanish(player, false); - player.sendMessage(ColorUtils.getMessageType("&bYou've &cdisabled &bstaff mode")); + player.sendMessage(ColorUtils.getMessageType(Constants.COMMAND_MESSAGES.get("staff-mode.disabled").get(0))); } } diff --git a/src/main/java/com/loganmagnan/eventcore/managers/hotbar/ClickableItem.java b/src/main/java/com/loganmagnan/eventcore/managers/hotbar/ClickableItem.java index 2a5ebf4..ef4227a 100644 --- a/src/main/java/com/loganmagnan/eventcore/managers/hotbar/ClickableItem.java +++ b/src/main/java/com/loganmagnan/eventcore/managers/hotbar/ClickableItem.java @@ -6,8 +6,6 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import org.bukkit.inventory.ItemStack; -import java.util.Objects; - @Getter @Setter @AllArgsConstructor @@ -21,59 +19,4 @@ public class ClickableItem { private boolean moveable = false; private boolean placeable = false; private boolean droppable = false; - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - - if (!(object instanceof ClickableItem)) { - return false; - } - - ClickableItem clickableItem = (ClickableItem) object; - - if (!clickableItem.canEqual(this)) { - return false; - } - - Object thisClickHandler = this.clickHandler; - Object otherClickHandler = clickableItem.getClickHandler(); - - if (!Objects.equals(thisClickHandler, otherClickHandler)) { - return false; - } - - Object thisItemStack = getItemStack(); - Object otherItemStack = clickableItem.getItemStack(); - - return (Objects.equals(thisItemStack, otherItemStack)) && (this.droppable == clickableItem.isDroppable() && (this.moveable == clickableItem.isMoveable() && (this.placeable == clickableItem.isPlaceable()))); - } - - @Override - public int hashCode() { - int result = 1; - - Object clickHandler = this.clickHandler; - - result = result * 59 + ((clickHandler == null) ? 43 : clickHandler.hashCode()); - - Object itemStack = this.itemStack; - - result = result * 59 + ((itemStack == null) ? 43 : itemStack.hashCode()); - result = result * 59 + (this.droppable ? 79 : 97); - result = result * 59 + (this.moveable ? 79 : 97); - - return result * 59 + (this.placeable ? 79 : 97); - } - - protected boolean canEqual(Object object) { - return object instanceof ClickableItem; - } - - @Override - public String toString() { - return "ClickableItem(clickHandler=" + this.clickHandler + ", itemStack=" + this.itemStack + ", droppable=" + this.droppable + ", moveable=" + this.moveable + ", placeable=" + this.placeable + ")"; - } } diff --git a/src/main/java/com/loganmagnan/eventcore/managers/hotbar/types/StaffModeHotBar.java b/src/main/java/com/loganmagnan/eventcore/managers/hotbar/types/StaffModeHotBar.java index 86174d3..457ca0a 100644 --- a/src/main/java/com/loganmagnan/eventcore/managers/hotbar/types/StaffModeHotBar.java +++ b/src/main/java/com/loganmagnan/eventcore/managers/hotbar/types/StaffModeHotBar.java @@ -4,6 +4,7 @@ import com.loganmagnan.eventcore.EventCore; import com.loganmagnan.eventcore.managers.hotbar.ClickableItem; import com.loganmagnan.eventcore.managers.hotbar.HotBar; import com.loganmagnan.eventcore.utils.ColorUtils; +import com.loganmagnan.eventcore.utils.Constants; import com.loganmagnan.eventcore.utils.ItemBuilder; import lombok.Getter; import lombok.Setter; @@ -29,12 +30,12 @@ public class StaffModeHotBar extends HotBar { Map clickableItems = new HashMap(); clickableItems.put(0, this.getClickableItem("teleport-compass")); clickableItems.put(1, this.getClickableItem("inventory-inspect")); + clickableItems.put(2, this.getClickableItem("better-looking")); if (player.hasPermission("worldedit.wand")) { - clickableItems.put(2, this.getClickableItem("world-edit-wand")); + clickableItems.put(3, this.getClickableItem("world-edit-wand")); } - clickableItems.put(3, this.getClickableItem("better-looking")); clickableItems.put(7, this.getClickableItem("staff-online")); clickableItems.put(8, this.getClickableItem("unvanish")); @@ -66,14 +67,14 @@ public class StaffModeHotBar extends HotBar { this.applyToPlayer(player, this.getClickableItem("unvanish"), 8); this.main.getStaffManager().setVanish(player, true); - player.sendMessage(ColorUtils.getMessageType("&bYou've &aenabled &bvanish")); + player.sendMessage(ColorUtils.getMessageType(Constants.STAFF_MANAGEMENT_MESSAGES.get("vanish.enabled").get(0))); }, new ItemBuilder(Material.GRAY_DYE).name(ColorUtils.getMessageType("&bVanish")).build(), false, false, false)); this.addClickableItem("unvanish", new ClickableItem(player -> { this.applyToPlayer(player, this.getClickableItem("vanish"), 8); this.main.getStaffManager().setVanish(player, false); - player.sendMessage(ColorUtils.getMessageType("&bYou've &cdisabled &bvanish")); + player.sendMessage(ColorUtils.getMessageType(Constants.STAFF_MANAGEMENT_MESSAGES.get("vanish.disabled").get(0))); }, new ItemBuilder(Material.LIME_DYE).name(ColorUtils.getMessageType("&bUnvanish")).build(), false, false, false)); } } diff --git a/src/main/java/com/loganmagnan/eventcore/utils/Constants.java b/src/main/java/com/loganmagnan/eventcore/utils/Constants.java index 867a83a..9bf1b4a 100644 --- a/src/main/java/com/loganmagnan/eventcore/utils/Constants.java +++ b/src/main/java/com/loganmagnan/eventcore/utils/Constants.java @@ -10,6 +10,7 @@ public class Constants { public static Map> COMMAND_MESSAGES = new HashMap>(); public static Map> LISTENER_MESSAGES = new HashMap>(); public static Map> CHAT_MANAGEMENT_MESSAGES = new HashMap>(); + public static Map> STAFF_MANAGEMENT_MESSAGES = new HashMap>(); public static Map PERMISSION_NODES = new HashMap(); public Constants() { @@ -23,6 +24,10 @@ public class Constants { // /setspawn COMMAND_MESSAGES.put("set-spawn.spawn-set", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.SET-SPAWN.SPAWN-SET"))); + // //staffmode + COMMAND_MESSAGES.put("staff-mode.enabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.STAFF-MODE.ENABLED"))); + COMMAND_MESSAGES.put("staff-mode.disabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.COMMANDS.STAFF-MODE.DISABLED"))); + // AsyncPlayerChatEvent LISTENER_MESSAGES.put("chat-muted", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.LISTENERS.CHAT-MUTED"))); LISTENER_MESSAGES.put("chat-cooldown", this.main.getMessagesConfig().getConfig().getStringList("MESSAGES.LISTENERS.CHAT-COOLDOWN")); @@ -33,6 +38,10 @@ public class Constants { CHAT_MANAGEMENT_MESSAGES.put("slowed", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.CHAT-MANAGEMENT.SLOWED"))); CHAT_MANAGEMENT_MESSAGES.put("cleared", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.CHAT-MANAGEMENT.CLEARED"))); + // Staff Management System + STAFF_MANAGEMENT_MESSAGES.put("vanish.enabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.STAFF-MANAGEMENT.VANISH.ENABLED"))); + STAFF_MANAGEMENT_MESSAGES.put("vanish.disabled", Collections.singletonList(this.main.getMessagesConfig().getConfig().getString("MESSAGES.STAFF-MANAGEMENT.VANISH.DISABLED"))); + // Permission Nodes PERMISSION_NODES.put("chat-bypass", this.main.getMainConfig().getConfig().getString("PERMISSION-NODES.CHAT-BYPASS")); } diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 1ef7333..61dd628 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -30,4 +30,8 @@ MESSAGES: MUTED: "&cChat has been muted by &c&l%player%" UNMUTED: "&aChat has been unmuted by &a&l%player%" SLOWED: "&cChat has been slowed for &c&l%amount% by &c&l%player%" - CLEARED: "&cChat has been cleared by &c&l%player%" \ No newline at end of file + CLEARED: "&cChat has been cleared by &c&l%player%" + STAFF-MANAGEMENT: + VANISH: + ENABLED: "&bYou've &aenabled &bvanish" + DISABLED: "&bYou've &cdisabled &bvanish" \ No newline at end of file