Skip to content

Commit

Permalink
use pdc instead of display name checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Oct 10, 2024
1 parent 069b1eb commit dc21cf8
Showing 1 changed file with 44 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,101 +162,78 @@ public void run(InventoryClickEvent event) {

if (itemStack == null) return;

if (!itemStack.hasItemMeta()) return;
final PersistentDataContainerView container = itemStack.getPersistentDataContainer();

final ItemMeta meta = itemStack.getItemMeta();
final Player player = (Player) event.getWhoClicked();

final String displayName = ChatColor.stripColor(meta.getDisplayName());

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.NextPage.Name"))) {
click();
}

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.PreviousPage.Name"))) {
//Methods.updateAuction();

//int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);

//if (page == 1) page++;

//openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page - 1);
FileConfiguration config = Files.config.getConfiguration();
FileConfiguration data = Files.data.getConfiguration();

if (container.has(Keys.auction_button.getNamespacedKey())) {
click();

return;
}

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Refesh.Name"))) {
//Methods.updateAuction();

//int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);

//openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page);

click();
String type = container.getOrDefault(Keys.auction_button.getNamespacedKey(), PersistentDataType.STRING, "");

return;
}

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Selling.Name"))) {
//openShop(player, ShopType.BID, shopCategory.get(player.getUniqueId()), 1);
switch (type) {
case "NextPage", "Your-Item", "Top-Bidder", "Cant-Afford" -> {
return;
}

click();
case "PreviousPage" -> {
Methods.updateAuction();

return;
}
int page = Integer.parseInt(event.getView().getTitle().split("#")[1]);

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Bidding.Name"))) {
//openShop(player, ShopType.SELL, shopCategory.get(player.getUniqueId()), 1);
if (page == 1) page++;

click();
GuiListener.openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), page - 1);

return;
}
return;
}

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Cancelled/ExpiredItems.Name"))) {
//openPlayersExpiredList(player, 1);
case "Refesh", "Refresh" -> {
Methods.updateAuction();

click();
int page = Integer.parseInt(event.getView().getTitle().split("#")[1]);

return;
}
GuiListener.openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), page);

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.SellingItems.Name"))) {
//openPlayersCurrentList(player, 1);
return;
}

click();
case "Bidding/Selling.Selling" -> {
GuiListener.openShop(player, ShopType.BID, HolderManager.getShopCategory(player), 1);

return;
}
return;
}

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Category1.Name"))) {
//openCategories(player, shopType.get(player.getUniqueId()));
case "Bidding/Selling.Bidding" -> {
GuiListener.openShop(player, ShopType.SELL, HolderManager.getShopCategory(player), 1);

click();
return;
}

return;
}
case "Cancelled/ExpiredItems" -> {
openPlayersExpiredList(player, 1);

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Category2.Name"))) {
//openCategories(player, shopType.get(player.getUniqueId()));
return;
}

click();
case "SellingItems" -> {
openPlayersCurrentList(player, 1);

return;
}
return;
}

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name"))) {
return;
}
case "Category1", "Category2" -> {
openCategories(player, HolderManager.getShopType(player));

if (displayName.equals(config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Name"))) {
return;
return;
}
}
}

if (!HolderManager.containsPage(player)) return;
return;
}

if (!data.contains("Items")) return;

Expand Down

0 comments on commit dc21cf8

Please sign in to comment.