mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-25 12:25:20 +01:00
Remove a lot of unnecessary code
The way I handle inventories now, allows me to rely less on caches, and just use what was merely available already to me. It makes things less disorganized, much more straight forward and easy to improve God bless pdc and inventory holders
This commit is contained in:
parent
5061d785b5
commit
cddecd5dd9
@ -4,18 +4,14 @@ 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);
|
||||
@ -68,75 +64,4 @@ public class HolderManager {
|
||||
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 void removePage(final Player player) {
|
||||
pages.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -34,7 +34,6 @@ public class AuctionsMenu extends Holder {
|
||||
|
||||
private List<ItemStack> items;
|
||||
private List<String> options;
|
||||
private List<Integer> ids;
|
||||
private int maxPages;
|
||||
|
||||
private FileConfiguration config;
|
||||
@ -47,7 +46,6 @@ public class AuctionsMenu extends Holder {
|
||||
|
||||
this.items = new ArrayList<>();
|
||||
this.options = new ArrayList<>();
|
||||
this.ids = new ArrayList<>();
|
||||
|
||||
this.config = Files.config.getConfiguration();
|
||||
this.data = Files.data.getConfiguration();
|
||||
@ -154,8 +152,6 @@ public class AuctionsMenu extends Holder {
|
||||
this.inventory.setItem(slot, item);
|
||||
}
|
||||
|
||||
HolderManager.addPages(this.player, Methods.getPageItems(this.ids, getPage()));
|
||||
|
||||
this.player.openInventory(this.inventory);
|
||||
|
||||
return this;
|
||||
@ -276,101 +272,117 @@ public class AuctionsMenu extends Holder {
|
||||
}
|
||||
}
|
||||
|
||||
if (HolderManager.containsPage(player)) return;
|
||||
|
||||
if (!data.contains("Items")) return;
|
||||
|
||||
final ConfigurationSection section = data.getConfigurationSection("Items");
|
||||
|
||||
if (section == null) return;
|
||||
|
||||
final List<Integer> pages = HolderManager.getPages(player);
|
||||
final String auction_id = container.getOrDefault(Keys.auction_item.getNamespacedKey(), PersistentDataType.STRING, "");
|
||||
|
||||
if (pages.size() < slot) return;
|
||||
final ConfigurationSection auction = section.getConfigurationSection(auction_id);
|
||||
|
||||
final int id = pages.get(slot);
|
||||
if (auction == null) return;
|
||||
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
for (String i : section.getKeys(false)) {
|
||||
int ID = data.getInt("Items." + i + ".StoreID");
|
||||
if (player.hasPermission("crazyauctions.admin") || player.hasPermission("crazyauctions.force-end")) {
|
||||
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
||||
int num = 1;
|
||||
|
||||
for (;data.contains("OutOfTime/Cancelled." + num); num++);
|
||||
|
||||
String seller = auction.getString("Seller");
|
||||
|
||||
Player sellerPlayer = Methods.getPlayer(seller);
|
||||
|
||||
if (Methods.isOnline(seller) && sellerPlayer != null) {
|
||||
sellerPlayer.sendMessage(Messages.ADMIN_FORCE_CANCELLED_TO_PLAYER.getMessage(player));
|
||||
}
|
||||
|
||||
AuctionCancelledEvent auctionCancelledEvent = new AuctionCancelledEvent((sellerPlayer != null ? sellerPlayer : Methods.getOfflinePlayer(seller)), Methods.fromBase64(auction.getString("Item")), Reasons.ADMIN_FORCE_CANCEL);
|
||||
this.server.getPluginManager().callEvent(auctionCancelledEvent);
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", section.getString("Seller"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", section.getLong("Full-Time"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", section.getInt("StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", auction.getString("Item"));
|
||||
data.set("Items." + auction_id, null);
|
||||
|
||||
Files.data.save();
|
||||
|
||||
player.sendMessage(Messages.ADMIN_FORCE_CANCELLED.getMessage(player));
|
||||
|
||||
menu.click(player);
|
||||
|
||||
GuiManager.openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), menu.getPage());
|
||||
|
||||
if (id != ID) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPermission("crazyauctions.admin") || player.hasPermission("crazyauctions.force-end")) {
|
||||
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
||||
int num = 1;
|
||||
if (auction.getString("Seller", "").equalsIgnoreCase(uuid.toString())) {
|
||||
String itemName = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
|
||||
|
||||
for (;data.contains("OutOfTime/Cancelled." + num); num++);
|
||||
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
|
||||
|
||||
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 auctionCancelledEvent = new AuctionCancelledEvent((sellerPlayer != null ? sellerPlayer : Methods.getOfflinePlayer(seller)), Methods.fromBase64(data.getString("Items." + ID + ".Item")), Reasons.ADMIN_FORCE_CANCEL);
|
||||
this.server.getPluginManager().callEvent(auctionCancelledEvent);
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", section.getString("Seller"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", section.getLong("Full-Time"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", section.getInt("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));
|
||||
|
||||
menu.click(player);
|
||||
|
||||
GuiManager.openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), menu.getPage());
|
||||
|
||||
return;
|
||||
}
|
||||
if (config.contains("Settings.GUISettings.OtherSettings.Your-Item.Lore")) {
|
||||
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Your-Item.Lore"));
|
||||
}
|
||||
|
||||
if (data.getString("Items." + i + ".Seller", "").equalsIgnoreCase(uuid.toString())) {
|
||||
String itemName = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
|
||||
inventory.setItem(slot, itemBuilder.build());
|
||||
|
||||
menu.click(player);
|
||||
|
||||
new FoliaRunnable(this.plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inventory.setItem(slot, itemStack);
|
||||
}
|
||||
}.runDelayed(this.plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
long cost = auction.getLong("Price");
|
||||
|
||||
if (this.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"));
|
||||
}
|
||||
|
||||
inventory.setItem(slot, itemBuilder.build());
|
||||
menu.click(player);
|
||||
|
||||
new FoliaRunnable(this.plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inventory.setItem(slot, itemStack);
|
||||
}
|
||||
}.runDelayed(this.plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (auction.getBoolean("Biddable")) {
|
||||
if (uuid.toString().equalsIgnoreCase(auction.getString("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.Your-Item.Lore")) {
|
||||
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Your-Item.Lore"));
|
||||
if (config.contains("Settings.GUISettings.OtherSettings.Top-Bidder.Lore")) {
|
||||
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Top-Bidder.Lore"));
|
||||
}
|
||||
|
||||
inventory.setItem(slot, itemBuilder.build());
|
||||
|
||||
click(player);
|
||||
|
||||
new FoliaRunnable(this.plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inventory.setItem(slot, itemStack);
|
||||
}
|
||||
}.runDelayed(this.plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
long cost = data.getLong("Items." + i + ".Price");
|
||||
|
||||
if (this.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"));
|
||||
}
|
||||
|
||||
inventory.setItem(slot, itemBuilder.build());
|
||||
menu.click(player);
|
||||
|
||||
new FoliaRunnable(this.plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@ -383,41 +395,13 @@ public class AuctionsMenu extends Holder {
|
||||
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");
|
||||
menu.click(player);
|
||||
|
||||
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
|
||||
GuiManager.openBidding(player, auction_id);
|
||||
} else {
|
||||
menu.click(player);
|
||||
|
||||
if (config.contains("Settings.GUISettings.OtherSettings.Top-Bidder.Lore")) {
|
||||
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Top-Bidder.Lore"));
|
||||
}
|
||||
|
||||
inventory.setItem(slot, itemBuilder.build());
|
||||
|
||||
menu.click(player);
|
||||
|
||||
new FoliaRunnable(this.plugin.getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
inventory.setItem(slot, itemStack);
|
||||
}
|
||||
}.runDelayed(this.plugin, 3 * 20);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
menu.click(player);
|
||||
|
||||
GuiManager.openBidding(player, i);
|
||||
|
||||
HolderManager.addBidId(player, i);
|
||||
} else {
|
||||
menu.click(player);
|
||||
|
||||
GuiManager.openBuying(player, i);
|
||||
}
|
||||
GuiManager.openBuying(player, auction_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,8 +482,9 @@ public class AuctionsMenu extends Holder {
|
||||
|
||||
itemBuilder.setLore(lore);
|
||||
|
||||
this.items.add(itemBuilder.build());
|
||||
itemBuilder.addInteger(auction.getInt("StoreID"), Keys.auction_id.getNamespacedKey());
|
||||
itemBuilder.addString(auction.getName(), Keys.auction_item.getNamespacedKey());
|
||||
|
||||
this.ids.add(auction.getInt("StoreID"));
|
||||
this.items.add(itemBuilder.build());
|
||||
}
|
||||
}
|
@ -27,7 +27,6 @@ public class CurrentMenu extends Holder {
|
||||
|
||||
private List<ItemStack> items;
|
||||
private List<String> options;
|
||||
private List<Integer> ids;
|
||||
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration data;
|
||||
@ -37,7 +36,6 @@ public class CurrentMenu extends Holder {
|
||||
|
||||
this.items = new ArrayList<>();
|
||||
this.options = new ArrayList<>();
|
||||
this.ids = new ArrayList<>();
|
||||
|
||||
this.config = Files.config.getConfiguration();
|
||||
this.data = Files.data.getConfiguration();
|
||||
@ -84,8 +82,6 @@ public class CurrentMenu extends Holder {
|
||||
this.inventory.setItem(slot, item);
|
||||
}
|
||||
|
||||
HolderManager.addPages(this.player, Methods.getPageItems(this.ids, getPage()));
|
||||
|
||||
this.player.openInventory(this.inventory);
|
||||
|
||||
return this;
|
||||
@ -127,9 +123,7 @@ public class CurrentMenu extends Holder {
|
||||
return;
|
||||
}
|
||||
|
||||
if (HolderManager.containsPage(player)) return;
|
||||
|
||||
final List<Integer> pages = HolderManager.getPages(player);
|
||||
final List<Integer> pages = new ArrayList<>();
|
||||
|
||||
if (pages.size() >= slot) {
|
||||
int id = pages.get(slot);
|
||||
@ -227,9 +221,10 @@ public class CurrentMenu extends Holder {
|
||||
|
||||
itemBuilder.setLore(lore);
|
||||
|
||||
this.items.add(itemBuilder.build());
|
||||
itemBuilder.addInteger(auction.getInt("StoreID"), Keys.auction_id.getNamespacedKey());
|
||||
itemBuilder.addString(auction.getName(), Keys.auction_item.getNamespacedKey());
|
||||
|
||||
this.ids.add(auction.getInt("StoreID"));
|
||||
this.items.add(itemBuilder.build());
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,6 @@ public class ExpiredMenu extends Holder {
|
||||
|
||||
private List<ItemStack> items;
|
||||
private List<String> options;
|
||||
private List<Integer> ids;
|
||||
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration data;
|
||||
@ -38,7 +37,6 @@ public class ExpiredMenu extends Holder {
|
||||
|
||||
this.items = new ArrayList<>();
|
||||
this.options = new ArrayList<>();
|
||||
this.ids = new ArrayList<>();
|
||||
|
||||
this.config = Files.config.getConfiguration();
|
||||
this.data = Files.data.getConfiguration();
|
||||
@ -96,8 +94,6 @@ public class ExpiredMenu extends Holder {
|
||||
this.inventory.setItem(slot, item);
|
||||
}
|
||||
|
||||
HolderManager.addPages(this.player, Methods.getPageItems(this.ids, getPage()));
|
||||
|
||||
this.player.openInventory(this.inventory);
|
||||
|
||||
return this;
|
||||
@ -201,9 +197,7 @@ public class ExpiredMenu extends Holder {
|
||||
}
|
||||
}
|
||||
|
||||
if (HolderManager.containsPage(player)) return;
|
||||
|
||||
final List<Integer> pages = HolderManager.getPages(player);
|
||||
final List<Integer> pages = new ArrayList<>();
|
||||
|
||||
if (pages.size() >= slot) {
|
||||
int id = pages.get(slot);
|
||||
@ -296,9 +290,10 @@ public class ExpiredMenu extends Holder {
|
||||
|
||||
itemBuilder.setLore(lore);
|
||||
|
||||
this.items.add(itemBuilder.build());
|
||||
itemBuilder.addInteger(auction.getInt("StoreID"), Keys.auction_id.getNamespacedKey());
|
||||
itemBuilder.addString(auction.getName(), Keys.auction_item.getNamespacedKey());
|
||||
|
||||
this.ids.add(auction.getInt("StoreID"));
|
||||
this.items.add(itemBuilder.build());
|
||||
}
|
||||
}
|
||||
}
|
@ -115,11 +115,11 @@ public class BidMenu extends Holder {
|
||||
|
||||
switch (type) {
|
||||
case "bid_item" -> {
|
||||
String ID = HolderManager.getBidId(player);
|
||||
String id = menu.id;
|
||||
|
||||
int bid = HolderManager.getBidding(player);
|
||||
|
||||
String topBidder = data.getString("Items." + ID + ".TopBidder", "None");
|
||||
String topBidder = data.getString("Items." + id + ".TopBidder", "None");
|
||||
|
||||
final long money = support.getMoney(player);
|
||||
|
||||
@ -134,22 +134,22 @@ public class BidMenu extends Holder {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.getLong("Items." + ID + ".Price") > bid) {
|
||||
if (data.getLong("Items." + id + ".Price") > bid) {
|
||||
player.sendMessage(Messages.BID_MORE_MONEY.getMessage(player));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.getLong("Items." + ID + ".Price") >= bid && !topBidder.equalsIgnoreCase("None")) {
|
||||
if (data.getLong("Items." + id + ".Price") >= bid && !topBidder.equalsIgnoreCase("None")) {
|
||||
player.sendMessage(Messages.BID_MORE_MONEY.getMessage(player));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.server.getPluginManager().callEvent(new AuctionNewBidEvent(player, Methods.fromBase64(data.getString("Items." + ID + ".Item")), bid));
|
||||
this.server.getPluginManager().callEvent(new AuctionNewBidEvent(player, Methods.fromBase64(data.getString("Items." + id + ".Item")), bid));
|
||||
|
||||
data.set("Items." + ID + ".Price", bid);
|
||||
data.set("Items." + ID + ".TopBidder", player.getUniqueId().toString());
|
||||
data.set("Items." + id + ".Price", bid);
|
||||
data.set("Items." + id + ".TopBidder", player.getUniqueId().toString());
|
||||
|
||||
final Map<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Bid%", String.valueOf(bid));
|
||||
@ -169,10 +169,8 @@ public class BidMenu extends Holder {
|
||||
|
||||
HolderManager.addBidding(player, HolderManager.getBidding(player) + price);
|
||||
|
||||
final String bid_id = HolderManager.getBidId(player);
|
||||
|
||||
this.inventory.setItem(4, getBiddingItem(bid_id));
|
||||
this.inventory.setItem(13, getBiddingGlass(player, bid_id));
|
||||
this.inventory.setItem(4, getBiddingItem(menu.id));
|
||||
this.inventory.setItem(13, getBiddingGlass(player, menu.id));
|
||||
} catch (Exception exception) {
|
||||
player.closeInventory();
|
||||
|
||||
@ -186,10 +184,8 @@ public class BidMenu extends Holder {
|
||||
|
||||
HolderManager.addBidding(player, HolderManager.getBidding(player) + price);
|
||||
|
||||
final String bid_id = HolderManager.getBidId(player);
|
||||
|
||||
this.inventory.setItem(4, getBiddingItem(bid_id));
|
||||
this.inventory.setItem(13, getBiddingGlass(player, bid_id));
|
||||
this.inventory.setItem(4, getBiddingItem(menu.id));
|
||||
this.inventory.setItem(13, getBiddingGlass(player, menu.id));
|
||||
} catch (Exception exception) {
|
||||
player.closeInventory();
|
||||
|
||||
|
@ -130,9 +130,10 @@ public class BuyingMenu extends Holder {
|
||||
|
||||
itemBuilder.setLore(lore);
|
||||
|
||||
this.inventory.setItem(4, itemBuilder.build());
|
||||
itemBuilder.addInteger(this.data.getInt("Items." + this.id + ".StoreID"), Keys.auction_id.getNamespacedKey());
|
||||
itemBuilder.addString(this.id, Keys.auction_item.getNamespacedKey());
|
||||
|
||||
HolderManager.addId(this.player, this.id);
|
||||
this.inventory.setItem(4, itemBuilder.build());
|
||||
|
||||
this.player.openInventory(this.inventory);
|
||||
|
||||
@ -170,11 +171,9 @@ public class BuyingMenu extends Holder {
|
||||
|
||||
switch (type) {
|
||||
case "Confirm" -> {
|
||||
String ID = HolderManager.getId(player);
|
||||
long cost = data.getLong("Items." + ID + ".Price");
|
||||
String seller = data.getString("Items." + ID + ".Seller");
|
||||
String id = menu.id;
|
||||
|
||||
if (!data.contains("Items." + ID)) {
|
||||
if (!data.contains("Items." + id)) {
|
||||
menu.click(player);
|
||||
|
||||
GuiManager.openShop(player, HolderManager.getShopType(player), HolderManager.getShopCategory(player), 1);
|
||||
@ -193,6 +192,9 @@ public class BuyingMenu extends Holder {
|
||||
return;
|
||||
}
|
||||
|
||||
long cost = data.getLong("Items." + id + ".Price");
|
||||
String seller = data.getString("Items." + id + ".Seller");
|
||||
|
||||
final VaultSupport support = this.plugin.getSupport();
|
||||
|
||||
if (support.getMoney(player) < cost) {
|
||||
@ -208,7 +210,7 @@ public class BuyingMenu extends Holder {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack i = Methods.fromBase64(data.getString("Items." + ID + ".Item"));
|
||||
ItemStack i = Methods.fromBase64(data.getString("Items." + id + ".Item"));
|
||||
|
||||
this.server.getPluginManager().callEvent(new AuctionBuyEvent(player, i, cost));
|
||||
support.removeMoney(player, cost);
|
||||
@ -216,7 +218,7 @@ public class BuyingMenu extends Holder {
|
||||
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
|
||||
String price = Methods.getPrice(ID, false);
|
||||
String price = Methods.getPrice(id, false);
|
||||
|
||||
placeholders.put("%Price%", price);
|
||||
placeholders.put("%price%", price);
|
||||
@ -245,7 +247,7 @@ public class BuyingMenu extends Holder {
|
||||
|
||||
player.getInventory().addItem(i);
|
||||
|
||||
data.set("Items." + ID, null);
|
||||
data.set("Items." + id, null);
|
||||
Files.data.save();
|
||||
|
||||
menu.click(player);
|
||||
|
@ -22,9 +22,7 @@ public class MiscListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
HolderManager.removeBidding(player);
|
||||
HolderManager.removeId(player);
|
||||
HolderManager.removeShopCategory(player);
|
||||
HolderManager.removeShopType(player);
|
||||
HolderManager.removePage(player);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user