mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-10 10:10:22 +01:00
use a more lightweight option, an arraylist
This commit is contained in:
parent
337b33246c
commit
422325f07a
@ -4,23 +4,22 @@ import com.badbones69.crazyauctions.Methods;
|
||||
import com.badbones69.crazyauctions.api.builders.ItemBuilder;
|
||||
import com.badbones69.crazyauctions.api.builders.gui.DynamicInventoryBuilder;
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Keys;
|
||||
import com.badbones69.crazyauctions.configs.impl.ConfigKeys;
|
||||
import com.badbones69.crazyauctions.configs.impl.gui.AuctionKeys;
|
||||
import com.badbones69.crazyauctions.utils.AuctionUtils;
|
||||
import com.badbones69.crazyauctions.utils.MiscUtils;
|
||||
import com.ryderbelserion.vital.paper.api.builders.gui.interfaces.GuiItem;
|
||||
import com.ryderbelserion.vital.paper.api.builders.gui.types.PaginatedGui;
|
||||
import com.ryderbelserion.vital.paper.api.builders.items.NbtBuilder;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AuctionMenu extends DynamicInventoryBuilder {
|
||||
|
||||
private final List<String> menus = new ArrayList<>();
|
||||
|
||||
public AuctionMenu(final Player player, final String title, final int rows) {
|
||||
super(player, title, rows);
|
||||
}
|
||||
@ -47,16 +46,14 @@ public class AuctionMenu extends DynamicInventoryBuilder {
|
||||
});
|
||||
|
||||
this.auctions.getProperty(AuctionKeys.expired_item_button).setItem(event -> {
|
||||
final GuiItem guiItem = this.gui.getGuiItem(event.getSlot());
|
||||
if (this.menus.contains("expired_gui")) {
|
||||
this.plugin.getLogger().warning("We cannot do shit.");
|
||||
|
||||
if (guiItem != null) {
|
||||
final ItemStack itemStack = guiItem.getItemStack();
|
||||
|
||||
if (itemStack.getPersistentDataContainer().has(Keys.auction_expired.getNamespacedKey())) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.menus.clear();
|
||||
|
||||
this.gui.clearPageContents();
|
||||
this.gui.clearPageItems();
|
||||
|
||||
@ -82,15 +79,7 @@ public class AuctionMenu extends DynamicInventoryBuilder {
|
||||
this.gui.addItem(itemBuilder.asGuiItem());
|
||||
});
|
||||
|
||||
if (guiItem != null) {
|
||||
NbtBuilder nbtBuilder = new NbtBuilder().setItemStack(guiItem.getItemStack());
|
||||
|
||||
nbtBuilder.setPersistentString(Keys.auction_expired.getNamespacedKey(), "1");
|
||||
|
||||
guiItem.setItemStack(nbtBuilder.getItemStack());
|
||||
|
||||
this.gui.setItem(event.getSlot(), guiItem);
|
||||
}
|
||||
this.menus.add("expired_gui");
|
||||
|
||||
this.gui.setTitle("<green>Expired Items");
|
||||
this.gui.updateTitle(this.player);
|
||||
@ -101,7 +90,13 @@ public class AuctionMenu extends DynamicInventoryBuilder {
|
||||
setSellingItem();
|
||||
|
||||
this.auctions.getProperty(AuctionKeys.sold_item_button).setItem(event -> {
|
||||
//todo() open sold gui
|
||||
if (this.menus.contains("sold_gui")) {
|
||||
this.plugin.getLogger().warning("We cannot do shit.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.menus.clear();
|
||||
}, this.gui);
|
||||
|
||||
this.gui.open(this.player);
|
||||
|
Loading…
Reference in New Issue
Block a user