Add GUI titles to MessageConfig.java
This commit is contained in:
parent
89f2dc7b51
commit
f898794b1a
|
|
@ -64,4 +64,16 @@ public class MessageConfig extends AbstractConfiguration {
|
|||
WITHDRAW_BALANCE_FAILED_PROMPT = config.getString("prompt.withdraw-balance-failed", WITHDRAW_BALANCE_FAILED_PROMPT);
|
||||
CHANGE_ITEM_PROMPT = config.getString("prompt.change-item",CHANGE_ITEM_PROMPT );
|
||||
}
|
||||
|
||||
public static String GUI_HOME_TITLE = "<green>PlayerShops";
|
||||
public static String GUI_LIST_PLAYERS_TITLE = "<green>Player shops <page>/<pages>";
|
||||
public static String GUI_LIST_SHOPS_TITLE = "<green>Players shops by <playername> <page>/<pages>";
|
||||
public static String GUI_LIST_TRANSACTIONS_TITLE = "<green>Shop Transactions <page>/<pages>";
|
||||
private static void guiTitles() {
|
||||
GUI_HOME_TITLE = config.getString("gui.home-title", GUI_HOME_TITLE);
|
||||
GUI_LIST_PLAYERS_TITLE = config.getString("gui.list-players-title", GUI_LIST_PLAYERS_TITLE);
|
||||
GUI_LIST_SHOPS_TITLE = config.getString("gui.list-shops-title", GUI_LIST_SHOPS_TITLE);
|
||||
GUI_LIST_TRANSACTIONS_TITLE = config.getString("gui.list-transactions-title", GUI_LIST_TRANSACTIONS_TITLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.alttd.playershops.gui;
|
||||
|
||||
import com.alttd.playershops.config.MessageConfig;
|
||||
import com.alttd.playershops.utils.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -10,7 +11,7 @@ public class HomeGui extends AbstractGui {
|
|||
|
||||
public HomeGui(UUID uuid) {
|
||||
super(uuid);
|
||||
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage("Config.gui.home-title"));
|
||||
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage(MessageConfig.GUI_HOME_TITLE));
|
||||
initInvContents();
|
||||
makeMenuBar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.alttd.playershops.gui;
|
||||
|
||||
import com.alttd.playershops.PlayerShops;
|
||||
import com.alttd.playershops.config.MessageConfig;
|
||||
import com.alttd.playershops.utils.ShopUtil;
|
||||
import com.alttd.playershops.utils.Util;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -12,10 +15,15 @@ import java.util.UUID;
|
|||
|
||||
public class ListPlayersGui extends AbstractGui {
|
||||
|
||||
private List<UUID> owners;
|
||||
private final List<UUID> owners;
|
||||
public ListPlayersGui(UUID uuid) {
|
||||
super(uuid);
|
||||
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage("Config.gui.list-players-title"));
|
||||
this.owners = PlayerShops.getInstance().getShopHandler().getShopOwners();
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.unparsed("page", Integer.toString(pageIndex + 1)),
|
||||
Placeholder.unparsed("pages", Integer.toString((int) Math.ceil(owners.size() / 45)))
|
||||
);
|
||||
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage(MessageConfig.GUI_LIST_PLAYERS_TITLE, placeholders));
|
||||
initInvContents();
|
||||
makeMenuBar();
|
||||
}
|
||||
|
|
@ -24,7 +32,6 @@ public class ListPlayersGui extends AbstractGui {
|
|||
void initInvContents() {
|
||||
super.initInvContents();
|
||||
|
||||
owners = PlayerShops.getInstance().getShopHandler().getShopOwners();
|
||||
int startIndex = pageIndex * 45;
|
||||
ItemStack item;
|
||||
for (int i = startIndex; i < owners.size(); i++) {
|
||||
|
|
@ -35,6 +42,9 @@ public class ListPlayersGui extends AbstractGui {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (pageIndex > 0) {
|
||||
addPrevPageItem();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -45,7 +55,7 @@ public class ListPlayersGui extends AbstractGui {
|
|||
return;
|
||||
|
||||
int index = pageIndex * 45 + slot;
|
||||
if (index > owners.size())
|
||||
if (index >= owners.size())
|
||||
return;
|
||||
UUID playerToList = owners.get(index);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.alttd.playershops.gui;
|
||||
|
||||
import com.alttd.playershops.PlayerShops;
|
||||
import com.alttd.playershops.config.MessageConfig;
|
||||
import com.alttd.playershops.shop.PlayerShop;
|
||||
import com.alttd.playershops.utils.ShopUtil;
|
||||
import com.alttd.playershops.utils.Util;
|
||||
|
|
@ -23,12 +24,15 @@ public class ListShopsGui extends AbstractGui {
|
|||
public ListShopsGui(UUID uuid, UUID playerToList) {
|
||||
super(uuid);
|
||||
this.playerToList = playerToList;
|
||||
this.shops = PlayerShops.getInstance().getShopHandler().getShops(playerToList);
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerToList);
|
||||
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.unparsed("name", offlinePlayer.hasPlayedBefore() ? offlinePlayer.getName() : "error")
|
||||
Placeholder.unparsed("playername", offlinePlayer.hasPlayedBefore() ? offlinePlayer.getName() : "error"),
|
||||
Placeholder.unparsed("page", Integer.toString(pageIndex)),
|
||||
Placeholder.unparsed("pages", Integer.toString((int) Math.ceil(shops.size() / 45)))
|
||||
);
|
||||
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage("Config.gui.list-shops-title", placeholders));
|
||||
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage(MessageConfig.GUI_LIST_SHOPS_TITLE, placeholders));
|
||||
initInvContents();
|
||||
makeMenuBar();
|
||||
}
|
||||
|
|
@ -37,7 +41,6 @@ public class ListShopsGui extends AbstractGui {
|
|||
void initInvContents() {
|
||||
super.initInvContents();
|
||||
|
||||
shops = PlayerShops.getInstance().getShopHandler().getShops(playerToList);
|
||||
// Todo add option to sort shops?
|
||||
|
||||
int startIndex = pageIndex * 45;
|
||||
|
|
@ -52,6 +55,9 @@ public class ListShopsGui extends AbstractGui {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (pageIndex > 0) {
|
||||
addPrevPageItem();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +70,7 @@ public class ListShopsGui extends AbstractGui {
|
|||
return;
|
||||
|
||||
int index = pageIndex * 45 + slot;
|
||||
if (index > shops.size())
|
||||
if (index >= shops.size())
|
||||
return;
|
||||
|
||||
PlayerShop playerShop = shops.get(index);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user