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; } }