|
|
@@ -5,11 +5,14 @@ import me.lethunderhawk.clans.settings.ClanSetting;
|
|
|
import me.lethunderhawk.clans.settings.ClanSettings;
|
|
|
import me.lethunderhawk.main.util.UnItalic;
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
|
import org.bukkit.Material;
|
|
|
import org.bukkit.entity.Player;
|
|
|
+import org.bukkit.inventory.ItemFlag;
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
public class ClanSettingsGUI extends InventoryGUI {
|
|
|
@@ -28,12 +31,11 @@ public class ClanSettingsGUI extends InventoryGUI {
|
|
|
fillGlassPaneBackground();
|
|
|
setBackButton(30);
|
|
|
setCloseButton(31);
|
|
|
-
|
|
|
buildItems();
|
|
|
}
|
|
|
|
|
|
private void buildItems() {
|
|
|
- AtomicInteger slot = new AtomicInteger(10);
|
|
|
+ AtomicInteger slot = new AtomicInteger(9);
|
|
|
settings.asMap().forEach((setting, value) -> {
|
|
|
ItemStack settingsItem;
|
|
|
if(value == true){
|
|
|
@@ -42,44 +44,135 @@ public class ClanSettingsGUI extends InventoryGUI {
|
|
|
settingsItem = new ItemStack(Material.RED_STAINED_GLASS_PANE);
|
|
|
}
|
|
|
ItemMeta meta = settingsItem.getItemMeta();
|
|
|
- meta.displayName(getReadableNameFromSetting(setting));
|
|
|
+ meta.displayName(
|
|
|
+ value ? Component.text("Enabled", NamedTextColor.GREEN) : Component.text("Disabled", NamedTextColor.RED)
|
|
|
+ );
|
|
|
settingsItem.setItemMeta(UnItalic.removeItalicFromMeta(meta));
|
|
|
- setItemWithClickAction(slot.get(), settingsItem, (p, type) -> {
|
|
|
- settings.toggleSetting(setting);
|
|
|
- update();
|
|
|
+
|
|
|
+ setItemWithClickAction(slot.get() -9, buildDecorationItem(setting), (p, type) ->{
|
|
|
+ toggleAndUpdate(p, setting);
|
|
|
+ });
|
|
|
+ setItemWithClickAction(slot.get(), settingsItem, (p, type) ->{
|
|
|
+ toggleAndUpdate(p, setting);
|
|
|
});
|
|
|
+
|
|
|
slot.getAndIncrement();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private Component getReadableNameFromSetting(ClanSetting setting) {
|
|
|
+ private void toggleAndUpdate(Player p, ClanSetting setting) {
|
|
|
+ settings.toggleSetting(setting);
|
|
|
+ update();
|
|
|
+ }
|
|
|
+
|
|
|
+ private ItemStack buildDecorationItem(ClanSetting setting) {
|
|
|
switch (setting){
|
|
|
case ClanSetting.BLOCK_BREAK -> {
|
|
|
- return Component.text("Breaking Blocks");
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Enable / Disable the ability of other", NamedTextColor.GRAY),
|
|
|
+ Component.text("Players not in your clan to", NamedTextColor.GRAY),
|
|
|
+ Component.text("break all kinds of blocks!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+ return buildItemFromParams(Material.DIAMOND_PICKAXE, Component.text("Breaking blocks"), lore);
|
|
|
}
|
|
|
case ClanSetting.BLOCK_PLACE -> {
|
|
|
- return Component.text("Placing Blocks");
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Enable / Disable the ability of other", NamedTextColor.GRAY),
|
|
|
+ Component.text("Players not in your clan to", NamedTextColor.GRAY),
|
|
|
+ Component.text("place blocks inside your territory!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.OAK_PLANKS, Component.text("Placing Blocks"), lore);
|
|
|
}
|
|
|
case ClanSetting.INTERACT_IGNITION -> {
|
|
|
- return Component.text("Igniting Blocks");
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Allow or prevent outsiders from", NamedTextColor.GRAY),
|
|
|
+ Component.text("using flint and steel to ignite", NamedTextColor.GRAY),
|
|
|
+ Component.text("blocks within your clan land!", NamedTextColor.GRAY),
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("WARNING: This doesn't prevent", NamedTextColor.RED),
|
|
|
+ Component.text("others from igniting TNT!", NamedTextColor.RED)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.FLINT_AND_STEEL, Component.text("Igniting blocks"), lore);
|
|
|
}
|
|
|
case ClanSetting.INTERACT_BLOCK -> {
|
|
|
- return Component.text("Interacting with Blocks");
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Controls whether non-clan players", NamedTextColor.GRAY),
|
|
|
+ Component.text("can interact with mechanisms like", NamedTextColor.GRAY),
|
|
|
+ Component.text("buttons, levers, and doors!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.LEVER, Component.text("Interacting with blocks"), lore);
|
|
|
}
|
|
|
case ClanSetting.INTERACT_ENTITY -> {
|
|
|
- return Component.text("Interacting with Entities");
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Determines if outsiders may", NamedTextColor.GRAY),
|
|
|
+ Component.text("right-click or otherwise interact", NamedTextColor.GRAY),
|
|
|
+ Component.text("with animals and NPC entities!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.VILLAGER_SPAWN_EGG, Component.text("Interacting with entities"), lore);
|
|
|
}
|
|
|
case ClanSetting.OPEN_CONTAINER -> {
|
|
|
- return Component.text("Opening Containers");
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Determines if outsiders may", NamedTextColor.GRAY),
|
|
|
+ Component.text("right-click or otherwise interact", NamedTextColor.GRAY),
|
|
|
+ Component.text("with animals and NPC entities!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.CHEST, Component.text("Opening Containers"), lore);
|
|
|
}
|
|
|
case ClanSetting.USE_ANVIL -> {
|
|
|
- return Component.text("Using Anvil");
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Control if outsiders can use", NamedTextColor.GRAY),
|
|
|
+ Component.text("anvils inside your territory", NamedTextColor.GRAY),
|
|
|
+ Component.text("to repair or rename items!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.ANVIL, Component.text("Using Anvils"), lore);
|
|
|
+ }
|
|
|
+ case ClanSetting.ALLOW_HITTING_MOBS -> {
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Determines whether players inside", NamedTextColor.GRAY),
|
|
|
+ Component.text("your claims may attack hostile", NamedTextColor.GRAY),
|
|
|
+ Component.text("or passive mobs in your land!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.ZOMBIE_HEAD, Component.text("Hitting mobs"), lore);
|
|
|
+ }
|
|
|
+ case ClanSetting.ALLOW_HITTING_PLAYERS -> {
|
|
|
+ List<Component> lore = List.of(
|
|
|
+ Component.text(""),
|
|
|
+ Component.text("Toggle whether players inside", NamedTextColor.GRAY),
|
|
|
+ Component.text("of your claim are allowed to", NamedTextColor.GRAY),
|
|
|
+ Component.text("fight other Players (PvP)!", NamedTextColor.GRAY)
|
|
|
+ );
|
|
|
+
|
|
|
+ return buildItemFromParams(Material.PLAYER_HEAD, Component.text("PvP"), lore);
|
|
|
}
|
|
|
default -> {
|
|
|
- return Component.text(setting.name());
|
|
|
+ return new ItemStack(Material.AIR);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ private ItemStack buildItemFromParams(Material material, Component displayName, List<Component> lore) {
|
|
|
+ ItemStack item = new ItemStack(material);
|
|
|
+ ItemMeta meta = item.getItemMeta();
|
|
|
+ meta.displayName(displayName.color(NamedTextColor.GOLD));
|
|
|
+ meta.lore(lore);
|
|
|
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
|
|
+ item.setItemMeta(UnItalic.removeItalicFromMeta(meta));
|
|
|
+ return item;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void update() {
|