Working on new menus

This commit is contained in:
Fabrizio La Rosa 2020-06-21 04:31:11 +02:00
parent 48ef9e922d
commit 41d850cdc1
4 changed files with 244 additions and 2 deletions

View File

@ -66,7 +66,7 @@ public class GuiBankSelector extends Gui {
event.player.closeInventory();
});
String action = "";
String action;
switch(type){
case DEPOSIT:
action = "Deposit";

View File

@ -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);

View File

@ -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<CompatibleBiome> 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());
}
}
}

View File

@ -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}'