mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2025-01-23 21:51:37 +01:00
add holder manager
This commit is contained in:
parent
054450aa7d
commit
4e29ef1f34
@ -0,0 +1,138 @@
|
||||
package com.badbones69.crazyauctions.api.guis;
|
||||
|
||||
import com.badbones69.crazyauctions.api.enums.Category;
|
||||
import com.badbones69.crazyauctions.api.enums.ShopType;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class HolderManager {
|
||||
|
||||
private static final Map<UUID, Integer> bidding = new HashMap<>();
|
||||
private static final Map<UUID, String> bidIds = new HashMap<>();
|
||||
private static final Map<UUID, ShopType> shopTypes = new HashMap<>();
|
||||
private static final Map<UUID, Category> shopCategory = new HashMap<>();
|
||||
private static final Map<UUID, List<Integer>> pages = new HashMap<>();
|
||||
private static final Map<UUID, String> ids = new HashMap<>();
|
||||
|
||||
public static void addShopCategory(final Player player, final Category category) {
|
||||
shopCategory.put(player.getUniqueId(), category);
|
||||
}
|
||||
|
||||
public static void removeShopCategory(final Player player) {
|
||||
shopCategory.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Category getShopCategory(final Player player) {
|
||||
return shopCategory.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Map<UUID, Category> getShopCategory() {
|
||||
return shopCategory;
|
||||
}
|
||||
|
||||
public static void addBidding(final Player player, final int amount) {
|
||||
bidding.put(player.getUniqueId(), amount);
|
||||
}
|
||||
|
||||
public static void removeBidding(final Player player) {
|
||||
bidding.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static int getBidding(final Player player) {
|
||||
return bidding.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Map<UUID, Integer> getBidding() {
|
||||
return bidding;
|
||||
}
|
||||
|
||||
public static boolean containsBidding(final Player player) {
|
||||
return bidding.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static void addShopType(final Player player, final ShopType shopType) {
|
||||
shopTypes.put(player.getUniqueId(), shopType);
|
||||
}
|
||||
|
||||
public static void removeShopType(final Player player) {
|
||||
shopTypes.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static ShopType getShopType(final Player player) {
|
||||
return shopTypes.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Map<UUID, ShopType> getShopType() {
|
||||
return shopTypes;
|
||||
}
|
||||
|
||||
public static void addPages(final Player player, List<Integer> list) {
|
||||
pages.put(player.getUniqueId(), list);
|
||||
}
|
||||
|
||||
public static void addPage(final Player player, final int page) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
final List<Integer> list = pages.get(uuid);
|
||||
list.add(page);
|
||||
|
||||
pages.put(uuid, list);
|
||||
}
|
||||
|
||||
public static void removePage(final Player player, final int page) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
final List<Integer> list = pages.get(uuid);
|
||||
|
||||
list.remove(page);
|
||||
|
||||
pages.put(uuid, list);
|
||||
}
|
||||
|
||||
public static boolean containsPage(final Player player) {
|
||||
return pages.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static List<Integer> getPages(final Player player) {
|
||||
return pages.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Map<UUID, List<Integer>> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public static void addBidId(final Player player, final String id) {
|
||||
bidIds.put(player.getUniqueId(), id);
|
||||
}
|
||||
|
||||
public static void removeBidId(final Player player) {
|
||||
bidIds.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static String getBidId(final Player player) {
|
||||
return bidIds.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Map<UUID, String> getBidIds() {
|
||||
return bidIds;
|
||||
}
|
||||
|
||||
public static void addId(final Player player, final String id) {
|
||||
ids.put(player.getUniqueId(), id);
|
||||
}
|
||||
|
||||
public static void removeId(final Player player) {
|
||||
ids.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static String getId(final Player player) {
|
||||
return ids.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Map<UUID, String> getIds() {
|
||||
return ids;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.badbones69.crazyauctions.controllers;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.Methods;
|
||||
import com.badbones69.crazyauctions.api.*;
|
||||
import com.badbones69.crazyauctions.api.CrazyManager;
|
||||
import com.badbones69.crazyauctions.api.builders.ItemBuilder;
|
||||
import com.badbones69.crazyauctions.api.enums.Category;
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Files;
|
||||
@ -12,7 +12,7 @@ import com.badbones69.crazyauctions.api.enums.ShopType;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionBuyEvent;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
|
||||
import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable;
|
||||
import com.badbones69.crazyauctions.api.guis.HolderManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Sound;
|
||||
@ -21,7 +21,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -32,7 +31,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GuiListener implements Listener {
|
||||
|
||||
@ -40,13 +38,6 @@ public class GuiListener implements Listener {
|
||||
private static final CrazyAuctions plugin = CrazyAuctions.getPlugin();
|
||||
private static final CrazyManager crazyManager = plugin.getCrazyManager();
|
||||
|
||||
private static final Map<UUID, Integer> bidding = new HashMap<>();
|
||||
private static final Map<UUID, String> biddingID = new HashMap<>();
|
||||
private static final Map<UUID, ShopType> shopType = new HashMap<>(); // Shop Type
|
||||
private static final Map<UUID, Category> shopCategory = new HashMap<>(); // Category Type
|
||||
private static final Map<UUID, List<Integer>> List = new HashMap<>();
|
||||
private static final Map<UUID, String> IDs = new HashMap<>();
|
||||
|
||||
public static void openShop(Player player, ShopType sell, Category cat, int page) {
|
||||
Methods.updateAuction();
|
||||
|
||||
@ -61,11 +52,7 @@ public class GuiListener implements Listener {
|
||||
Files.data.save();
|
||||
}
|
||||
|
||||
if (cat != null) {
|
||||
shopCategory.put(player.getUniqueId(), cat);
|
||||
} else {
|
||||
shopCategory.put(player.getUniqueId(), Category.NONE);
|
||||
}
|
||||
HolderManager.addShopCategory(player, cat == null ? Category.NONE : cat);
|
||||
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
@ -160,23 +147,19 @@ public class GuiListener implements Listener {
|
||||
options.add("Category2");
|
||||
|
||||
if (sell == ShopType.SELL) {
|
||||
shopType.put(player.getUniqueId(), ShopType.SELL);
|
||||
|
||||
if (crazyManager.isBiddingEnabled()) {
|
||||
options.add("Bidding/Selling.Selling");
|
||||
}
|
||||
|
||||
options.add("WhatIsThis.SellingShop");
|
||||
}
|
||||
|
||||
if (sell == ShopType.BID) {
|
||||
shopType.put(player.getUniqueId(), ShopType.BID);
|
||||
HolderManager.addShopType(player, sell == ShopType.BID ? ShopType.BID : ShopType.SELL);
|
||||
|
||||
options.add(sell == ShopType.BID ? "WhatIsThis.BiddingShop" : "WhatIsThis.SellingShop");
|
||||
|
||||
if (sell == ShopType.BID) {
|
||||
if (crazyManager.isSellingEnabled()) {
|
||||
options.add("Bidding/Selling.Bidding");
|
||||
}
|
||||
|
||||
options.add("WhatIsThis.BiddingShop");
|
||||
}
|
||||
|
||||
for (String o : options) {
|
||||
@ -190,7 +173,7 @@ public class GuiListener implements Listener {
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings." + o + ".Name");
|
||||
List<String> lore = new ArrayList<>();
|
||||
int slot = config.getInt("Settings.GUISettings.OtherSettings." + o + ".Slot");
|
||||
String cName = Methods.color(config.getString("Settings.GUISettings.Category-Settings." + shopCategory.get(player.getUniqueId()).getName() + ".Name"));
|
||||
String cName = Methods.color(config.getString("Settings.GUISettings.Category-Settings." + HolderManager.getShopCategory(player).getName() + ".Name"));
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
|
||||
|
||||
@ -212,7 +195,7 @@ public class GuiListener implements Listener {
|
||||
}
|
||||
|
||||
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
||||
List.put(player.getUniqueId(), Id);
|
||||
HolderManager.addPages(player, Id);
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
@ -256,7 +239,7 @@ public class GuiListener implements Listener {
|
||||
inv.setItem(slot - 1, itemBuilder.build());
|
||||
}
|
||||
|
||||
shopType.put(player.getUniqueId(), shop);
|
||||
HolderManager.addShopType(player, shop);
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
||||
@ -331,7 +314,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
||||
|
||||
List.put(player.getUniqueId(), Id);
|
||||
HolderManager.addPages(player, Id);
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
@ -416,7 +399,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
List<Integer> Id = new ArrayList<>(Methods.getPageInts(ID, page));
|
||||
|
||||
List.put(player.getUniqueId(), Id);
|
||||
HolderManager.addPages(player, Id);
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
@ -428,7 +411,7 @@ public class GuiListener implements Listener {
|
||||
FileConfiguration data = Files.data.getConfiguration();
|
||||
|
||||
if (!data.contains("Items." + ID)) {
|
||||
openShop(player, ShopType.SELL, shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, ShopType.SELL, HolderManager.getShopCategory(player), 1);
|
||||
|
||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||
|
||||
@ -505,7 +488,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
inv.setItem(4, itemBuilder.build());
|
||||
|
||||
IDs.put(player.getUniqueId(), ID);
|
||||
HolderManager.addId(player, ID);
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
@ -517,7 +500,7 @@ public class GuiListener implements Listener {
|
||||
FileConfiguration data = Files.data.getConfiguration();
|
||||
|
||||
if (!data.contains("Items." + ID)) {
|
||||
openShop(player, ShopType.BID, shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, ShopType.BID, HolderManager.getShopCategory(player), 1);
|
||||
|
||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||
|
||||
@ -526,7 +509,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
Inventory inv = plugin.getServer().createInventory(null, 27, Methods.color(config.getString("Settings.Bidding-On-Item")));
|
||||
|
||||
if (!bidding.containsKey(player.getUniqueId())) bidding.put(player.getUniqueId(), 0);
|
||||
if (!HolderManager.containsBidding(player)) HolderManager.addBidding(player, 0);
|
||||
|
||||
inv.setItem(9, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+1").setAmount(1).build());
|
||||
inv.setItem(10, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+10").setAmount(1).build());
|
||||
@ -656,7 +639,7 @@ public class GuiListener implements Listener {
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
|
||||
List.put(player.getUniqueId(), new ArrayList<>(Methods.getPageInts(ID, page)));
|
||||
HolderManager.addPages(player, Methods.getPageInts(ID, page));
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
@ -669,7 +652,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
|
||||
|
||||
int bid = bidding.get(player.getUniqueId());
|
||||
int bid = HolderManager.getBidding(player);
|
||||
|
||||
String price = Methods.getPrice(ID, false);
|
||||
|
||||
@ -735,20 +718,6 @@ public class GuiListener implements Listener {
|
||||
|
||||
return itemBuilder.build();
|
||||
}
|
||||
|
||||
private static void playClick(Player player) {
|
||||
FileConfiguration config = Files.config.getConfiguration();
|
||||
|
||||
if (config.getBoolean("Settings.Sounds.Toggle", false)) {
|
||||
String sound = config.getString("Settings.Sounds.Sound");
|
||||
|
||||
try {
|
||||
player.playSound(player.getLocation(), Sound.valueOf(sound), 1, 1);
|
||||
} catch (Exception e) {
|
||||
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1F, 1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void playSoldSound(@NotNull Player player) {
|
||||
FileConfiguration config = Files.config.getConfiguration();
|
||||
@ -768,7 +737,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
Player player = (Player) e.getPlayer();
|
||||
|
||||
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Bidding-On-Item")))) bidding.remove(player);
|
||||
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Bidding-On-Item")))) HolderManager.removeBidding(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -792,7 +761,7 @@ public class GuiListener implements Listener {
|
||||
if (item.getItemMeta().hasDisplayName()) {
|
||||
for (Category cat : Category.values()) {
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.Category-Settings." + cat.getName() + ".Name")))) {
|
||||
openShop(player, shopType.get(player.getUniqueId()), cat, 1);
|
||||
openShop(player, HolderManager.getShopType(player), cat, 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
@ -800,7 +769,7 @@ public class GuiListener implements Listener {
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
@ -824,8 +793,8 @@ public class GuiListener implements Listener {
|
||||
if (item.hasItemMeta()) {
|
||||
if (item.getItemMeta().hasDisplayName()) {
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bid.Name")))) {
|
||||
String ID = biddingID.get(player.getUniqueId());
|
||||
int bid = bidding.get(player.getUniqueId());
|
||||
String ID = HolderManager.getBidId(player);
|
||||
int bid = HolderManager.getBidding(player);
|
||||
String topBidder = data.getString("Items." + ID + ".TopBidder");
|
||||
|
||||
if (plugin.getSupport().getMoney(player) < bid) {
|
||||
@ -863,9 +832,9 @@ public class GuiListener implements Listener {
|
||||
|
||||
Files.data.save();
|
||||
|
||||
bidding.put(player.getUniqueId(), 0);
|
||||
HolderManager.addBidding(player, 0);
|
||||
player.closeInventory();
|
||||
playClick(player);
|
||||
//playClick(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -882,11 +851,11 @@ public class GuiListener implements Listener {
|
||||
for (String price : priceEdits.keySet()) {
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(price))) {
|
||||
try {
|
||||
bidding.put(player.getUniqueId(), (bidding.get(player.getUniqueId()) + priceEdits.get(price)));
|
||||
HolderManager.addBidding(player, HolderManager.getBidding(player) + priceEdits.get(price));
|
||||
|
||||
inv.setItem(4, getBiddingItem(biddingID.get(player.getUniqueId())));
|
||||
inv.setItem(4, getBiddingItem(HolderManager.getBidId(player)));
|
||||
|
||||
inv.setItem(13, getBiddingGlass(player, biddingID.get(player.getUniqueId())));
|
||||
inv.setItem(13, getBiddingGlass(player, HolderManager.getBidId(player)));
|
||||
|
||||
playClick(player);
|
||||
|
||||
@ -906,266 +875,6 @@ public class GuiListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.GUIName")))) {
|
||||
e.setCancelled(true);
|
||||
final int slot = e.getRawSlot();
|
||||
|
||||
if (slot <= inv.getSize()) {
|
||||
if (e.getCurrentItem() != null) {
|
||||
final ItemStack item = e.getCurrentItem();
|
||||
|
||||
if (item.hasItemMeta()) {
|
||||
if (item.getItemMeta().hasDisplayName()) {
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.NextPage.Name")))) {
|
||||
Methods.updateAuction();
|
||||
|
||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page + 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(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);
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(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);
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Selling.Name")))) {
|
||||
openShop(player, ShopType.BID, shopCategory.get(player.getUniqueId()), 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Bidding/Selling.Bidding.Name")))) {
|
||||
openShop(player, ShopType.SELL, shopCategory.get(player.getUniqueId()), 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cancelled/ExpiredItems.Name")))) {
|
||||
openPlayersExpiredList(player, 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.SellingItems.Name")))) {
|
||||
openPlayersCurrentList(player, 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category1.Name")))) {
|
||||
openCategories(player, shopType.get(player.getUniqueId()));
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Category2.Name")))) {
|
||||
openCategories(player, shopType.get(player.getUniqueId()));
|
||||
|
||||
playClick(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name")))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Name")))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Name")))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (List.containsKey(player.getUniqueId())) {
|
||||
if (List.get(player.getUniqueId()).size() >= slot) {
|
||||
int id = List.get(player.getUniqueId()).get(slot);
|
||||
boolean T = false;
|
||||
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
int ID = data.getInt("Items." + i + ".StoreID");
|
||||
|
||||
if (id == ID) {
|
||||
if (player.hasPermission("crazyauctions.admin") || player.hasPermission("crazyauctions.force-end")) {
|
||||
if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
||||
int num = 1;
|
||||
for (; data.contains("OutOfTime/Cancelled." + num); num++);
|
||||
|
||||
String seller = data.getString("Items." + i + ".Seller");
|
||||
Player sellerPlayer = Methods.getPlayer(seller);
|
||||
|
||||
if (Methods.isOnline(seller) && sellerPlayer != null) {
|
||||
sellerPlayer.sendMessage(Messages.ADMIN_FORCE_CANCELLED_TO_PLAYER.getMessage(player));
|
||||
}
|
||||
|
||||
AuctionCancelledEvent event = new AuctionCancelledEvent((sellerPlayer != null ? sellerPlayer : Methods.getOfflinePlayer(seller)), Methods.fromBase64(data.getString("Items." + ID + ".Item")), Reasons.ADMIN_FORCE_CANCEL);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + ID + ".Item"));
|
||||
data.set("Items." + i, null);
|
||||
|
||||
Files.data.save();
|
||||
|
||||
player.sendMessage(Messages.ADMIN_FORCE_CANCELLED.getMessage(player));
|
||||
|
||||
playClick(player);
|
||||
|
||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), page);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
|
||||
String itemName = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
|
||||
|
||||
if (config.contains("Settings.GUISettings.OtherSettings.Your-Item.Lore")) {
|
||||
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Your-Item.Lore"));
|
||||
}
|
||||
|
||||
inv.setItem(slot, itemBuilder.build());
|
||||
|
||||
playClick(player);
|
||||
|
||||
new FoliaRunnable(plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
}.runDelayed(plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
long cost = data.getLong("Items." + i + ".Price");
|
||||
|
||||
if (plugin.getSupport().getMoney(player) < cost) {
|
||||
String itemName = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Name");
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
|
||||
|
||||
if (config.contains("Settings.GUISettings.OtherSettings.Cant-Afford.Lore")) {
|
||||
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Cant-Afford.Lore"));
|
||||
}
|
||||
|
||||
inv.setItem(slot, itemBuilder.build());
|
||||
playClick(player);
|
||||
|
||||
new FoliaRunnable(plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
}.runDelayed(plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.getBoolean("Items." + i + ".Biddable")) {
|
||||
if (player.getUniqueId().toString().equalsIgnoreCase(data.getString("Items." + i + ".TopBidder"))) {
|
||||
String itemName = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Name");
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
|
||||
|
||||
if (config.contains("Settings.GUISettings.OtherSettings.Top-Bidder.Lore")) {
|
||||
itemBuilder.setLore( config.getStringList("Settings.GUISettings.OtherSettings.Top-Bidder.Lore"));
|
||||
}
|
||||
|
||||
inv.setItem(slot, itemBuilder.build());
|
||||
|
||||
playClick(player);
|
||||
|
||||
new FoliaRunnable(plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
}.runDelayed(plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
playClick(player);
|
||||
|
||||
openBidding(player, i);
|
||||
|
||||
biddingID.put(player.getUniqueId(), i);
|
||||
} else {
|
||||
playClick(player);
|
||||
|
||||
openBuying(player, i);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!T) {
|
||||
playClick(player);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
|
||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.getView().getTitle().contains(Methods.color(config.getString("Settings.Buying-Item")))) {
|
||||
e.setCancelled(true);
|
||||
int slot = e.getRawSlot();
|
||||
@ -1177,14 +886,14 @@ public class GuiListener implements Listener {
|
||||
if (item.hasItemMeta()) {
|
||||
if (item.getItemMeta().hasDisplayName()) {
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Confirm.Name")))) {
|
||||
String ID = IDs.get(player.getUniqueId());
|
||||
String ID = HolderManager.getId(player);
|
||||
long cost = data.getLong("Items." + ID + ".Price");
|
||||
String seller = data.getString("Items." + ID + ".Seller");
|
||||
|
||||
if (!data.contains("Items." + ID)) {
|
||||
playClick(player);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||
|
||||
@ -1246,13 +955,13 @@ public class GuiListener implements Listener {
|
||||
|
||||
playClick(player);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Cancel.Name")))) {
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
@ -1276,7 +985,7 @@ public class GuiListener implements Listener {
|
||||
if (item.hasItemMeta()) {
|
||||
if (item.getItemMeta().hasDisplayName()) {
|
||||
if (item.getItemMeta().getDisplayName().equals(Methods.color(config.getString("Settings.GUISettings.OtherSettings.Back.Name")))) {
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
playClick(player);
|
||||
|
||||
@ -1284,9 +993,11 @@ public class GuiListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (List.containsKey(player.getUniqueId())) {
|
||||
if (List.get(player.getUniqueId()).size() >= slot) {
|
||||
int id = List.get(player.getUniqueId()).get(slot);
|
||||
if (HolderManager.containsPage(player)) {
|
||||
final List<Integer> pages = HolderManager.getPages(player);
|
||||
|
||||
if (pages.size() >= slot) {
|
||||
int id = pages.get(slot);
|
||||
boolean T = false;
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
@ -1321,7 +1032,7 @@ public class GuiListener implements Listener {
|
||||
if (!T) {
|
||||
playClick(player);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||
|
||||
@ -1350,7 +1061,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
playClick(player);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1414,9 +1125,11 @@ public class GuiListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (List.containsKey(player.getUniqueId())) {
|
||||
if (List.get(player.getUniqueId()).size() >= slot) {
|
||||
int id = List.get(player.getUniqueId()).get(slot);
|
||||
if (HolderManager.containsPage(player)) {
|
||||
final List<Integer> pages = HolderManager.getPages(player);
|
||||
|
||||
if (pages.size() >= slot) {
|
||||
int id = pages.get(slot);
|
||||
|
||||
boolean T = false;
|
||||
|
||||
@ -1449,7 +1162,7 @@ public class GuiListener implements Listener {
|
||||
if (!T) {
|
||||
playClick(player);
|
||||
|
||||
openShop(player, shopType.get(player.getUniqueId()), shopCategory.get(player.getUniqueId()), 1);
|
||||
openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
|
||||
player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage(player));
|
||||
}
|
||||
@ -1461,4 +1174,18 @@ public class GuiListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void playClick(Player player) {
|
||||
FileConfiguration config = Files.config.getConfiguration();
|
||||
|
||||
if (config.getBoolean("Settings.Sounds.Toggle", false)) {
|
||||
String sound = config.getString("Settings.Sounds.Sound");
|
||||
|
||||
try {
|
||||
player.playSound(player.getLocation(), Sound.valueOf(sound), 1, 1);
|
||||
} catch (Exception e) {
|
||||
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1F, 1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user