Changes and fixes to GUI system
This commit is contained in:
parent
0a4de42fea
commit
2ffdf01dd8
|
|
@ -66,9 +66,9 @@ public class MessageConfig extends AbstractConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String GUI_HOME_TITLE = "<green>PlayerShops";
|
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_PLAYERS_TITLE = "<green>Player shops";
|
||||||
public static String GUI_LIST_SHOPS_TITLE = "<green>Players shops by <playername> <page>/<pages>";
|
public static String GUI_LIST_SHOPS_TITLE = "<green>Players shops by <playername>";
|
||||||
public static String GUI_LIST_TRANSACTIONS_TITLE = "<green>Shop Transactions <page>/<pages>";
|
public static String GUI_LIST_TRANSACTIONS_TITLE = "<green>Shop Transactions";
|
||||||
public static String GUI_MANAGE_TITLE = "<green>Shop Manager";
|
public static String GUI_MANAGE_TITLE = "<green>Shop Manager";
|
||||||
public static String GUI_PLAYER_SETTINGS_TITLE = "<green>Shop Settings Manager";
|
public static String GUI_PLAYER_SETTINGS_TITLE = "<green>Shop Settings Manager";
|
||||||
private static void guiTitles() {
|
private static void guiTitles() {
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public abstract class AbstractGui implements InventoryHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean addItem(ItemStack icon) {
|
protected boolean addItem(ItemStack icon) {
|
||||||
if (currentSlot == inventory.getSize())
|
if (currentSlot == inventory.getSize() - 9)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
inventory.setItem(currentSlot, icon);
|
inventory.setItem(currentSlot, icon);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ public class HomeGui extends AbstractGui {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(int slot, ItemStack item) {
|
public void onClick(int slot, ItemStack item) {
|
||||||
super.onClick(slot, item);
|
super.onClick(slot, item);
|
||||||
|
|
||||||
|
if (slot >= 45)
|
||||||
|
return;
|
||||||
|
|
||||||
if (slot == GuiIcon.HOME_LIST_OWN_SHOPS.getSlot() && GuiIcon.HOME_LIST_OWN_SHOPS.getItemStack().equals(item)) {
|
if (slot == GuiIcon.HOME_LIST_OWN_SHOPS.getSlot() && GuiIcon.HOME_LIST_OWN_SHOPS.getItemStack().equals(item)) {
|
||||||
ListShopsGui listShopsGui = new ListShopsGui(uuid, uuid);
|
ListShopsGui listShopsGui = new ListShopsGui(uuid, uuid);
|
||||||
listShopsGui.setLastGui(this);
|
listShopsGui.setLastGui(this);
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,8 @@ public class ListPlayersGui extends AbstractGui {
|
||||||
private final List<UUID> owners;
|
private final List<UUID> owners;
|
||||||
public ListPlayersGui(UUID uuid) {
|
public ListPlayersGui(UUID uuid) {
|
||||||
super(uuid);
|
super(uuid);
|
||||||
this.owners = PlayerShops.getInstance().getShopHandler().getShopOwners();
|
this.owners = PlayerShops.getInstance().getShopHandler().getShopOwnersForThisServer();
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage(MessageConfig.GUI_LIST_PLAYERS_TITLE));
|
||||||
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();
|
initInvContents();
|
||||||
makeMenuBar();
|
makeMenuBar();
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +47,9 @@ public class ListPlayersGui extends AbstractGui {
|
||||||
public void onClick(int slot, ItemStack item) {
|
public void onClick(int slot, ItemStack item) {
|
||||||
super.onClick(slot, item);
|
super.onClick(slot, item);
|
||||||
|
|
||||||
|
if (slot >= 45)
|
||||||
|
return;
|
||||||
|
|
||||||
if (item.getType() != Material.PLAYER_HEAD)
|
if (item.getType() != Material.PLAYER_HEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,19 +18,15 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class ListShopsGui extends AbstractGui {
|
public class ListShopsGui extends AbstractGui {
|
||||||
|
|
||||||
private UUID playerToList;
|
|
||||||
List<PlayerShop> shops;
|
List<PlayerShop> shops;
|
||||||
|
|
||||||
public ListShopsGui(UUID uuid, UUID playerToList) {
|
public ListShopsGui(UUID uuid, UUID playerToList) {
|
||||||
super(uuid);
|
super(uuid);
|
||||||
this.playerToList = playerToList;
|
|
||||||
this.shops = PlayerShops.getInstance().getShopHandler().getShops(playerToList);
|
this.shops = PlayerShops.getInstance().getShopHandler().getShops(playerToList);
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerToList);
|
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerToList);
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.unparsed("playername", 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(MessageConfig.GUI_LIST_SHOPS_TITLE, placeholders));
|
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage(MessageConfig.GUI_LIST_SHOPS_TITLE, placeholders));
|
||||||
initInvContents();
|
initInvContents();
|
||||||
|
|
@ -50,7 +46,7 @@ public class ListShopsGui extends AbstractGui {
|
||||||
if (!shop.isInitialized())
|
if (!shop.isInitialized())
|
||||||
item = GuiIcon.EMPTY_SHOP.getItemStack();
|
item = GuiIcon.EMPTY_SHOP.getItemStack();
|
||||||
|
|
||||||
if (!this.addItem(item)) {
|
if (!addItem(item)) {
|
||||||
addNextPageItem();
|
addNextPageItem();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -65,6 +61,9 @@ public class ListShopsGui extends AbstractGui {
|
||||||
public void onClick(int slot, ItemStack item) {
|
public void onClick(int slot, ItemStack item) {
|
||||||
super.onClick(slot, item);
|
super.onClick(slot, item);
|
||||||
|
|
||||||
|
if (slot >= 45)
|
||||||
|
return;
|
||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,7 @@ public class ListTransactionsGui extends AbstractGui {
|
||||||
public ListTransactionsGui(UUID uuid, PlayerShop shop) {
|
public ListTransactionsGui(UUID uuid, PlayerShop shop) {
|
||||||
super(uuid);
|
super(uuid);
|
||||||
this.transactions = shop.getTransactions();
|
this.transactions = shop.getTransactions();
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage(MessageConfig.GUI_LIST_TRANSACTIONS_TITLE));
|
||||||
Placeholder.unparsed("page", Integer.toString(pageIndex + 1)),
|
|
||||||
Placeholder.unparsed("pages", Integer.toString((int) Math.ceil(transactions.size() / 45)))
|
|
||||||
);
|
|
||||||
this.inventory = Bukkit.createInventory(this, INV_SIZE, Util.parseMiniMessage(MessageConfig.GUI_LIST_TRANSACTIONS_TITLE, placeholders));
|
|
||||||
initInvContents();
|
initInvContents();
|
||||||
makeMenuBar();
|
makeMenuBar();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,5 +58,8 @@ public class PlayerSettingsGui extends AbstractGui {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(int slot, ItemStack item) {
|
public void onClick(int slot, ItemStack item) {
|
||||||
super.onClick(slot, item);
|
super.onClick(slot, item);
|
||||||
|
|
||||||
|
if (slot >= 45)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,10 @@ public class ShopManagementGui extends AbstractGui {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(int slot, ItemStack item) {
|
public void onClick(int slot, ItemStack item) {
|
||||||
super.onClick(slot, item);
|
super.onClick(slot, item);
|
||||||
|
|
||||||
|
if (slot >= 45)
|
||||||
|
return;
|
||||||
|
|
||||||
if (slot == GuiIcon.MANAGE_SHOP.getSlot() && GuiIcon.MANAGE_SHOP.getItemStack().equals(item)) {
|
if (slot == GuiIcon.MANAGE_SHOP.getSlot() && GuiIcon.MANAGE_SHOP.getItemStack().equals(item)) {
|
||||||
|
|
||||||
} else if (slot == GuiIcon.MANAGE_SHOP_BALANCE_ADD.getSlot() && GuiIcon.MANAGE_SHOP_BALANCE_ADD.getItemStack().equals(item)) {
|
} else if (slot == GuiIcon.MANAGE_SHOP_BALANCE_ADD.getSlot() && GuiIcon.MANAGE_SHOP_BALANCE_ADD.getItemStack().equals(item)) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.alttd.playershops.utils.Logger;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
@ -77,6 +78,10 @@ public class ShopHandler {
|
||||||
return shopLocation.values().stream().map(PlayerShop::getOwnerUUID).distinct().toList();
|
return shopLocation.values().stream().map(PlayerShop::getOwnerUUID).distinct().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<UUID> getShopOwnersForThisServer() {
|
||||||
|
return shopLocation.values().stream().filter(playerShop -> playerShop.getServer().equalsIgnoreCase(Bukkit.getServerName())).map(PlayerShop::getOwnerUUID).distinct().toList();
|
||||||
|
}
|
||||||
|
|
||||||
public void addPlayerLimit(UUID uuid, int limit) {
|
public void addPlayerLimit(UUID uuid, int limit) {
|
||||||
shopBuildLimits.put(uuid, limit);
|
shopBuildLimits.put(uuid, limit);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user