Update ToggleMenu.java

This commit is contained in:
Deauthorized 2024-04-27 20:18:24 -04:00 committed by GitHub
parent 59a13b0616
commit b81a373020
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@ import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ToggleMenu extends AbstractMenu public class ToggleMenu extends AbstractMenu
@ -24,6 +25,7 @@ public class ToggleMenu extends AbstractMenu
resetFluidspreadItem(this.inventory()); resetFluidspreadItem(this.inventory());
resetDropsItem(this.inventory()); resetDropsItem(this.inventory());
resetRedstoneItem(this.inventory()); resetRedstoneItem(this.inventory());
resetChatItem(this.inventory());
} }
private void resetExplosionItem(Inventory inventory) private void resetExplosionItem(Inventory inventory)
@ -60,12 +62,22 @@ public class ToggleMenu extends AbstractMenu
{ {
ItemStack redstone = new ItemStack(Material.REDSTONE); ItemStack redstone = new ItemStack(Material.REDSTONE);
ItemMeta redstoneItemMeta = redstone.getItemMeta(); ItemMeta redstoneItemMeta = redstone.getItemMeta();
redstoneItemMeta.displayName(PlexUtils.mmDeserialize("<!italic><light_purple>Redstone")); redstoneItemMeta.displayName(PlexUtils.mmDeserialize("<!italic><light_purple>Toggle redstone"));
redstoneItemMeta.lore(List.of(PlexUtils.mmDeserialize("<!italic><yellow>Redstone is " + (plugin.toggles.getBoolean("redstone") ? "<green>enabled" : "<red>disabled")))); redstoneItemMeta.lore(List.of(PlexUtils.mmDeserialize("<!italic><yellow>Redstone is " + (plugin.toggles.getBoolean("redstone") ? "<green>enabled" : "<red>disabled"))));
redstone.setItemMeta(redstoneItemMeta); redstone.setItemMeta(redstoneItemMeta);
inventory.setItem(3, redstone); inventory.setItem(3, redstone);
} }
private void resetChatItem(Inventory inventory)
{
ItemStack chat = new ItemStack(Material.OAK_SIGN);
ItemMeta chatItemMeta = chat.getItemMeta();
chatItemMeta.displayName(PlexUtils.mmDeserialize("<!italic><light_purple>Toggle chat"));
chatItemMeta.lore(List.of(PlexUtils.mmDeserialize("<!italic><yellow>Public chat is currently " + (plugin.toggles.getBoolean("moderated") ? "<red>restricted to administrators" : "<green>unrestricted"))));
chat.setItemMeta(chatItemMeta);
inventory.setItem(4, chat);
}
@Override @Override
public boolean onClick(InventoryView view, Inventory inventory, Player player, ItemStack clicked) public boolean onClick(InventoryView view, Inventory inventory, Player player, ItemStack clicked)
{ {
@ -93,6 +105,13 @@ public class ToggleMenu extends AbstractMenu
resetRedstoneItem(inventory); resetRedstoneItem(inventory);
player.sendMessage(PlexUtils.mmDeserialize("<gray>Toggled redstone.")); player.sendMessage(PlexUtils.mmDeserialize("<gray>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("<gray>Toggled moderated mode."));
}
return true; return true;
} }
} }