From b81a37302019a5d15b7301791460e6fcfa35d250 Mon Sep 17 00:00:00 2001 From: Deauthorized <49701242+Deauthorized@users.noreply.github.com> Date: Sat, 27 Apr 2024 20:18:24 -0400 Subject: [PATCH] Update ToggleMenu.java --- .../java/dev/plex/menu/impl/ToggleMenu.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/dev/plex/menu/impl/ToggleMenu.java b/server/src/main/java/dev/plex/menu/impl/ToggleMenu.java index 4f0bf06..1b9d039 100644 --- a/server/src/main/java/dev/plex/menu/impl/ToggleMenu.java +++ b/server/src/main/java/dev/plex/menu/impl/ToggleMenu.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.ArrayList; import java.util.List; public class ToggleMenu extends AbstractMenu @@ -24,6 +25,7 @@ public class ToggleMenu extends AbstractMenu resetFluidspreadItem(this.inventory()); resetDropsItem(this.inventory()); resetRedstoneItem(this.inventory()); + resetChatItem(this.inventory()); } private void resetExplosionItem(Inventory inventory) @@ -60,12 +62,22 @@ public class ToggleMenu extends AbstractMenu { ItemStack redstone = new ItemStack(Material.REDSTONE); ItemMeta redstoneItemMeta = redstone.getItemMeta(); - redstoneItemMeta.displayName(PlexUtils.mmDeserialize("Redstone")); + redstoneItemMeta.displayName(PlexUtils.mmDeserialize("Toggle redstone")); redstoneItemMeta.lore(List.of(PlexUtils.mmDeserialize("Redstone is " + (plugin.toggles.getBoolean("redstone") ? "enabled" : "disabled")))); redstone.setItemMeta(redstoneItemMeta); inventory.setItem(3, redstone); } + private void resetChatItem(Inventory inventory) + { + ItemStack chat = new ItemStack(Material.OAK_SIGN); + ItemMeta chatItemMeta = chat.getItemMeta(); + chatItemMeta.displayName(PlexUtils.mmDeserialize("Toggle chat")); + chatItemMeta.lore(List.of(PlexUtils.mmDeserialize("Public chat is currently " + (plugin.toggles.getBoolean("moderated") ? "restricted to administrators" : "unrestricted")))); + chat.setItemMeta(chatItemMeta); + inventory.setItem(4, chat); + } + @Override public boolean onClick(InventoryView view, Inventory inventory, Player player, ItemStack clicked) { @@ -93,6 +105,13 @@ public class ToggleMenu extends AbstractMenu resetRedstoneItem(inventory); player.sendMessage(PlexUtils.mmDeserialize("Toggled redstone.")); } + if (clicked.getType() == Material.OAK_SIGN) + { + plugin.toggles.set("moderated", !plugin.toggles.getBoolean("moderated")); + PlexUtils.broadcast(PlexUtils.messageComponent(plugin.toggles.getBoolean("moderated") ? "modmodeon" : "modmodeoff", player.getName())); + resetChatItem(inventory); + player.sendMessage(PlexUtils.mmDeserialize("Toggled moderated mode.")); + } return true; } }