Optimize and fix errors in bank gui

This commit is contained in:
Fabrizio La Rosa 2020-06-21 01:13:22 +02:00
parent 246ab7dd0c
commit a24b246945
3 changed files with 8 additions and 15 deletions

View File

@ -27,6 +27,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import javax.annotation.Nonnull;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -36,31 +37,25 @@ import java.util.stream.Collectors;
public class GuiBank extends Gui {
private final SkyBlock plugin;
private final BankManager bankManager;
private final PermissionManager permissionManager;
private final Island island;
private final FileConfiguration languageLoad;
private final FileConfiguration config;
private final Gui returnGui;
private final boolean admin;
public GuiBank(SkyBlock plugin, Island island, Gui returnGui, boolean admin) {
super(2, returnGui);
this.plugin = plugin;;
this.bankManager = plugin.getBankManager();
this.permissionManager = plugin.getPermissionManager();
this.island = island;
this.returnGui = returnGui;
this.admin = admin;
this.languageLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
setTitle(TextUtils.formatText("Bank"));
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Title")));
paint();
}
@Override
public void onOpen(GuiManager manager, Player player) {
public void onOpen(@Nonnull GuiManager manager, @Nonnull Player player) {
updateItem(13, // Balance
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Displayname")),
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Lore")
@ -87,9 +82,7 @@ public class GuiBank extends Gui {
});
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK, // Transaction log
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> {
guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin));
});
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin)));
setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.RED_DYE, // Deposit
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Deposit.Displayname"))), (event -> {

View File

@ -114,7 +114,7 @@ public class GuiBankTransaction extends Gui {
im = is.getItemMeta();
if(im != null){
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.DisplayName")
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.Displayname")
.replace("%dateTime", formatDate.format(transaction.timestamp))));
List<String> lore = new ArrayList<>();
switch (transaction.visibility){
@ -140,7 +140,7 @@ public class GuiBankTransaction extends Gui {
im = is.getItemMeta();
if(im != null){
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Deposit.DisplayName")
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Deposit.Displayname")
.replace("%dateTime", formatDate.format(transaction.timestamp))));
List<String> lore = new ArrayList<>();
switch (transaction.visibility){

View File

@ -3316,10 +3316,10 @@ Menu:
Lore: '&7Total transactions: %totalTransactions'
Title: 'Transactions'
Withdraw:
DisplayName: '&c%dateTime'
Displayname: '&c%dateTime'
Format: '&7 %playerName withdrawn %amount'
Deposit:
DisplayName: '&a%dateTime'
Displayname: '&a%dateTime'
Format: '&7 %playerName deposited %amount'
Admin: '&cAdmin&7'
DateTimeFormat: 'dd/MM/yyyy HH:mm:ss'