diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4788b4b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,113 @@
+# User-specific stuff
+.idea/
+
+*.iml
+*.ipr
+*.iws
+
+# IntelliJ
+out/
+
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+*~
+
+# temporary files which can be created if a process still has a handle open of a deleted file
+.fuse_hidden*
+
+# KDE directory preferences
+.directory
+
+# Linux trash folder which might appear on any partition or disk
+.Trash-*
+
+# .nfs files are created when an open file is removed but is still being accessed
+.nfs*
+
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# Windows thumbnail cache files
+Thumbs.db
+Thumbs.db:encryptable
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+target/
+
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
+.flattened-pom.xml
+
+# Common working directory
+run/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..5180a47
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,94 @@
+
+
+ 4.0.0
+
+ me.latestion
+ LatestCrates
+ 1.0-SNAPSHOT
+ jar
+
+ LatestCrates
+
+
+ 1.8
+ UTF-8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+
+ ${java.version}
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.4
+
+
+ package
+
+ shade
+
+
+ false
+
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ spigotmc-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ sonatype
+ https://oss.sonatype.org/content/groups/public/
+
+
+ codemc-repo
+ https://repo.codemc.io/repository/maven-public/
+
+
+ essentials
+ https://repo.essentialsx.net/snapshots/
+
+
+
+
+
+ org.spigotmc
+ spigot
+ 1.16.5-R0.1-SNAPSHOT
+ provided
+
+
+ com.gmail.filoghost.holographicdisplays
+ holographicdisplays-api
+ 2.4.6
+ provided
+
+
+ net.essentialsx
+ EssentialsX
+ 2.19.0-SNAPSHOT
+ provided
+
+
+
diff --git a/src/main/java/me/latestion/latestcrates/LatestCrates.java b/src/main/java/me/latestion/latestcrates/LatestCrates.java
new file mode 100644
index 0000000..edc87b3
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/LatestCrates.java
@@ -0,0 +1,196 @@
+package me.latestion.latestcrates;
+
+import com.earth2me.essentials.api.Economy;
+import com.gmail.filoghost.holographicdisplays.api.Hologram;
+import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
+import me.latestion.latestcrates.commands.Executor;
+import me.latestion.latestcrates.events.*;
+import me.latestion.latestcrates.files.CrateLootManager;
+import me.latestion.latestcrates.files.DataManager;
+import me.latestion.latestcrates.gui.AllCrates;
+import me.latestion.latestcrates.gui.CrateGUI;
+import me.latestion.latestcrates.gui.CrateRename;
+import me.latestion.latestcrates.gui.ShulkInv;
+import me.latestion.latestcrates.gui.events.AsyncChat;
+import me.latestion.latestcrates.utils.*;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.RegisteredServiceProvider;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.*;
+
+public final class LatestCrates extends JavaPlugin {
+
+ public Economy eco;
+ public DataManager data;
+ public CrateLootManager loot;
+ public Util util;
+
+ public static LatestCrates instance;
+
+ public Map crateInstance = new HashMap<>();
+ public Map lootInstance = new HashMap<>();
+
+ public Map idInstance = new HashMap<>();
+ public Map newCrates = new HashMap<>(); // NEW CRATES DONE EVERYTHING BY CLASS
+ public Map shulkerInv = new HashMap<>();
+
+ public Map inCrate = new HashMap<>();
+ public List isCreating = new ArrayList<>();
+ public List isBeingCreated = new ArrayList<>();
+ public List inProcess = new ArrayList<>();
+ public List cache = new ArrayList<>();
+
+ public Map holoInstance = new HashMap<>();
+ public Map asInstance = new HashMap<>();
+ public List mani = new ArrayList<>();
+ public Map refillInv = new HashMap<>();
+
+ public AllCrates gui;
+
+ public List cache2 = new ArrayList<>();
+
+ public Map cGUI = new HashMap<>();
+ public Map sInv = new HashMap<>();
+ public Map cRename = new HashMap<>();
+
+
+ @Override
+ public void onEnable() {
+ instance = this;
+ if (!setupEconomy()) {
+ getServer().getPluginManager().disablePlugin(this);
+ return;
+ }
+ loadFiles();
+ loadCrates();
+ loadEvents();
+ holo();
+ loadHolos();
+ spawnAs();
+ }
+
+ @Override
+ public void onDisable() {
+ removeHolos();
+ removeAs();
+ for (Crate c : crateInstance.values()) {
+ c.setCrateItems(c.getCrateItems);
+ }
+ setLoot();
+ }
+
+ private void loadCrates() {
+ try {
+ data.getConfig().getConfigurationSection("crates").getKeys(false).forEach(key -> {
+ crateInstance.put(key, new Crate(this, key));
+ });
+ } catch (Exception e) {
+
+ }
+ }
+
+ private boolean setupEconomy() {
+ RegisteredServiceProvider economy = getServer().getServicesManager().getRegistration
+ (com.earth2me.essentials.api.Economy.class);
+ if (economy != null) {
+ eco = economy.getProvider();
+ }
+ return (eco == null);
+ }
+
+ public void holo() {
+ if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
+ getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
+ getLogger().severe("*** This plugin will be disabled. ***");
+ this.setEnabled(false);
+ return;
+ }
+ }
+
+ private void loadFiles() {
+ this.data = new DataManager(this);
+ this.loot = new CrateLootManager(this);
+ this.util = new Util(this);
+ Executor exe = new Executor(this);
+ this.getCommand("crate").setExecutor(exe);
+ this.getCommand("crateloot").setExecutor(exe);
+ this.getCommand("cratesgui").setExecutor(exe);
+ }
+
+ private void loadEvents() {
+ PluginManager manager = this.getServer().getPluginManager();
+ manager.registerEvents(new InventoryClick(this), this);
+ manager.registerEvents(new InventoryClose(this), this);
+ manager.registerEvents(new InventoryOpen(this), this);
+ manager.registerEvents(new PlayerJoin(this), this);
+ manager.registerEvents(new AsInteract(this), this);
+ manager.registerEvents(new AsyncChat(this), this);
+ manager.registerEvents(new me.latestion.latestcrates.gui.events.InventoryClick(this), this);
+ manager.registerEvents(new me.latestion.latestcrates.gui.events.InventoryClose(this), this);
+ }
+
+ public void loadHolos() {
+ try {
+ data.getConfig().getConfigurationSection("shulker").getKeys(false).forEach(key -> {
+ Location loc = util.stringToLoc(key);
+ String name = data.getConfig().getString("shulker." + key + ".crate-name");
+ Crate crate = crateInstance.get(name);
+ crate.createArmorStand(loc);
+ });
+ } catch (Exception e) {
+
+ }
+ }
+
+ public void removeHolos() {
+ for (Hologram gram : HologramsAPI.getHolograms(this)) {
+ gram.delete();
+ }
+ }
+
+ public void spawnAs() {
+ asInstance.clear();
+ try {
+ data.getConfig().getConfigurationSection("shulker").getKeys(false).forEach(key -> {
+ Location loc = util.stringToLoc(key);
+ ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
+ prepareArmorStand(as);
+ asInstance.put(loc, as);
+ });
+ } catch (Exception e) {
+ }
+ }
+
+ public void removeAs() {
+ for (ArmorStand as : asInstance.values()) {
+ as.remove();
+ }
+ asInstance.clear();
+ }
+
+ private void setLoot() {
+ for (CrateLoot l : lootInstance.values()) {
+ l.setCrateItems();
+ }
+ }
+
+ public void prepareArmorStand(ArmorStand as) {
+ as.setVisible(false);
+ as.setMarker(false);
+ as.setBasePlate(false);
+ as.setSmall(true);
+ as.setInvulnerable(true);
+ as.setAI(false);
+ as.setGravity(false);
+ as.setCollidable(false);
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/commands/Executor.java b/src/main/java/me/latestion/latestcrates/commands/Executor.java
new file mode 100644
index 0000000..cea48a0
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/commands/Executor.java
@@ -0,0 +1,290 @@
+package me.latestion.latestcrates.commands;
+
+import me.latestion.latestcrates.LatestCrates;
+import me.latestion.latestcrates.gui.AllCrates;
+import me.latestion.latestcrates.utils.Crate;
+import me.latestion.latestcrates.utils.CreateCrate;
+import me.latestion.latestcrates.utils.RefillInv;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.block.Block;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+
+public class Executor implements CommandExecutor {
+
+ private LatestCrates plugin;
+
+ public Executor(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+
+ if (sender instanceof Player) {
+ Player player = (Player) sender;
+
+ if (label.equalsIgnoreCase("crate")) {
+
+ if (args.length == 0) {
+ player.sendMessage(ChatColor.RED + "/crate create {cratename}" + ChatColor.WHITE + ": Creates the desierd crate!");
+ player.sendMessage(ChatColor.RED + "/crate set {cratename}" + ChatColor.WHITE + ": Set the shulker box to crate!");
+ player.sendMessage(ChatColor.RED + "/crate setprice {cratename}" + ChatColor.WHITE + ": Sets the price of crate!");
+ player.sendMessage(ChatColor.RED + "/crate refill {cratename}" + ChatColor.WHITE + ": Refills the crate!");
+ return false;
+ }
+
+ if (args[0].equalsIgnoreCase("create")) {
+ // Create a new crate
+ if (sender.hasPermission("crate.create")) {
+ if (args.length == 1) {
+ return false;
+ }
+ String name = stringBuilder(args, 1);
+
+ if (plugin.isBeingCreated.contains(name)) {
+ return false;
+ }
+
+ if (plugin.util.isCrate(name)) {
+ return false;
+ }
+
+ CreateCrate crate = new CreateCrate(plugin, name, player);
+ player.openInventory(crate.getInventory());
+ plugin.newCrates.put(player, crate);
+ plugin.isCreating.add(player);
+ plugin.isBeingCreated.add(name);
+
+ }
+ }
+
+ if (args[0].equalsIgnoreCase("set")) {
+ // Set it to shulker box here
+ if (player.hasPermission("crate.set")) {
+ Block block = player.getTargetBlockExact(5);
+ if (block == null) {
+ return false;
+ }
+ if (args.length == 1) {
+ return false;
+ }
+ if (!plugin.util.isShulkerBox(block.getType())) return false;
+ String name = stringBuilder(args, 1);
+
+ if (!plugin.util.isCrate(name)) {
+ return false;
+ }
+
+ plugin.data.getConfig().set("shulker." + plugin.util.locToString(block.getLocation().clone()) + ".crate-name", name);
+ plugin.data.saveConfig();
+ Crate crate = plugin.crateInstance.get(name);
+ crate.createArmorStand(block.getLocation());
+
+ Location loc = block.getLocation();
+ ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
+ plugin.prepareArmorStand(as);
+ plugin.asInstance.put(loc, as);
+ }
+ }
+
+ if (args[0].equalsIgnoreCase("setprice")) {
+ // Set the price of crate with the crate name and eco plugin will be used
+ if (player.hasPermission("crate.setprice")) {
+ if (args.length < 2) {
+ return false;
+ }
+ String name = stringBuilder(args, 1, args.length - 1);
+
+ if (!plugin.util.isCrate(name)) {
+ return false;
+ }
+
+ if (!plugin.util.isNum(args[args.length - 1])) {
+ return false;
+ }
+
+ Crate crate = plugin.crateInstance.get(name);
+ crate.setPrice(plugin.util.parseInt(args[args.length - 1]));
+ sender.sendMessage(ChatColor.GOLD + name + " price set to " + plugin.util.parseInt(args[args.length - 1]));
+ }
+ }
+
+ if (args[0].equalsIgnoreCase("give")) {
+ if (sender.hasPermission("crate.give")) {
+ if (args.length == 1 || args.length == 2) {
+ return false;
+ }
+ try {
+ Player target = Bukkit.getPlayer(plugin.idInstance.get(args[1]));
+ String name = stringBuilder(args, 2, args.length - 1);
+ int i = plugin.util.parseInt(args[args.length - 1]);
+ if (target.isOnline()) target.sendMessage(ChatColor.GOLD + "You recieved " + i + " " + name + "keys.");
+ int current = plugin.data.getConfig().getInt("data." + target.getUniqueId().toString() + "." + name);
+ plugin.data.getConfig().set("data." + target.getUniqueId().toString() + "." + name, (current + i));
+ plugin.data.saveConfig();
+ } catch (Exception e) {
+ return false;
+ }
+ }
+ }
+
+ if (args[0].equalsIgnoreCase("refill")) {
+
+ if (player.hasPermission("crate.refill")) {
+ String name = stringBuilder(args, 1);
+
+ if (!plugin.util.isCrate(name)) {
+ return false;
+ }
+ RefillInv inv = new RefillInv(plugin, name, player);
+ player.openInventory(inv.getInventory());
+ plugin.refillInv.put(player, inv);
+ }
+ }
+
+ if (args[0].equalsIgnoreCase("remove")) {
+
+ if (player.hasPermission("crate.remove")) {
+ if (args.length == 1) {
+ return false;
+ }
+ // REMOVE LOCATION WITH THE CRATES TOO
+ // REMOVE THIS CRATE FROM ALL HASHMAPS
+ String name = stringBuilder(args, 1);
+ player.sendMessage(ChatColor.RED + name + " was removed!");
+
+ for (Location loc : plugin.crateInstance.get(name).getLocations()) {
+ plugin.data.getConfig().set("shulker." + plugin.util.locToString(loc), null);
+ plugin.data.saveConfig();
+ }
+ for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
+ plugin.data.getConfig().set("data." + p.getUniqueId().toString() + "." + name, null);
+ plugin.data.saveConfig();
+ }
+
+ plugin.removeHolos();
+ plugin.removeAs();
+
+ plugin.loadHolos();
+ plugin.spawnAs();
+
+ plugin.data.getConfig().set("crates." + name, null);
+ plugin.data.saveConfig();
+ plugin.crateInstance.remove(name);
+ }
+ }
+
+ if (args[0].equalsIgnoreCase("rename")) {
+
+ }
+
+ }
+ if (label.equalsIgnoreCase("crateloot")) {
+ player.openInventory(plugin.lootInstance.get(player.getUniqueId()).getInventory());
+ }
+ if (label.equalsIgnoreCase("cratesgui")) {
+ if (sender.hasPermission("crates.all")) {
+ plugin.gui = new AllCrates();
+ player.openInventory(plugin.gui.invs.get(0));
+ }
+ }
+ }
+ else {
+ if (args[0].equalsIgnoreCase("setprice")) {
+ // Set the price of crate with the crate name and eco plugin will be used
+ if (sender.hasPermission("crate.setprice")) {
+ if (args.length < 2) {
+ return false;
+ }
+ String name = stringBuilder(args, 1, args.length - 1);
+
+ if (!plugin.util.isCrate(name)) {
+ return false;
+ }
+
+ if (!plugin.util.isNum(args[args.length - 1])) {
+ return false;
+ }
+
+ Crate crate = plugin.crateInstance.get(name);
+ crate.setPrice(plugin.util.parseInt(args[args.length - 1]));
+ }
+ }
+ if (args[0].equalsIgnoreCase("give")) {
+ if (sender.hasPermission("crate.give")) {
+ if (args.length == 1 || args.length == 2) {
+ return false;
+ }
+ try {
+ Player target = Bukkit.getPlayer(plugin.idInstance.get(args[1]));
+ String name = stringBuilder(args, 2, args.length - 1);
+ int i = plugin.util.parseInt(args[args.length - 1]);
+ int current = plugin.data.getConfig().getInt("data." + target.getUniqueId().toString() + "." + name);
+ plugin.data.getConfig().set("data." + target.getUniqueId().toString() + "." + name, (current + i));
+ plugin.data.saveConfig();
+ } catch (Exception e) {
+ return false;
+ }
+
+ }
+ }
+ if (args[0].equalsIgnoreCase("remove")) {
+
+ if (sender.hasPermission("crate.remove")) {
+ if (args.length == 1) {
+ return false;
+ }
+ // REMOVE LOCATION WITH THE CRATES TOO
+ // REMOVE THIS CRATE FROM ALL HASHMAPS
+ String name = stringBuilder(args, 1);
+ sender.sendMessage(ChatColor.RED + name + " was removed!");
+
+ for (Location loc : plugin.crateInstance.get(name).getLocations()) {
+ plugin.data.getConfig().set("shulker." + plugin.util.locToString(loc), null);
+ plugin.data.saveConfig();
+ }
+
+ for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
+ plugin.data.getConfig().set("data." + p.getUniqueId().toString() + "." + name, null);
+ plugin.data.saveConfig();
+ }
+
+ plugin.removeHolos();
+ plugin.removeAs();
+
+ plugin.loadHolos();
+ plugin.spawnAs();
+
+ plugin.data.getConfig().set("crates." + name, null);
+ plugin.data.saveConfig();
+ plugin.crateInstance.remove(name);
+ }
+ }
+ }
+ return false;
+ }
+
+ public String stringBuilder(String[] args, int start) {
+ StringBuffer sb = new StringBuffer();
+ for(int i = start; i < args.length; i++) {
+ sb.append(args[i] + " ");
+ }
+ return ChatColor.stripColor(sb.toString());
+ }
+
+ public String stringBuilder(String[] args, int start, int end) {
+ StringBuffer sb = new StringBuffer();
+ for(int i = start; i < end; i++) {
+ sb.append(args[i] + " ");
+ }
+ return ChatColor.stripColor(sb.toString());
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/events/AsInteract.java b/src/main/java/me/latestion/latestcrates/events/AsInteract.java
new file mode 100644
index 0000000..e7f401f
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/events/AsInteract.java
@@ -0,0 +1,23 @@
+package me.latestion.latestcrates.events;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
+
+public class AsInteract implements Listener {
+
+ private LatestCrates plugin;
+
+ public AsInteract(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void asInteract(PlayerArmorStandManipulateEvent event) {
+ if (plugin.mani.contains(event.getRightClicked())) {
+ event.setCancelled(true);
+ }
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/events/InventoryClick.java b/src/main/java/me/latestion/latestcrates/events/InventoryClick.java
new file mode 100644
index 0000000..501f8d9
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/events/InventoryClick.java
@@ -0,0 +1,242 @@
+package me.latestion.latestcrates.events;
+
+import com.earth2me.essentials.api.Economy;
+import com.earth2me.essentials.api.NoLoanPermittedException;
+import com.earth2me.essentials.api.UserDoesNotExistException;
+import me.latestion.latestcrates.LatestCrates;
+import me.latestion.latestcrates.utils.Crate;
+import me.latestion.latestcrates.utils.CrateLoot;
+import me.latestion.latestcrates.utils.CreateCrate;
+import me.latestion.latestcrates.utils.RefillInv;
+import org.bukkit.ChatColor;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryDragEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.PlayerInventory;
+
+import java.math.BigDecimal;
+
+public class InventoryClick implements Listener {
+
+ private LatestCrates plugin;
+
+ public InventoryClick(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void invClick(InventoryClickEvent event) {
+ Player player = (Player) event.getWhoClicked();
+ if (plugin.isCreating.contains(event.getWhoClicked())) {
+ CreateCrate crate = plugin.newCrates.get(player);
+ if (event.getClickedInventory() instanceof PlayerInventory) {
+ return;
+ }
+ if (event.getSlot() < 9 || event.getSlot() > 44) {
+ event.setCancelled(true);
+ }
+ if (event.getSlot() == 49) {
+ plugin.isCreating.remove(player);
+ plugin.isBeingCreated.remove(event.getView().getTitle());
+ plugin.newCrates.remove(player);
+ player.closeInventory();
+ }
+ if (event.getSlot() == 48) {
+ if (event.getInventory().equals(crate.getInventory())) {
+ event.setCancelled(true);
+ return;
+ }
+ /// Open the inventory index - 1
+ plugin.cache.add(player);
+ player.openInventory(crate.invs.get(crate.invs.indexOf(event.getInventory()) - 1));
+ }
+ if (event.getSlot() == 50) {
+ if (crate.isInventoryFull(event.getInventory())) {
+ plugin.cache.add(player);
+ player.openInventory(crate.createNewInv());
+ }
+ }
+ if (event.getSlot() == 4) {
+ player.closeInventory();
+ crate.createCrate();
+ plugin.isCreating.remove(player);
+ plugin.isBeingCreated.remove(event.getView().getTitle());
+ plugin.newCrates.remove(player);
+ }
+ return;
+ }
+ if (plugin.shulkerInv.containsValue(event.getInventory())) {
+ String name = event.getView().getTitle();
+ if (event.getClickedInventory() instanceof PlayerInventory) {
+ event.setCancelled(true);
+ return;
+ }
+ if (event.getCurrentItem() == null) {
+ return;
+ }
+ event.setCancelled(true);
+ Block block = player.getLocation().getWorld().getBlockAt(plugin.inCrate.get(player));
+ if (event.getSlot() == 15) {
+ try {
+ BigDecimal i = Economy.getMoneyExact(event.getWhoClicked().getUniqueId());
+ int price = plugin.util.getCratePrice(name);
+ if (i.doubleValue() > price) {
+ Economy.subtract(event.getWhoClicked().getUniqueId(), new BigDecimal(price));
+ player.closeInventory();
+ Crate crate = plugin.crateInstance.get(name);
+ crate.purchase(block, player);
+ // RUN THE MECHANICS FOR PARTICLES AND THE ROTATING ITEM AND THE CHANGE THE NAME OF THE ARMOR STAND ABOVE IT
+ }
+ else {
+ event.getWhoClicked().closeInventory();
+ event.getWhoClicked().sendMessage(ChatColor.RED + "Not enough funds!");
+ }
+ } catch (UserDoesNotExistException e) {
+ } catch (NoLoanPermittedException e) {
+ } catch (ArithmeticException e) {
+ }
+ event.getWhoClicked().closeInventory();
+ }
+ if (event.getSlot() == 11) {
+ Crate crate = plugin.crateInstance.get(name);
+ int currentCrates = crate.getPlayerCrate(player);
+ if (currentCrates == 0) {
+ event.getWhoClicked().sendMessage(ChatColor.RED + "Not enought crates!");
+ event.getWhoClicked().closeInventory();
+ return;
+ }
+ currentCrates--;
+ crate.setPlayerCrate(player, currentCrates);
+ event.getWhoClicked().closeInventory();
+ crate.purchase(block, player);
+ }
+ }
+ if (plugin.refillInv.containsKey(player))
+ if (plugin.refillInv.get(player).invs.contains(event.getInventory())) {
+ RefillInv crate = plugin.refillInv.get(player);
+ if (event.getClickedInventory() instanceof PlayerInventory) {
+ return;
+ }
+ if (event.getSlot() < 9 || event.getSlot() > 44) {
+ event.setCancelled(true);
+ }
+ if (event.getSlot() == 49) {
+ plugin.refillInv.remove(player);
+ player.closeInventory();
+ }
+ if (event.getSlot() == 48) {
+ if (event.getInventory().equals(crate.getInventory())) {
+ event.setCancelled(true);
+ return;
+ }
+ /// Open the inventory index - 1
+ plugin.cache.add(player);
+ player.openInventory(crate.invs.get(crate.invs.indexOf(event.getInventory()) - 1));
+ }
+ if (event.getSlot() == 50) {
+ if (crate.isInventoryFull(event.getInventory())) {
+ plugin.cache.add(player);
+ int index = crate.invs.indexOf(event.getInventory());
+ int size = crate.invs.size() - 1;
+ if (size > index) {
+ player.openInventory(crate.invs.get(index + 1));
+ }
+ else player.openInventory(crate.createNewInv());
+ }
+ }
+ if (event.getSlot() == 4) {
+ crate.createCrate();
+ plugin.refillInv.remove(player);
+ player.closeInventory();
+ }
+ return;
+ }
+ if (plugin.lootInstance.containsKey(event.getWhoClicked().getUniqueId()))
+ if (plugin.lootInstance.get(event.getWhoClicked().getUniqueId()).invs.contains(event.getInventory())) {
+ if (event.getClickedInventory().getType() == InventoryType.PLAYER) {
+ event.setCancelled(true);
+ return;
+ }
+
+ if (!event.getView().getTitle().contains(ChatColor.GOLD + "Crate Loot")) return;
+ if (event.getCurrentItem() == null) return;
+
+ event.setCancelled(true);
+
+ CrateLoot loot = plugin.lootInstance.get(player.getUniqueId());
+
+ if (event.getSlot() == 49) {
+ player.closeInventory();
+ return;
+ }
+
+ if (event.getSlot() == 48) {
+ if (event.getClickedInventory().equals(loot.getInventory())) {
+ event.setCancelled(true);
+ return;
+ }
+ player.openInventory(loot.invs.get(loot.invs.indexOf(event.getInventory()) - 1));
+ return;
+ }
+
+ if (event.getSlot() == 50) {
+ int index = loot.invs.indexOf(event.getInventory());
+ int size = loot.invs.size() - 1;
+ if (size > index) {
+ player.openInventory(loot.invs.get(index + 1));
+ }
+ return;
+ }
+
+ if (event.getSlot() == 47) {
+ if (plugin.util.isInventoryFull(player)) {
+ player.sendMessage(ChatColor.RED + "Your Inventory Is Full!");
+ return;
+ }
+ player.closeInventory();
+ for (int i = 0; i < loot.allItems.size() * 100; i++) {
+ if (loot.allItems.isEmpty()) break;
+ ItemStack item = loot.allItems.remove(0);
+ player.getInventory().addItem(item);
+ player.updateInventory();
+ if (plugin.util.isInventoryFull(player)) {
+ player.sendMessage(ChatColor.RED + "Your Inventory Is Full!");
+ break;
+ }
+ }
+ loot.createInv();
+ }
+
+ if (event.getSlot() < 45) {
+ if (plugin.util.isInventoryFull(player)) {
+ player.sendMessage(ChatColor.RED + "Your Inventory Is Full!");
+ return;
+ }
+ ItemStack item = event.getCurrentItem();
+ loot.allItems.remove(item);
+ player.closeInventory();
+ loot.createInv();
+ player.sendMessage(ChatColor.GOLD + "Added " + format(item.getItemMeta().getDisplayName()) + " to your inventory!");
+ player.getInventory().addItem(item);
+ player.updateInventory();
+ return;
+ }
+ }
+ }
+
+ @EventHandler
+ public void drag(InventoryDragEvent event) {
+ if (plugin.lootInstance.get(event.getWhoClicked().getUniqueId()).invs.contains(event.getInventory())) {
+ event.setCancelled(true);
+ }
+ }
+
+ private String format(String s) {
+ return ChatColor.translateAlternateColorCodes('&', s);
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/events/InventoryClose.java b/src/main/java/me/latestion/latestcrates/events/InventoryClose.java
new file mode 100644
index 0000000..3b462cf
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/events/InventoryClose.java
@@ -0,0 +1,48 @@
+package me.latestion.latestcrates.events;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryCloseEvent;
+
+public class InventoryClose implements Listener {
+
+ private LatestCrates plugin;
+
+ public InventoryClose(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void invClose(InventoryCloseEvent event) {
+ Player player = (Player) event.getPlayer();
+ if (plugin.isCreating.contains(event.getPlayer())) {
+ if (plugin.cache.contains(event.getPlayer())) {
+ plugin.cache.remove(event.getPlayer());
+ return;
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ event.getPlayer().openInventory(event.getInventory());
+ }
+ }, 10);
+ }
+ if (plugin.shulkerInv.containsValue(event.getInventory())) {
+ plugin.inCrate.remove(event.getPlayer());
+ }
+ if (plugin.refillInv.containsKey(player))
+ if (plugin.refillInv.get(player).invs.contains(event.getInventory())) {
+ if (plugin.cache.contains(event.getPlayer())) {
+ plugin.cache.remove(event.getPlayer());
+ return;
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ event.getPlayer().openInventory(event.getInventory());
+ }
+ }, 10);
+ }
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/events/InventoryOpen.java b/src/main/java/me/latestion/latestcrates/events/InventoryOpen.java
new file mode 100644
index 0000000..e2d6f7b
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/events/InventoryOpen.java
@@ -0,0 +1,61 @@
+package me.latestion.latestcrates.events;
+
+import me.latestion.latestcrates.LatestCrates;
+import me.latestion.latestcrates.utils.Crate;
+import me.latestion.latestcrates.utils.CrateInv;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.Inventory;
+
+import java.util.UUID;
+
+public class InventoryOpen implements Listener {
+
+ private LatestCrates plugin;
+
+ public InventoryOpen(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void invOpen(PlayerInteractEvent event) {
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+ if (event.getClickedBlock() == null) {
+ return;
+ }
+ Block block = event.getClickedBlock();
+ Location loc = event.getClickedBlock().getLocation();
+ if (plugin.util.isShulkerBox(event.getClickedBlock().getType())) {
+ if (plugin.util.isLocationTaken(loc)) {
+ event.setCancelled(true);
+ // REAL CRATE
+ Player player = event.getPlayer();
+
+ if (plugin.inProcess.contains(block)) {
+ return;
+ }
+
+ String name = plugin.data.getConfig().getString("shulker." + plugin.util.locToString(loc) + ".crate-name");
+ Crate crate = plugin.crateInstance.get(name);
+ if (crate.getCrateItems.isEmpty()) {
+ player.sendMessage(ChatColor.RED + "Crate is empty!");
+ return;
+ }
+
+ UUID id = event.getPlayer().getUniqueId();
+ CrateInv inv = new CrateInv(plugin, id, name);
+ Inventory invv = inv.getInventory();
+ event.getPlayer().openInventory(invv);
+ plugin.shulkerInv.put(id, invv);
+ plugin.inCrate.put(event.getPlayer(), event.getClickedBlock().getLocation());
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/events/PlayerJoin.java b/src/main/java/me/latestion/latestcrates/events/PlayerJoin.java
new file mode 100644
index 0000000..49f999f
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/events/PlayerJoin.java
@@ -0,0 +1,23 @@
+package me.latestion.latestcrates.events;
+
+import me.latestion.latestcrates.LatestCrates;
+import me.latestion.latestcrates.utils.CrateLoot;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+
+public class PlayerJoin implements Listener {
+
+ private LatestCrates plugin;
+ public PlayerJoin(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void pJoin(PlayerJoinEvent event) {
+ plugin.idInstance.put(event.getPlayer().getName(), event.getPlayer().getUniqueId());
+ if (!plugin.lootInstance.containsKey(event.getPlayer().getUniqueId()))
+ plugin.lootInstance.put(event.getPlayer().getUniqueId(), new CrateLoot(plugin, event.getPlayer().getUniqueId()));
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/files/CrateLootManager.java b/src/main/java/me/latestion/latestcrates/files/CrateLootManager.java
new file mode 100644
index 0000000..4517dd6
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/files/CrateLootManager.java
@@ -0,0 +1,66 @@
+package me.latestion.latestcrates.files;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Level;
+
+public class CrateLootManager {
+ private LatestCrates plugin;
+ private FileConfiguration dataConfig = null;
+ private File configFile = null;
+
+ public CrateLootManager(LatestCrates plugin) {
+ this.plugin = plugin;
+ saveDefaultConfig();
+ }
+
+ public void reloadConfig() {
+ if (this.configFile == null)
+ this.configFile = new File(this.plugin.getDataFolder(), "loot.yml");
+
+ this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
+
+ InputStream defaultStream = this.plugin.getResource("loot.yml");
+ if (defaultStream != null) {
+ YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
+ this.dataConfig.setDefaults(defaultConfig);
+
+ }
+
+ }
+
+ public FileConfiguration getConfig() {
+
+ if (this.dataConfig == null)
+ reloadConfig();
+
+ return this.dataConfig;
+ }
+
+ public void saveConfig() {
+ if (this.dataConfig == null || this.configFile == null)
+ return;
+
+ try {
+ this.getConfig().save(this.configFile);
+ } catch (IOException e) {
+ plugin.getLogger().log(Level.SEVERE, "Could Not Save Config to" + this.configFile, e);
+
+ }
+ }
+
+ public void saveDefaultConfig() {
+ if (this.configFile == null)
+ this.configFile = new File(this.plugin.getDataFolder(), "loot.yml");
+
+ if (!this.configFile.exists()) {
+ this.plugin.saveResource("loot.yml", false);
+ }
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/files/DataManager.java b/src/main/java/me/latestion/latestcrates/files/DataManager.java
new file mode 100644
index 0000000..c2c1875
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/files/DataManager.java
@@ -0,0 +1,67 @@
+package me.latestion.latestcrates.files;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Level;
+
+public class DataManager {
+
+ private LatestCrates plugin;
+ private FileConfiguration dataConfig = null;
+ private File configFile = null;
+
+ public DataManager(LatestCrates plugin) {
+ this.plugin = plugin;
+ saveDefaultConfig();
+ }
+
+ public void reloadConfig() {
+ if (this.configFile == null)
+ this.configFile = new File(this.plugin.getDataFolder(), "data.yml");
+
+ this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
+
+ InputStream defaultStream = this.plugin.getResource("data.yml");
+ if (defaultStream != null) {
+ YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
+ this.dataConfig.setDefaults(defaultConfig);
+
+ }
+
+ }
+
+ public FileConfiguration getConfig() {
+
+ if (this.dataConfig == null)
+ reloadConfig();
+
+ return this.dataConfig;
+ }
+
+ public void saveConfig() {
+ if (this.dataConfig == null || this.configFile == null)
+ return;
+
+ try {
+ this.getConfig().save(this.configFile);
+ } catch (IOException e) {
+ plugin.getLogger().log(Level.SEVERE, "Could Not Save Config to" + this.configFile, e);
+
+ }
+ }
+
+ public void saveDefaultConfig() {
+ if (this.configFile == null)
+ this.configFile = new File(this.plugin.getDataFolder(), "data.yml");
+
+ if (!this.configFile.exists()) {
+ this.plugin.saveResource("data.yml", false);
+ }
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/gui/AllCrates.java b/src/main/java/me/latestion/latestcrates/gui/AllCrates.java
new file mode 100644
index 0000000..45c7a2f
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/gui/AllCrates.java
@@ -0,0 +1,93 @@
+package me.latestion.latestcrates.gui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import me.latestion.latestcrates.utils.CrateAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class AllCrates {
+
+ public List invs = new ArrayList<>();
+
+ public AllCrates() {
+ crateGUI();
+ }
+
+ public Inventory getInventory() {
+ return invs.get(0);
+ }
+
+ private void crateGUI() {
+ Inventory inv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Crates");
+ setClose(inv);
+ setArrow(inv);
+ int i = 0;
+ for (String s : CrateAPI.getAllCrates()) {
+ inv.setItem(i, createItem(s));
+ i++;
+ if (i == 45) {
+ Inventory set;
+ set = inv;
+ invs.add(set);
+ inv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Crates");
+ setClose(inv);
+ setArrow(inv);
+ i = 0;
+ }
+ }
+ if (!invs.contains(inv)) invs.add(inv);
+ }
+
+
+ private ItemStack createItem(String s) {
+ ItemStack item = new ItemStack(Material.CHEST);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(format(s));
+ List lore = new ArrayList<>();
+ lore.add(ChatColor.RED + "Is empty: " + CrateAPI.isCrateEmpty(s));
+ meta.setLore(lore);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private String format(String s) {
+ return ChatColor.translateAlternateColorCodes('&', s);
+ }
+
+ private void setClose(Inventory inv) {
+ ItemStack item = new ItemStack(Material.BARRIER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Close");
+ item.setItemMeta(meta);
+ inv.setItem(49, item);
+ }
+
+ private void setArrow(Inventory inv) {
+ ItemStack item = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Previous Page");
+ item.setItemMeta(meta);
+ inv.setItem(48, item);
+
+ ItemStack item2 = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta2 = item2.getItemMeta();
+ meta2.setDisplayName(ChatColor.GREEN + "Next Page");
+ item2.setItemMeta(meta2);
+ inv.setItem(50, item2);
+ }
+
+ public ItemStack createCrateItem() {
+ ItemStack item = new ItemStack(Material.CHEST_MINECART);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GREEN + "Create New Crate");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/gui/CrateGUI.java b/src/main/java/me/latestion/latestcrates/gui/CrateGUI.java
new file mode 100644
index 0000000..02ad8d6
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/gui/CrateGUI.java
@@ -0,0 +1,69 @@
+package me.latestion.latestcrates.gui;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class CrateGUI {
+
+ public Inventory inv;
+
+ public String name;
+
+ public CrateGUI(String name) {
+ this.name = name;
+ createInv();
+ }
+
+ private void createInv() {
+ inv = Bukkit.createInventory(null, 9, ChatColor.GOLD + name);
+ inv.setItem(0, shulk());
+ inv.setItem(2, rename());
+ inv.setItem(4, close());
+ inv.setItem(6, reffil());
+ inv.setItem(8, remove());
+ }
+
+ private ItemStack shulk() {
+ ItemStack item = new ItemStack(Material.SHULKER_SHELL);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GOLD + "See Crates");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private ItemStack rename() {
+ ItemStack item = new ItemStack(Material.PAPER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GOLD + "Rename Crate");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private ItemStack reffil() {
+ ItemStack item = new ItemStack(Material.HOPPER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GOLD + "Refill Crate");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private ItemStack close() {
+ ItemStack item = new ItemStack(Material.BARRIER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Close");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private ItemStack remove() {
+ ItemStack item = new ItemStack(Material.LAVA_BUCKET);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GOLD + "Remove Crate");
+ item.setItemMeta(meta);
+ return item;
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/gui/CrateRename.java b/src/main/java/me/latestion/latestcrates/gui/CrateRename.java
new file mode 100644
index 0000000..7d5094f
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/gui/CrateRename.java
@@ -0,0 +1,20 @@
+package me.latestion.latestcrates.gui;
+
+import me.latestion.latestcrates.utils.CrateAPI;
+import org.bukkit.entity.Player;
+
+public class CrateRename {
+
+ public Player player;
+ public String name;
+
+ public CrateRename(Player player, String name) {
+ this.player = player;
+ this.name = name;
+ }
+
+ public void rename(String newName) {
+ CrateAPI.renameCrate(name, newName);
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/gui/ShulkInv.java b/src/main/java/me/latestion/latestcrates/gui/ShulkInv.java
new file mode 100644
index 0000000..df28c92
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/gui/ShulkInv.java
@@ -0,0 +1,82 @@
+package me.latestion.latestcrates.gui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import me.latestion.latestcrates.utils.CrateAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class ShulkInv {
+
+ public List invs = new ArrayList<>();;
+ public String name;
+
+ public ShulkInv(String name) {
+ this.name = name;
+ crateShulk();
+ }
+
+ private void crateShulk() {
+ Inventory inv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Shulks");
+ setClose(inv);
+ setArrow(inv);
+ int i = 0;
+ for (String s : CrateAPI.getCrateShulkers(name)) {
+ inv.setItem(i, createItem(s));
+ i++;
+ if (i == 45) {
+ Inventory set;
+ set = inv;
+ invs.add(set);
+ inv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Crates");
+ setClose(inv);
+ setArrow(inv);
+ }
+ }
+ if (!invs.contains(inv)) invs.add(inv);
+ }
+
+ private ItemStack createItem(String s) {
+ ItemStack item = new ItemStack(Material.SHULKER_BOX);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.AQUA + name + " Crate!");
+ List lore = new ArrayList<>();
+ lore.add(ChatColor.GOLD + "Click to teleport at crate!");
+ lore.add(s);
+ meta.setLore(lore);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private void setClose(Inventory inv) {
+ ItemStack item = new ItemStack(Material.BARRIER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Close");
+ item.setItemMeta(meta);
+ inv.setItem(49, item);
+ }
+
+ private void setArrow(Inventory inv) {
+ ItemStack item = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Previous Page");
+ item.setItemMeta(meta);
+ inv.setItem(48, item);
+
+ ItemStack item2 = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta2 = item2.getItemMeta();
+ meta2.setDisplayName(ChatColor.GREEN + "Next Page");
+ item2.setItemMeta(meta2);
+ inv.setItem(50, item2);
+ }
+
+ public Inventory getInventory() {
+ return invs.get(0);
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/gui/events/AsyncChat.java b/src/main/java/me/latestion/latestcrates/gui/events/AsyncChat.java
new file mode 100644
index 0000000..a2c7071
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/gui/events/AsyncChat.java
@@ -0,0 +1,30 @@
+package me.latestion.latestcrates.gui.events;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+
+public class AsyncChat implements Listener {
+
+ private LatestCrates plugin;
+
+ public AsyncChat(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void chat(AsyncPlayerChatEvent event) {
+ if (plugin.cRename.containsKey(event.getPlayer())) {
+ event.setCancelled(true);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ plugin.cRename.get(event.getPlayer()).rename(event.getMessage());
+ plugin.cRename.remove(event.getPlayer());
+ }
+ }, 1L);
+ }
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/gui/events/InventoryClick.java b/src/main/java/me/latestion/latestcrates/gui/events/InventoryClick.java
new file mode 100644
index 0000000..86a4555
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/gui/events/InventoryClick.java
@@ -0,0 +1,167 @@
+package me.latestion.latestcrates.gui.events;
+
+import me.latestion.latestcrates.LatestCrates;
+import me.latestion.latestcrates.gui.CrateGUI;
+import me.latestion.latestcrates.gui.CrateRename;
+import me.latestion.latestcrates.gui.ShulkInv;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.ItemStack;
+
+public class InventoryClick implements Listener {
+
+ private LatestCrates plugin;
+
+ public InventoryClick(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onClick(InventoryClickEvent event) {
+ Player player = (Player) event.getWhoClicked();
+ if (plugin.gui.invs.contains(event.getClickedInventory())) {
+ if (event.getClickedInventory().getType() == InventoryType.PLAYER) {
+ event.setCancelled(true);
+ return;
+ }
+ if (event.getCurrentItem() == null) return;
+
+ if (event.getSlot() == 49) {
+ player.closeInventory();
+ return;
+ }
+
+ if (event.getSlot() == 48) {
+ if (event.getClickedInventory().equals(plugin.gui.getInventory())) {
+ event.setCancelled(true);
+ return;
+ }
+ player.openInventory(plugin.gui.invs.get(plugin.gui.invs.indexOf(event.getInventory()) - 1));
+ return;
+ }
+
+ if (event.getSlot() == 50) {
+ int index = plugin.gui.invs.indexOf(event.getInventory());
+ int size = plugin.gui.invs.size() - 1;
+ if (size > index) {
+ player.openInventory(plugin.gui.invs.get(index + 1));
+ }
+ return;
+ }
+
+ if (event.getSlot() < 45) {
+ String name = event.getCurrentItem().getItemMeta().getDisplayName();
+ CrateGUI gui = new CrateGUI(name);
+ player.openInventory(gui.inv);
+ plugin.cGUI.put(player, gui);
+ }
+ }
+ if (plugin.cGUI.containsKey(player)) {
+ if (plugin.cGUI.get(player).inv.equals(event.getClickedInventory())) {
+ String name = plugin.cGUI.get(player).name;
+ if (event.getClickedInventory().getType() == InventoryType.PLAYER) {
+ event.setCancelled(true);
+ return;
+ }
+ if (event.getCurrentItem() == null) return;
+
+ if (event.getSlot() == 0) {
+ plugin.cache2.add(player);
+ player.closeInventory();
+ ShulkInv inv = new ShulkInv(name);
+ player.openInventory(inv.invs.get(0));
+ plugin.sInv.put(player, inv);
+ }
+
+ if (event.getSlot() == 2) {
+ /*
+ * Rename
+ *
+ * A LOT OF NESTING AND TESTING
+ *
+ */
+ plugin.cache2.add(player);
+ player.closeInventory();
+ player.sendMessage("Enter the new name for the crate!");
+ CrateRename rname = new CrateRename(player, name);
+ plugin.cRename.put(player, rname);
+ }
+
+ if (event.getSlot() == 4) {
+ plugin.cache2.add(player);
+ player.closeInventory();
+ }
+
+ if (event.getSlot() == 6) {
+ player.performCommand("crate refill " + name);
+ plugin.cache2.add(player);
+ player.closeInventory();
+ }
+
+ if (event.getSlot() == 8) {
+ player.performCommand("crate remove " + name);
+ plugin.cache2.add(player);
+ player.closeInventory();
+ }
+ }
+ }
+ if (plugin.sInv.containsKey(player))
+ if (plugin.sInv.get(player).invs.contains(event.getClickedInventory())) {
+ if (event.getClickedInventory().getType() == InventoryType.PLAYER) {
+ event.setCancelled(true);
+ return;
+ }
+ if (event.getCurrentItem() == null) return;
+
+ if (event.getSlot() == 49) {
+ plugin.cache2.add(player);
+ player.closeInventory();
+ return;
+ }
+
+ ShulkInv sInv = plugin.sInv.get(player);
+
+ if (event.getSlot() == 48) {
+ if (event.getClickedInventory().equals(sInv.getInventory())) {
+ event.setCancelled(true);
+ return;
+ }
+ plugin.cache2.add(player);
+ player.openInventory(sInv.invs.get(sInv.invs.indexOf(event.getInventory()) - 1));
+ return;
+ }
+
+ if (event.getSlot() == 50) {
+ int index = sInv.invs.indexOf(event.getInventory());
+ int size = sInv.invs.size() - 1;
+ if (size > index) {
+ plugin.cache2.add(player);
+ player.openInventory(sInv.invs.get(index + 1));
+ }
+ return;
+ }
+
+ if (event.getSlot() < 45) {
+ ItemStack item = event.getCurrentItem();
+ Location loc = stringToLoc(item.getItemMeta().getLore().get(1));
+ plugin.cache2.add(player);
+ player.closeInventory();
+ player.teleport(loc);
+ }
+ }
+ }
+ public Location stringToLoc(String loc) {
+ String[] split = loc.split(",");
+ Location send = new Location(Bukkit.getWorld(split[0]), parseInt(split[1]), parseInt(split[2]), parseInt(split[3]));
+ return send;
+ }
+ public int parseInt(String i) {
+ return Integer.parseInt(i);
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/gui/events/InventoryClose.java b/src/main/java/me/latestion/latestcrates/gui/events/InventoryClose.java
new file mode 100644
index 0000000..86af864
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/gui/events/InventoryClose.java
@@ -0,0 +1,48 @@
+package me.latestion.latestcrates.gui.events;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryCloseEvent;
+
+public class InventoryClose implements Listener {
+
+ private final LatestCrates plugin;
+
+ public InventoryClose(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onClose(InventoryCloseEvent event) {
+ if (plugin.cGUI.containsKey(event.getPlayer())) {
+ if (plugin.cGUI.get(event.getPlayer()).inv.equals(event.getInventory())) {
+ if (!plugin.cache2.contains(event.getPlayer())) {
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ event.getPlayer().openInventory(event.getInventory());
+ }
+ }, 5);
+ return;
+ }
+ plugin.cache2.remove(event.getPlayer());
+ plugin.cGUI.remove(event.getPlayer());
+ }
+ }
+ if (plugin.sInv.containsKey(event.getPlayer())) {
+ if (plugin.sInv.get(event.getPlayer()).invs.contains(event.getInventory())) {
+ if (!plugin.cache2.contains(event.getPlayer())) {
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ event.getPlayer().openInventory(event.getInventory());
+ }
+ }, 5);
+ return;
+ }
+ plugin.cache2.remove(event.getPlayer());
+ plugin.sInv.remove(event.getPlayer());
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/utils/Crate.java b/src/main/java/me/latestion/latestcrates/utils/Crate.java
new file mode 100644
index 0000000..990b6f1
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/Crate.java
@@ -0,0 +1,270 @@
+package me.latestion.latestcrates.utils;
+
+import com.gmail.filoghost.holographicdisplays.api.Hologram;
+import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
+import me.latestion.latestcrates.LatestCrates;
+import net.minecraft.server.v1_16_R3.BlockPosition;
+import net.minecraft.server.v1_16_R3.TileEntityShulkerBox;
+import org.bukkit.*;
+import org.bukkit.block.Block;
+import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class Crate {
+
+ String name; // Crate name
+ private LatestCrates plugin;
+
+ public List getCrateItems = new ArrayList<>();
+
+ public Crate(LatestCrates plugin, String name) {
+ this.plugin = plugin;
+ this.name = name;
+ loadCrateItems();
+ }
+
+ public void loadCrateItems() {
+ getCrateItems.clear();
+ try {
+ plugin.data.getConfig().getConfigurationSection("crates." + name + ".items").getKeys(false).forEach(num -> {
+ // num is number
+ ItemStack add = plugin.data.getConfig().getItemStack("crates." + name + ".items." + num);
+ getCrateItems.add(add);
+ });
+ } catch (Exception e) {
+ }
+ }
+
+ public void setCrateItem(ItemStack item, int set) {
+ plugin.data.getConfig().set("crates." + name + ".items." + set, item);
+ plugin.data.saveConfig();
+ }
+
+ public void setCrateItems(List items) {
+ int i = 0;
+ try {
+ plugin.data.getConfig().set("crates." + name + ".items", null);
+ plugin.data.saveConfig();
+ } catch (Exception e) {
+ }
+ for (ItemStack item : items) {
+ plugin.data.getConfig().set("crates." + name + ".items." + i, item);
+ plugin.data.saveConfig();
+ i++;
+ }
+ }
+
+ public List getLocations() {
+ List send = new ArrayList();
+ try {
+ plugin.data.getConfig().getConfigurationSection("shulker").getKeys(false).forEach(loc -> {
+ if (plugin.data.getConfig().getString("shulker." + loc + ".crate-name").equalsIgnoreCase(name)) {
+ send.add(plugin.util.stringToLoc(loc));
+ }
+ });
+ } catch (Exception e) {
+ // e.printStackTrace();
+ }
+ return send;
+ }
+
+ public boolean isEmpty() {
+ return !plugin.data.getConfig().contains("crates." + name + ".items.0");
+ }
+
+ public int getPrice() {
+ return plugin.data.getConfig().getInt("crates." + name + ".price");
+ }
+
+ public void setPrice(int price) {
+ plugin.data.getConfig().set("crates." + name + ".price", price);
+ plugin.data.saveConfig();
+
+ // Change the HOLO Price of all shulkers here
+
+ }
+
+ public int getPlayerCrate(Player player) {
+ return plugin.data.getConfig().getInt("data." + player.getUniqueId().toString() + "." + name);
+ }
+
+ public void setPlayerCrate(Player player, int i) {
+ plugin.data.getConfig().set("data." + player.getUniqueId().toString() + "." + name, i);
+ plugin.data.saveConfig();
+ }
+
+ public void purchase(Block block, Player player) {
+ Location loc = block.getLocation();
+ plugin.inProcess.add(block);
+ new SpawnParticles(plugin, loc, 5, Particle.TOTEM); // Spawns the particles
+ int i = getRandomItem();
+ ItemStack item = getCrateItems.get(i);
+ plugin.data.getConfig().set("crates." + name + ".items." + i, null);
+ plugin.data.saveConfig();
+ plugin.lootInstance.get(player.getUniqueId()).allItems.add(item);
+ plugin.lootInstance.get(player.getUniqueId()).createInv();
+ player.sendMessage(ChatColor.GOLD + "Do /crateloot, to claim your rewards!");
+ String itemname = item.getItemMeta().getDisplayName();
+ if (itemname.equals("")) {
+ itemname = item.getType().toString().replace('_', ' ');
+ }
+ renameHologram(block, player.getName(), item.getAmount(), itemname, 10);
+ openShulker(loc, 10, block);
+ Location rotateLoc = loc.clone().subtract(0, 1, 0);
+ if (!item.getType().isBlock()) {
+ rotateLoc.subtract(0, 0.25, 0);
+ }
+ armorStandRotateAnimate(block.getLocation(), 10, item, rotateLoc.clone());
+ getCrateItems.remove(item);
+ loc.getWorld().playSound(loc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
+ }
+
+ public Hologram createArmorStand(Location loc) {
+ Hologram hologram = HologramsAPI.createHologram(plugin, loc.clone().add(0.5, 2.0, 0.5));
+ hologram.appendTextLine(ChatColor.BOLD + "" + ChatColor.GOLD + name.substring(0, name.length() - 1));
+ hologram.appendTextLine(ChatColor.WHITE + "" + getPrice() + " Dollars");
+ plugin.holoInstance.put(loc, hologram);
+ return hologram;
+ }
+
+ private void openShulker(Location loc, int i, Block block) {
+ net.minecraft.server.v1_16_R3.World world = ((CraftWorld) loc.getWorld()).getHandle();
+ BlockPosition position = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
+ TileEntityShulkerBox tileShulker = (TileEntityShulkerBox) world.getTileEntity(position);
+ world.playBlockAction(position, tileShulker.getBlock().getBlock(), 1, 1);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ world.playBlockAction(position, tileShulker.getBlock().getBlock(), 1, 0);
+ plugin.inProcess.remove(block);
+ }
+ }, i * 20);
+ }
+
+ private void armorStandRotateAnimate(Location a, int i, ItemStack item, Location loc){
+ ArmorStand as = plugin.asInstance.get(a);
+ as.teleport(loc);
+ as.setVisible(false);
+ prepareArmorStand(as, item);
+ if (!plugin.mani.contains(as)) {
+ plugin.mani.add(as);
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ @SuppressWarnings("deprecation")
+ public void run() {
+ as.setHelmet(new ItemStack(Material.AIR));
+ }
+ }, i * 20);
+ plugin.getServer().getScheduler().runTaskTimer(plugin, () -> {
+ loc.setYaw(loc.getYaw() + 4);
+ as.teleport(loc);
+ }, 0, 1);
+ }
+
+ private int getRandomItem() {
+ Random rand = new Random();
+ int i = rand.nextInt(getCrateItems.size());
+ return i;
+ }
+
+ @SuppressWarnings("deprecation")
+ private void prepareArmorStand(ArmorStand as, ItemStack item) {
+ as.setVisible(false);
+ as.setMarker(false);
+ as.setBasePlate(false);
+ as.setSmall(true);
+ as.setHelmet(item);
+ as.setInvulnerable(true);
+ as.setAI(false);
+ as.setGravity(false);
+ as.setCollidable(false);
+ }
+
+ private void renameHologram(Block loc, String pName, int amount, String item, int duration) {
+ Hologram gram = plugin.holoInstance.get(loc.getLocation());
+ gram.clearLines();
+ gram.appendTextLine(ChatColor.BOLD + "" + ChatColor.GOLD + pName);
+ gram.appendTextLine(ChatColor.WHITE + "Has won " + amount + "x " + item + "!");
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ /*
+ * ChatColor.BOLD + "" + ChatColor.GOLD + name.substring(0, name.length() - 1)
+ * ChatColor.WHITE + "" + getPrice() + " Dollars"
+ */
+ gram.clearLines();
+ gram.appendTextLine(ChatColor.BOLD + "" + ChatColor.GOLD + name.substring(0, name.length() - 1));
+ gram.appendTextLine(ChatColor.WHITE + "" + getPrice() + " Dollars");
+ }
+ }, duration * 20);
+ }
+
+ public void updateHoloPrice() {
+ plugin.data.getConfig().getConfigurationSection("shulker").getKeys(false).forEach(key -> {
+ Location loc = plugin.util.stringToLoc(key);
+ Hologram gram = plugin.holoInstance.get(loc);
+ gram.clearLines();
+ gram.appendTextLine(ChatColor.BOLD + "" + ChatColor.GOLD + name.substring(0, name.length() - 1));
+ gram.appendTextLine(ChatColor.WHITE + "" + getPrice() + " Dollars");
+ });
+ }
+
+ public void rename(String newName) {
+
+ newName = newName + " ";
+
+ Crate crate = new Crate(plugin, newName);
+
+ crate.setCrateItems(this.getCrateItems);
+ crate.getCrateItems.clear();
+ crate.getCrateItems.addAll(this.getCrateItems);
+
+ for (Location loc : getLocations()) {
+ plugin.data.getConfig().set("shulker." + plugin.util.locToString(loc) + ".crate-name", newName);
+ plugin.data.saveConfig();
+ }
+
+ for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
+ plugin.data.getConfig().set("data." + p.getUniqueId().toString() + "." + name, null);
+ plugin.data.saveConfig();
+ plugin.data.getConfig().set("data." + p.getUniqueId().toString() + "." + newName, 0);
+ plugin.data.saveConfig();
+ }
+
+
+
+ plugin.data.getConfig().set("crates." + name, null);
+ plugin.data.saveConfig();
+
+ plugin.crateInstance.put(newName, crate);
+ plugin.crateInstance.remove(name);
+
+ plugin.removeHolos();
+ plugin.removeAs();
+
+ plugin.loadHolos();
+ plugin.spawnAs();
+
+ }
+
+}
+
+/* crates:
+ * cratename:
+ * items:
+ * 1:
+ * item
+ * 2:
+ * item
+ * price: int
+ */
+
+/*
+ * shulker:
+ * location:
+ * crate-name: name
+ */
\ No newline at end of file
diff --git a/src/main/java/me/latestion/latestcrates/utils/CrateAPI.java b/src/main/java/me/latestion/latestcrates/utils/CrateAPI.java
new file mode 100644
index 0000000..11b8201
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/CrateAPI.java
@@ -0,0 +1,41 @@
+package me.latestion.latestcrates.utils;
+
+import me.latestion.latestcrates.LatestCrates;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+public class CrateAPI {
+
+ public CrateAPI() {
+
+ }
+
+ public static Set getAllCrates() {
+ return LatestCrates.instance.crateInstance.keySet();
+ }
+
+ public static List getCrateShulkers(String name) {
+ List send = new ArrayList();
+ try {
+ LatestCrates.instance.data.getConfig().getConfigurationSection("shulker").getKeys(false).forEach(loc -> {
+ if (LatestCrates.instance.data.getConfig().getString("shulker." + loc + ".crate-name").equalsIgnoreCase(name)) {
+ send.add(loc);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return send;
+ }
+
+ public static void renameCrate(String name, String newName) {
+ LatestCrates.instance.crateInstance.get(name).rename(newName);
+ }
+
+ public static boolean isCrateEmpty(String name) {
+ return !LatestCrates.instance.data.getConfig().contains("crates." + name + ".items.0");
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/utils/CrateInv.java b/src/main/java/me/latestion/latestcrates/utils/CrateInv.java
new file mode 100644
index 0000000..bda57b4
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/CrateInv.java
@@ -0,0 +1,85 @@
+package me.latestion.latestcrates.utils;
+
+import com.earth2me.essentials.api.Economy;
+import com.earth2me.essentials.api.UserDoesNotExistException;
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+public class CrateInv {
+
+ private Inventory inv;
+ private String name;
+ private LatestCrates plugin;
+ private UUID id;
+
+ int x = 0;
+ int price = 0;
+
+ public CrateInv(LatestCrates plugin, UUID id, String name) {
+ this.name = name;
+ this.plugin = plugin;
+ this.id = id;
+ price = plugin.util.getCratePrice(name);
+ setX();
+ createInv();
+ }
+
+ public Inventory getInventory() {
+ return inv;
+ }
+
+ private void createInv() {
+ inv = Bukkit.createInventory(null, 27, name);
+ Crate crate = plugin.crateInstance.get(name);
+ int total = crate.getPlayerCrate(Bukkit.getPlayer(id));
+ inv.setItem(11, iron(total));
+ if (total > 64) {
+ inv.setItem(11, iron(64));
+ }
+ inv.setItem(15, gold());
+ }
+
+ private ItemStack iron(int i) {
+ if (i == 0) {
+ i = 1;
+ }
+ ItemStack item = new ItemStack(Material.IRON_NUGGET, i);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.WHITE + "Pay with purchased crates");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public void setX() {
+ if (price == 0) return;
+ try {
+ BigDecimal i = Economy.getMoneyExact(id);
+ x = i.intValue() / price;
+ } catch (UserDoesNotExistException e) {
+
+ }
+
+ }
+
+ private ItemStack gold() {
+ ItemStack item = new ItemStack(Material.GOLD_NUGGET);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GOLD + "Pay with dollars");
+ List lore = new ArrayList<>();
+ lore.add(ChatColor.GOLD + "You can buy " + x + " crates with dollars");
+ meta.setLore(lore);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/utils/CrateItemChance.java b/src/main/java/me/latestion/latestcrates/utils/CrateItemChance.java
new file mode 100644
index 0000000..01b3fbd
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/CrateItemChance.java
@@ -0,0 +1,15 @@
+package me.latestion.latestcrates.utils;
+
+import me.latestion.latestcrates.LatestCrates;
+
+public class CrateItemChance {
+
+ private LatestCrates plugin;
+ private Crate crate;
+
+ public CrateItemChance(LatestCrates plugin, Crate crate) {
+
+ }
+
+}
+
diff --git a/src/main/java/me/latestion/latestcrates/utils/CrateLoot.java b/src/main/java/me/latestion/latestcrates/utils/CrateLoot.java
new file mode 100644
index 0000000..e0c2597
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/CrateLoot.java
@@ -0,0 +1,117 @@
+package me.latestion.latestcrates.utils;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+public class CrateLoot {
+
+ private LatestCrates plugin;
+ public List invs = new ArrayList();
+
+ private UUID id;
+
+ public List allItems = new ArrayList<>();
+
+ public CrateLoot(LatestCrates plugin, UUID id) {
+ this.plugin = plugin;
+ this.id = id;
+ allItems = getAllItems();
+ createInv();
+ }
+
+ public Inventory getInventory() {
+ return invs.get(0);
+ }
+
+ public void createInv() {
+ invs.clear();
+ Inventory inv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Crate Loot");
+ setClose(inv);
+ setArrow(inv);
+ setClaim(inv);
+ int i = 0;
+ for (ItemStack item : allItems) {
+ inv.addItem(item);
+ i++;
+ if (i == 45) {
+ Inventory set;
+ set = inv;
+ invs.add(set);
+ inv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Crate Loot");
+ setClose(inv);
+ setArrow(inv);
+ setClaim(inv);
+ }
+ }
+ if (!invs.contains(inv)) invs.add(inv);
+ }
+
+ private void setClose(Inventory inv) {
+ ItemStack item = new ItemStack(Material.BARRIER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Close");
+ item.setItemMeta(meta);
+ inv.setItem(49, item);
+ }
+
+ private void setArrow(Inventory inv) {
+ ItemStack item = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Previous Page");
+ item.setItemMeta(meta);
+ inv.setItem(48, item);
+
+ ItemStack item2 = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta2 = item2.getItemMeta();
+ meta2.setDisplayName(ChatColor.GREEN + "Next Page");
+ item2.setItemMeta(meta2);
+ inv.setItem(50, item2);
+ }
+
+ private void setClaim(Inventory inv) {
+ ItemStack item = new ItemStack(Material.CHEST);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GOLD + "Claim All");
+ item.setItemMeta(meta);
+ inv.setItem(47, item);
+ }
+
+ private List getAllItems() {
+ List items = new ArrayList<>();
+ try {
+ plugin.loot.getConfig().getConfigurationSection("loot." + id.toString() + ".items").getKeys(false).forEach(num -> {
+ // num is number
+ ItemStack add = plugin.loot.getConfig().getItemStack("loot." + id.toString() + ".items." + num);
+ items.add(add);
+ });
+ } catch (Exception e) {
+ }
+ return items;
+ }
+
+ public void setCrateItems() {
+ int i = 0;
+ plugin.loot.getConfig().set("loot." + id.toString() + ".items", null);
+ plugin.loot.saveConfig();
+ for (ItemStack item : allItems) {
+ plugin.loot.getConfig().set("loot." + id.toString() + ".items." + i, item);
+ plugin.loot.saveConfig();
+ i++;
+ }
+ }
+
+
+ public Player getPlayer() {
+ return Bukkit.getPlayer(id);
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/utils/CreateCrate.java b/src/main/java/me/latestion/latestcrates/utils/CreateCrate.java
new file mode 100644
index 0000000..8e24ce6
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/CreateCrate.java
@@ -0,0 +1,146 @@
+package me.latestion.latestcrates.utils;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CreateCrate {
+
+ private Inventory invv;
+ private String name;
+ public List invs = new ArrayList();
+ private LatestCrates plugin;
+ private Player player;
+
+ public CreateCrate(LatestCrates plugin, String name, Player player) {
+ this.name = name;
+ createInv();
+ this.plugin = plugin;
+ this.player = player;
+ }
+
+ public void createInv() {
+ invv = Bukkit.createInventory(null, 54, name);
+ setGlass(invv);
+ setLaunch(invv);
+ setClose(invv);
+ setArrow(invv);
+ invs.add(invv);
+ }
+
+
+ public Inventory getInventory() {
+ return invv;
+ }
+
+ public Inventory createNewInv() {
+ Inventory newInv = Bukkit.createInventory(null, 54, name);
+ setGlass(newInv);
+ setLaunch(newInv);
+ setClose(newInv);
+ setArrow(newInv);
+ invs.add(newInv); // Added
+ return newInv;
+ }
+
+ public boolean isInventoryFull(Inventory inv) {
+ for (ItemStack item : inv.getContents()) {
+ if (item == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void createCrate() {
+ // Means they pressed launch
+ List items = new ArrayList();
+ for (Inventory inv : invs) {
+ for (int i = 9; i < 45; i++) {
+ ItemStack item = inv.getItem(i);
+ if (item != null) {
+ items.add(item);
+ }
+
+ }
+ }
+ if (items.isEmpty()) {
+ player.sendMessage(ChatColor.RED + "Cannot create an empty crate!");
+ return;
+ }
+ player.sendMessage(ChatColor.GOLD + "Crate has been created!");
+ Crate crate = new Crate(plugin, name);
+ crate.setCrateItems(items);
+ crate.getCrateItems.clear();
+ crate.getCrateItems.addAll(items);
+ for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
+ plugin.data.getConfig().set("data." + p.getUniqueId().toString() + "." + name, 0);
+ plugin.data.saveConfig();
+ }
+ plugin.crateInstance.put(name, crate);
+ }
+
+ private ItemStack glass() {
+ ItemStack item = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(" ");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private void setGlass(Inventory inv) {
+ inv.setItem(0, glass());
+ inv.setItem(1, glass());
+ inv.setItem(2, glass());
+ inv.setItem(3, glass());
+ inv.setItem(5, glass());
+ inv.setItem(6, glass());
+ inv.setItem(7, glass());
+ inv.setItem(8, glass());
+ inv.setItem(45, glass());
+ inv.setItem(46, glass());
+ inv.setItem(47, glass());
+ inv.setItem(51, glass());
+ inv.setItem(52, glass());
+ inv.setItem(53, glass());
+ }
+
+ private void setLaunch(Inventory inv) {
+ ItemStack item = new ItemStack(Material.GREEN_TERRACOTTA);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GREEN + "Launch");
+ item.setItemMeta(meta);
+ inv.setItem(4, item);
+ }
+
+ private void setClose(Inventory inv) {
+ ItemStack item = new ItemStack(Material.BARRIER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Close");
+ item.setItemMeta(meta);
+ inv.setItem(49, item);
+ }
+
+ private void setArrow(Inventory inv) {
+ ItemStack item = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Previous Page");
+ item.setItemMeta(meta);
+ inv.setItem(48, item);
+
+ ItemStack item2 = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta2 = item2.getItemMeta();
+ meta2.setDisplayName(ChatColor.GREEN + "Next Page");
+ item2.setItemMeta(meta2);
+ inv.setItem(50, item2);
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/utils/RefillInv.java b/src/main/java/me/latestion/latestcrates/utils/RefillInv.java
new file mode 100644
index 0000000..07fbfbe
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/RefillInv.java
@@ -0,0 +1,153 @@
+package me.latestion.latestcrates.utils;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RefillInv {
+
+ private Inventory invv;
+ private String name;
+ public List invs = new ArrayList();
+ private LatestCrates plugin;
+ private Player player;
+
+ public RefillInv(LatestCrates plugin, String name, Player player) {
+ this.name = name;
+ this.plugin = plugin;
+ this.player = player;
+ createInv();
+ }
+
+ public void createInv() {
+ invv = Bukkit.createInventory(null, 54, name);
+ setGlass(invv);
+ setLaunch(invv);
+ setClose(invv);
+ setArrow(invv);
+ int i = 9;
+ invs.add(invv);
+ Inventory set = invv;
+ Crate crate = plugin.crateInstance.get(name);
+ List items = crate.getCrateItems;
+ for (ItemStack item : items) {
+ set.setItem(i, item);
+ if (i == 44) {
+ Inventory nw = createNewInv();
+ set = nw;
+ i = 8;
+ }
+ i++;
+ }
+ }
+
+
+ public Inventory getInventory() {
+ return invs.get(0);
+ }
+
+ public Inventory createNewInv() {
+ Inventory newInv = Bukkit.createInventory(null, 54, name);
+ setGlass(newInv);
+ setLaunch(newInv);
+ setClose(newInv);
+ setArrow(newInv);
+ invs.add(newInv); // Added
+ return newInv;
+ }
+
+ public boolean isInventoryFull(Inventory inv) {
+ for (ItemStack item : inv.getContents()) {
+ if (item == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void createCrate() {
+ // Means they pressed launch
+ List items = new ArrayList();
+ for (Inventory inv : invs) {
+ for (int i = 9; i < 45; i++) {
+ ItemStack item = inv.getItem(i);
+ if (item != null) {
+ items.add(item);
+ }
+
+ }
+ }
+ if (items.isEmpty()) {
+ player.sendMessage(ChatColor.RED + "Cannot create an empty crate!");
+ return;
+ }
+ player.sendMessage(ChatColor.GOLD + "Crate has been updated!");
+ Crate crate = plugin.crateInstance.get(name);
+ crate.getCrateItems.clear();
+ crate.getCrateItems.addAll(items);
+ }
+
+ private ItemStack glass() {
+ ItemStack item = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(" ");
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ private void setGlass(Inventory inv) {
+ inv.setItem(0, glass());
+ inv.setItem(1, glass());
+ inv.setItem(2, glass());
+ inv.setItem(3, glass());
+ inv.setItem(5, glass());
+ inv.setItem(6, glass());
+ inv.setItem(7, glass());
+ inv.setItem(8, glass());
+ inv.setItem(45, glass());
+ inv.setItem(46, glass());
+ inv.setItem(47, glass());
+ inv.setItem(51, glass());
+ inv.setItem(52, glass());
+ inv.setItem(53, glass());
+ }
+
+ private void setLaunch(Inventory inv) {
+ ItemStack item = new ItemStack(Material.GREEN_TERRACOTTA);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.GREEN + "Launch");
+ item.setItemMeta(meta);
+ inv.setItem(4, item);
+ }
+
+ private void setClose(Inventory inv) {
+ ItemStack item = new ItemStack(Material.BARRIER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Close");
+ item.setItemMeta(meta);
+ inv.setItem(49, item);
+ }
+
+ private void setArrow(Inventory inv) {
+ ItemStack item = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(ChatColor.RED + "Previous Page");
+ item.setItemMeta(meta);
+ inv.setItem(48, item);
+
+ ItemStack item2 = new ItemStack(Material.SPECTRAL_ARROW);
+ ItemMeta meta2 = item2.getItemMeta();
+ meta2.setDisplayName(ChatColor.GREEN + "Next Page");
+ item2.setItemMeta(meta2);
+ inv.setItem(50, item2);
+ }
+
+}
diff --git a/src/main/java/me/latestion/latestcrates/utils/SpawnParticles.java b/src/main/java/me/latestion/latestcrates/utils/SpawnParticles.java
new file mode 100644
index 0000000..dbffe38
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/SpawnParticles.java
@@ -0,0 +1,93 @@
+package me.latestion.latestcrates.utils;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Location;
+import org.bukkit.Particle;
+import org.bukkit.scheduler.BukkitRunnable;
+
+public class SpawnParticles {
+
+ private LatestCrates plugin;
+
+ public SpawnParticles(LatestCrates plugin, Location loc, int amount, Particle particle) {
+ this.plugin = plugin;
+ playSpiralParticle(loc, amount, particle);
+ }
+
+ private void playSpiralParticle(Location loc, int amount, Particle particle) {
+ Location l = loc.add(.5, .7, .5);
+ new BukkitRunnable() {
+ int time = 16;
+ @Override
+ public void run() {
+ if (time == 15) {
+ l.getWorld().spawnParticle(particle, l.clone().add(.8, 0, 0), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(-.8, 0, 0), amount, 0, 0, 0, 0);
+ }
+ if (time == 14) {
+ l.getWorld().spawnParticle(particle, l.clone().add(.75, 0, .43), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(-.75, 0, -.43), amount, 0, 0, 0, 0);
+ }
+ if (time == 13) {
+ l.getWorld().spawnParticle(particle, l.clone().add(.65, 0, .65), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(-.65, 0, -.65), amount, 0, 0, 0, 0);
+ }
+ if (time == 12) {
+ l.getWorld().spawnParticle(particle, l.clone().add(.43, 0, .75), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(-.43, 0, -.75), amount, 0, 0, 0, 0);
+ }
+ if (time == 11) {
+ l.getWorld().spawnParticle(particle, l.clone().add(0, 0, .8), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(0, 0, -.8), amount, 0, 0, 0, 0);
+ }
+ if (time == 10) {
+ l.getWorld().spawnParticle(particle, l.clone().add(-.43, 0, .75), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(.43, 0, -.75), amount, 0, 0, 0, 0);
+ }
+ if (time == 9) {
+ l.getWorld().spawnParticle(particle, l.clone().add(-.65, 0, .65), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(.65, 0, -.65), amount, 0, 0, 0, 0);
+ }
+ if (time == 8) {
+ l.getWorld().spawnParticle(particle, l.clone().add(-.75, 0, .43), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(.75, 0, -.43), amount, 0, 0, 0, 0);
+ }
+ if (time == 7) {
+ l.getWorld().spawnParticle(particle, l.clone().add(-.8, 0, 0), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(.8, 0, 0), amount, 0, 0, 0, 0);
+ }
+ if (time == 6) {
+ l.getWorld().spawnParticle(particle, l.clone().add(-.75, 0, -.43), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(.75, 0, .43), amount, 0, 0, 0, 0);
+ }
+ if (time == 5) {
+ l.getWorld().spawnParticle(particle, l.clone().add(-.65, 0, -.65), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(.65, 0, .65), amount, 0, 0, 0, 0);
+ }
+ if (time == 4) {
+ l.getWorld().spawnParticle(particle, l.clone().add(-.43, 0, -.75), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(.43, 0, .75), amount, 0, 0, 0, 0);
+ }
+ if (time == 3) {
+ l.getWorld().spawnParticle(particle, l.clone().add(0, 0, -.8), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(0, 0, .8), amount, 0, 0, 0, 0);
+ }
+ if (time == 2) {
+ l.getWorld().spawnParticle(particle, l.clone().add(.43, 0, -.75), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(-.43, 0, .75), amount, 0, 0, 0, 0);
+ }
+ if (time == 1) {
+ l.getWorld().spawnParticle(particle, l.clone().add(.65, 0, -.65), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(-.65, 0, .65), amount, 0, 0, 0, 0);
+ }
+ if (time == 0) {
+ l.getWorld().spawnParticle(particle, l.clone().add(.75, 0, -.43), amount, 0, 0, 0, 0);
+ l.getWorld().spawnParticle(particle, l.clone().add(-.75, 0, .43), amount, 0, 0, 0, 0);
+ cancel();
+ }
+ time--;
+ }
+
+ }.runTaskTimer(plugin, 0, 2);
+ }
+}
diff --git a/src/main/java/me/latestion/latestcrates/utils/Util.java b/src/main/java/me/latestion/latestcrates/utils/Util.java
new file mode 100644
index 0000000..80642be
--- /dev/null
+++ b/src/main/java/me/latestion/latestcrates/utils/Util.java
@@ -0,0 +1,99 @@
+package me.latestion.latestcrates.utils;
+
+import me.latestion.latestcrates.LatestCrates;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Util {
+
+ private LatestCrates plugin;
+
+ public Util(LatestCrates plugin) {
+ this.plugin = plugin;
+ }
+
+ public String locToString(Location loc) {
+ return (loc.getWorld().getName() + "," + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ());
+ }
+
+ public Location stringToLoc(String loc) {
+ String[] split = loc.split(",");
+ Location send = new Location(Bukkit.getWorld(split[0]), parseInt(split[1]), parseInt(split[2]), parseInt(split[3]));
+ return send;
+ }
+
+ public int parseInt(String i) {
+ return Integer.parseInt(i);
+ }
+
+ public boolean isCrate(String name) {
+ return (plugin.crateInstance.containsKey(name));
+ }
+
+ public boolean isNum(String i) {
+ try {
+ Integer.parseInt(i);
+ return true;
+ }
+ catch (Exception e) {
+ return false;
+ }
+ }
+
+ public int getCratePrice(String name) {
+ return plugin.data.getConfig().getInt("crates." + name + ".price");
+ }
+
+ public boolean isInventoryFull(Player player) {
+ return player.getInventory().firstEmpty() == -1;
+ }
+
+ public boolean isShulkerBox(Material m) {
+ switch (m) {
+ case SHULKER_BOX:
+ case LIGHT_GRAY_SHULKER_BOX:
+ case BLACK_SHULKER_BOX:
+ case BLUE_SHULKER_BOX:
+ case BROWN_SHULKER_BOX:
+ case CYAN_SHULKER_BOX:
+ case GRAY_SHULKER_BOX:
+ case GREEN_SHULKER_BOX:
+ case LIGHT_BLUE_SHULKER_BOX:
+ case LIME_SHULKER_BOX:
+ case MAGENTA_SHULKER_BOX:
+ case ORANGE_SHULKER_BOX:
+ case PINK_SHULKER_BOX:
+ case PURPLE_SHULKER_BOX:
+ case RED_SHULKER_BOX:
+ case WHITE_SHULKER_BOX:
+ case YELLOW_SHULKER_BOX:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public boolean isLocationTaken(Location loc) {
+ List test = new ArrayList<>();
+ try {
+ plugin.data.getConfig().getConfigurationSection("shulker").getKeys(false).forEach(key -> {
+ test.add(this.stringToLoc(key));
+ });
+ if (test.contains(loc)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ } catch (Exception e) {
+
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/resources/data.yml b/src/main/resources/data.yml
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/resources/loot.yml b/src/main/resources/loot.yml
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..e5a6868
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,10 @@
+name: LatestCrates
+version: ${project.version}
+main: me.latestion.latestcrates.LatestCrates
+api-version: 1.16
+depend: [Vault]
+
+commands:
+ crate:
+ crateloot:
+ cratesgui: