From f71a55e1e71062ae82db92e7a8437ca680640d03 Mon Sep 17 00:00:00 2001 From: Connor Monahan Date: Wed, 25 Nov 2020 10:42:12 -0600 Subject: [PATCH] Fix ChestUI issue #859 --- war/pom.xml | 2 +- .../tommytony/war/ui/DefaultZoneConfigUI.java | 41 +++++++++++++++++++ .../java/com/tommytony/war/ui/WarAdminUI.java | 25 ++--------- 3 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 war/src/main/java/com/tommytony/war/ui/DefaultZoneConfigUI.java diff --git a/war/pom.xml b/war/pom.xml index 2fa85db..dd8450b 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.tommytony war - 2.0.0-RC5-SNAPSHOT + 2.0.0-RC6-SNAPSHOT jar War http://war.tommytony.com diff --git a/war/src/main/java/com/tommytony/war/ui/DefaultZoneConfigUI.java b/war/src/main/java/com/tommytony/war/ui/DefaultZoneConfigUI.java new file mode 100644 index 0000000..04bd877 --- /dev/null +++ b/war/src/main/java/com/tommytony/war/ui/DefaultZoneConfigUI.java @@ -0,0 +1,41 @@ +package com.tommytony.war.ui; + +import com.tommytony.war.War; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class DefaultZoneConfigUI extends ChestUI { + @Override + public void build(Player player, Inventory inv) { + ItemStack item; + ItemMeta meta; + int i = 0; + + item = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); + meta = item.getItemMeta(); + meta.setDisplayName(">>>> Warzone Default Config >>>>"); + item.setItemMeta(meta); + this.addItem(inv, i++, item, () -> War.war.getUIManager().assignUI(player, new WarAdminUI())); + i = UIConfigHelper.addWarzoneConfigOptions(this, player, inv, War.war.getWarzoneDefaultConfig(), null, i); + item = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); + meta = item.getItemMeta(); + meta.setDisplayName(">>>> Team Default Config >>>>"); + item.setItemMeta(meta); + this.addItem(inv, i++, item, () -> War.war.getUIManager().assignUI(player, new WarAdminUI())); + UIConfigHelper.addTeamConfigOptions(this, player, inv, War.war.getTeamDefaultConfig(), null, null, i); + } + + @Override + public String getTitle() { + return ChatColor.DARK_RED + "" + ChatColor.BOLD + "War Default Zone Config"; + } + + @Override + public int getSize() { + return 9*6; + } +} diff --git a/war/src/main/java/com/tommytony/war/ui/WarAdminUI.java b/war/src/main/java/com/tommytony/war/ui/WarAdminUI.java index 12db8e4..ed5532a 100644 --- a/war/src/main/java/com/tommytony/war/ui/WarAdminUI.java +++ b/war/src/main/java/com/tommytony/war/ui/WarAdminUI.java @@ -19,28 +19,11 @@ public class WarAdminUI extends ChestUI { int i = 0; i = UIConfigHelper.addWarConfigOptions(this, player, inv, War.war.getWarConfig(), i); - item = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); + item = new ItemStack(Material.CHEST); meta = item.getItemMeta(); - meta.setDisplayName(">>>> Warzone Default Config >>>>"); + meta.setDisplayName("Warzone Default Config"); item.setItemMeta(meta); - this.addItem(inv, i++, item, new Runnable() { - @Override - public void run() { - War.war.getUIManager().assignUI(player, new WarAdminUI()); - } - }); - i = UIConfigHelper.addWarzoneConfigOptions(this, player, inv, War.war.getWarzoneDefaultConfig(), null, i); - item = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); - meta = item.getItemMeta(); - meta.setDisplayName(">>>> Team Default Config >>>>"); - item.setItemMeta(meta); - this.addItem(inv, i++, item, new Runnable() { - @Override - public void run() { - War.war.getUIManager().assignUI(player, new WarAdminUI()); - } - }); - UIConfigHelper.addTeamConfigOptions(this, player, inv, War.war.getTeamDefaultConfig(), null, null, i); + this.addItem(inv, 9*(i / 9) + 8, item, () -> War.war.getUIManager().assignUI(player, new DefaultZoneConfigUI())); } @Override @@ -50,6 +33,6 @@ public class WarAdminUI extends ChestUI { @Override public int getSize() { - return 9 * 7; + return 9 * 2; } }