From 41d850cdc1bd7e7e64c90378af88700e0480f598 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 04:31:11 +0200 Subject: [PATCH] Working on new menus --- .../skyblock/gui/bank/GuiBankSelector.java | 2 +- .../com/songoda/skyblock/gui/wip/GuiBans.java | 6 +- .../songoda/skyblock/gui/wip/GuiBiome.java | 124 ++++++++++++++++++ src/main/resources/menus.yml | 114 ++++++++++++++++ 4 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java create mode 100644 src/main/resources/menus.yml diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index a92e18d3..28503c85 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -66,7 +66,7 @@ public class GuiBankSelector extends Gui { event.player.closeInventory(); }); - String action = ""; + String action; switch(type){ case DEPOSIT: action = "Deposit"; diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index bb4a3652..6c0616f1 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -39,12 +39,16 @@ public class GuiBans extends Gui { this.island = island; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); - setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setDefaultItem(null); setTitle(TextUtils.formatText("Bans")); paint(); } public void paint() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 1, 8, null); + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java new file mode 100644 index 00000000..41ac7ab3 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java @@ -0,0 +1,124 @@ +package com.songoda.skyblock.gui.wip; + +import com.songoda.core.compatibility.CompatibleBiome; +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.AnvilGui; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.bank.BankManager; +import com.songoda.skyblock.bank.Transaction; +import com.songoda.skyblock.gui.bank.GuiBankSelector; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandWorld; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.utils.NumberUtil; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class GuiBiome extends Gui { + private final SkyBlock plugin; + private final Island island; + private final FileConfiguration languageLoad; + private final FileConfiguration config; + private final Gui returnGui; + private final Player player; + private final IslandWorld world; + private final boolean admin; + + public GuiBiome(SkyBlock plugin, Player player, Island island, IslandWorld world, Gui returnGui, boolean admin) { + super(returnGui); + this.plugin = plugin; + this.island = island; + this.world = world; + this.player = player; + this.returnGui = returnGui; + this.admin = admin; + this.config = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + setDefaultItem(null); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Input.Title"))); + paint(); + } + + public void paint() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 1, 8, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + for(int i=9; i<18; i++){ + setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + } + + List biomes = new ArrayList<>(); + for(CompatibleBiome biome : CompatibleBiome.getCompatibleBiomes()) { + if(biome.isCompatible() + && player.hasPermission("fabledskyblock.biome." + biome.name().toLowerCase()) + && config.getBoolean("Island.Biome." + world.name() + "." + biome.name(), false)){ + biomes.add(biome); + } + } + + if(biomes.size() > 0){ + this.pages = (int) Math.max(1, Math.ceil((double) biomes.size() / 27d)); + + if (page != 1) + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))), + (event) -> { + page--; + paint(); + }); + + if (page != pages) + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); + + for (int i = 9; i < ((getRows()-1)*9)+9; i++) { + int current = ((page - 1) * 36) - 9; + if (current + i >= biomes.size()) { + setItem(i, null); + continue; + } + CompatibleBiome transaction = biomes.get(current + i); + if (transaction == null) continue; + + ItemStack is = null; + // TODO create the item + + setItem(i, is); + } + } else { + setItem(31, CompatibleMaterial.BARRIER.getItem()); + } + } +} diff --git a/src/main/resources/menus.yml b/src/main/resources/menus.yml new file mode 100644 index 00000000..7b1db7ac --- /dev/null +++ b/src/main/resources/menus.yml @@ -0,0 +1,114 @@ +GUI: + Bank: + Main: + Title: 'Bank' + Placeholder: + Material: BLACK_STAINED_GLASS_PANE + DisplayName: "&fBank" + Lore: [] + Exit1: + Material: OAK_FENCE_GATE + Position: 0 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + Exit2: + Material: OAK_FENCE_GATE + Position: 8 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + Transaction: + Material: BOOK + Position: 4 + DisplayName: "&fTransaction log" + Lore: + - "Click to view full log" + Balance: + Material: GOLD_INGOT + Position: 13 + DisplayName: "&fBalance" + Lore: + - "&7Bank balance: &6${BALANCE}" + Deposit: + Material: GREEN_DYE + Position: 10 + DisplayName: "&a{DATETIME}" + Lore: + - '&7Click to deposit your money. Everything or a custom amount.' + Withdraw: + Material: RED_DYE + Position: 16 + DisplayName: "&c{DATETIME}" + Lore: + - '&7Click to withdraw your money. Everything or a custom amount.' + Selector: + Title: 'Select amount' + Placeholder: + Material: BLACK_STAINED_GLASS_PANE + DisplayName: "&fBank" + Lore: [] + Exit1: + Material: OAK_FENCE_GATE + Position: 0 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + Exit2: + Material: OAK_FENCE_GATE + Position: 8 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + All: + Material: GOLD_BLOCK + Position: 2 + DisplayName: "&fAll" + Lore: [] + Custom: + Material: PAPER + Position: 6 + DisplayName: "&fCustom" + Lore: [] + Transactions: + Title: 'Transactions' + Placeholder: + Material: AIR + DisplayName: "" + Lore: [] + Empty: + Material: BARRIER + Position: 31 + DisplayName: "&cBank" + Lore: [] + Info: + Material: PAINTING + Position: 31 + Displayname: '&fInfo' + Lore: + - '&7Total transactions: {TRANSACTIONS}' + Deposit: + Material: GREEN_DYE + Position: 31 + Displayname: '&a%dateTime' + Lore: + - '&7 {PLAYERNAME} deposited {AMOUNT}' + Withdraw: + Material: RED_DYE + Position: 31 + Displayname: '&c%dateTime' + Lore: + - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + PrevPage: + Material: ARROW + Position: 50 + Displayname: '&a&lPrevious Page' + Lore: + - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + NextPage: + Material: ARROW + Position: 54 + Displayname: '&a&lNext Page' + Lore: + - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + \ No newline at end of file