diff --git a/src/bskyblock/addon/level/Level.java b/src/bskyblock/addon/level/Level.java index 815c03d..c08768c 100644 --- a/src/bskyblock/addon/level/Level.java +++ b/src/bskyblock/addon/level/Level.java @@ -14,12 +14,12 @@ import bskyblock.addon.level.commands.AdminTop; import bskyblock.addon.level.commands.IslandLevel; import bskyblock.addon.level.commands.IslandTop; import bskyblock.addon.level.config.PluginConfig; -import bskyblock.addon.level.database.object.Levels; +import bskyblock.addon.level.database.object.LevelsData; import us.tastybento.bskyblock.BSkyBlock; +import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.api.addons.Addon; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.User; -import us.tastybento.bskyblock.config.Settings; import us.tastybento.bskyblock.database.BSBDatabase; import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler; @@ -38,7 +38,7 @@ public class Level extends Addon { BukkitTask checker = null; // Database handler for level data - private AbstractDatabaseHandler handler; + private AbstractDatabaseHandler handler; // The BSkyBlock database object private BSBDatabase database; @@ -70,7 +70,7 @@ public class Level extends Addon { database = BSBDatabase.getDatabase(); // Set up the database handler to store and retrieve Island classes // Note that these are saved by the BSkyBlock database - handler = (AbstractDatabaseHandler) database.getHandler(bSkyBlock, Levels.class); + handler = (AbstractDatabaseHandler) database.getHandler(LevelsData.class); // Initialize the cache levelsCache = new HashMap<>(); // Load all the levels @@ -83,10 +83,10 @@ public class Level extends Addon { // Local locales //localeManager = new LocaleManager(this); // Register commands - CompositeCommand bsbIslandCmd = (CompositeCommand) BSkyBlock.getInstance().getCommandsManager().getCommand(Settings.ISLANDCOMMAND); + CompositeCommand bsbIslandCmd = (CompositeCommand) BSkyBlock.getInstance().getCommandsManager().getCommand(Constants.ISLANDCOMMAND); new IslandLevel(this, bsbIslandCmd); new IslandTop(this, bsbIslandCmd); - CompositeCommand bsbAdminCmd = (CompositeCommand) BSkyBlock.getInstance().getCommandsManager().getCommand(Settings.ADMINCOMMAND); + CompositeCommand bsbAdminCmd = (CompositeCommand) BSkyBlock.getInstance().getCommandsManager().getCommand(Constants.ADMINCOMMAND); new AdminLevel(this, bsbAdminCmd); new AdminTop(this, bsbAdminCmd); // Done @@ -102,7 +102,7 @@ public class Level extends Addon { public void load() { try { - for (Levels level : handler.loadObjects()) { + for (LevelsData level : handler.loadObjects()) { levelsCache.put(UUID.fromString(level.getUniqueId()), level.getLevel()); } } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException @@ -120,7 +120,7 @@ public class Level extends Addon { Runnable save = () -> { try { for (Entry en : levelsCache.entrySet()) { - Levels lv = new Levels(); + LevelsData lv = new LevelsData(); lv.setLevel(en.getValue()); lv.setUniqueId(en.getKey().toString()); handler.saveObject(lv); @@ -149,7 +149,7 @@ public class Level extends Addon { return levelsCache.get(targetPlayer); } // Get from database - Levels level; + LevelsData level; try { level = handler.loadObject(targetPlayer.toString()); if (level == null) { @@ -178,7 +178,7 @@ public class Level extends Addon { topTen.addEntry(targetPlayer, level); } - public AbstractDatabaseHandler getHandler() { + public AbstractDatabaseHandler getHandler() { return handler; } diff --git a/src/bskyblock/addon/level/LevelPresenter.java b/src/bskyblock/addon/level/LevelPresenter.java index fabec7d..3e08d4f 100644 --- a/src/bskyblock/addon/level/LevelPresenter.java +++ b/src/bskyblock/addon/level/LevelPresenter.java @@ -6,8 +6,8 @@ import java.util.UUID; import org.bukkit.ChatColor; +import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.api.commands.User; -import us.tastybento.bskyblock.config.Settings; public class LevelPresenter extends LevelPlugin { @@ -46,9 +46,9 @@ public class LevelPresenter extends LevelPlugin { return false; } // Player asking for their own island calc - if (!sender.isPlayer() || sender.getUniqueId().equals(targetPlayer) || sender.isOp() || sender.hasPermission(Settings.PERMPREFIX + "mod.info")) { + if (!sender.isPlayer() || sender.getUniqueId().equals(targetPlayer) || sender.isOp() || sender.hasPermission(Constants.PERMPREFIX + "mod.info")) { // Newer better system - uses chunks - if (!onLevelWaitTime(sender) || levelWait <= 0 || sender.isOp() || sender.hasPermission(Settings.PERMPREFIX + "mod.info")) { + if (!onLevelWaitTime(sender) || levelWait <= 0 || sender.isOp() || sender.hasPermission(Constants.PERMPREFIX + "mod.info")) { sender.sendRawMessage(ChatColor.GREEN + "Calculating level, please wait..."); setLevelWaitTime(sender); new ChunkScanner(plugin, bSkyBlock.getIslands().getIsland(targetPlayer), sender); diff --git a/src/bskyblock/addon/level/TopTen.java b/src/bskyblock/addon/level/TopTen.java index 9932d0b..912325c 100644 --- a/src/bskyblock/addon/level/TopTen.java +++ b/src/bskyblock/addon/level/TopTen.java @@ -41,11 +41,11 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; -import bskyblock.addon.level.database.object.Levels; -import bskyblock.addon.level.database.object.TopTenList; +import bskyblock.addon.level.database.object.LevelsData; +import bskyblock.addon.level.database.object.TopTenData; import bskyblock.addon.level.event.TopTenClick; import us.tastybento.bskyblock.BSkyBlock; -import us.tastybento.bskyblock.config.Settings; +import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.database.BSBDatabase; import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler; @@ -58,14 +58,14 @@ import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler; public class TopTen implements Listener { private Level plugin; // Top ten list of players - private TopTenList topTenList; + private TopTenData topTenList; private final int GUISIZE = 27; // Must be a multiple of 9 private final int[] SLOTS = new int[] {4, 12, 14, 19, 20, 21, 22, 23, 24, 25}; private final boolean DEBUG = false; // Store this as a because it's the same for everyone and saves memory cleanup private Inventory gui; private BSBDatabase database; - private AbstractDatabaseHandler handler; + private AbstractDatabaseHandler handler; @SuppressWarnings("unchecked") public TopTen(Level plugin) { @@ -74,7 +74,7 @@ public class TopTen implements Listener { database = BSBDatabase.getDatabase(); // Set up the database handler to store and retrieve the TopTenList class // Note that these are saved in the BSkyBlock database - handler = (AbstractDatabaseHandler) database.getHandler(BSkyBlock.getInstance(), TopTenList.class); + handler = (AbstractDatabaseHandler) database.getHandler(TopTenData.class); loadTopTen(); } @@ -89,7 +89,7 @@ public class TopTen implements Listener { Player player = plugin.getServer().getPlayer(ownerUUID); if (player != null) { // Online - if (!player.hasPermission(Settings.PERMPREFIX + "intopten")) { + if (!player.hasPermission(Constants.PERMPREFIX + "intopten")) { topTenList.remove(ownerUUID); return; } @@ -105,10 +105,10 @@ public class TopTen implements Listener { */ public void create() { // Obtain all the levels for each known player - AbstractDatabaseHandler levelHandler = plugin.getHandler(); + AbstractDatabaseHandler levelHandler = plugin.getHandler(); try { long index = 0; - for (Levels lv : levelHandler.loadObjects()) { + for (LevelsData lv : levelHandler.loadObjects()) { if (index++ % 1000 == 0) { plugin.getLogger().info("Processed " + index + " players for top ten"); } @@ -158,7 +158,7 @@ public class TopTen implements Listener { Player entry = plugin.getServer().getPlayer(playerUUID); boolean show = true; if (entry != null) { - if (!entry.hasPermission(Settings.PERMPREFIX + "intopten")) { + if (!entry.hasPermission(Constants.PERMPREFIX + "intopten")) { it.remove(); show = false; } @@ -211,7 +211,7 @@ public class TopTen implements Listener { return playerSkull; } - public TopTenList getTopTenList() { + public TopTenData getTopTenList() { return topTenList; } @@ -222,7 +222,7 @@ public class TopTen implements Listener { try { topTenList = handler.loadObject("topten"); if (topTenList == null) { - topTenList = new TopTenList(); + topTenList = new TopTenData(); } } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException | ClassNotFoundException | IntrospectionException | SQLException e) { diff --git a/src/bskyblock/addon/level/commands/AdminLevel.java b/src/bskyblock/addon/level/commands/AdminLevel.java index de7f86b..8a5a596 100644 --- a/src/bskyblock/addon/level/commands/AdminLevel.java +++ b/src/bskyblock/addon/level/commands/AdminLevel.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.UUID; import bskyblock.addon.level.Level; +import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.User; -import us.tastybento.bskyblock.config.Settings; public class AdminLevel extends CompositeCommand { @@ -40,7 +40,7 @@ public class AdminLevel extends CompositeCommand { @Override public void setup() { - this.setPermission(Settings.PERMPREFIX + "admin.level"); + this.setPermission(Constants.PERMPREFIX + "admin.level"); this.setOnlyPlayer(false); this.setParameters("admin.level.parameters"); this.setDescription("admin.level.description"); diff --git a/src/bskyblock/addon/level/commands/AdminTop.java b/src/bskyblock/addon/level/commands/AdminTop.java index 484d48e..3cf2a62 100644 --- a/src/bskyblock/addon/level/commands/AdminTop.java +++ b/src/bskyblock/addon/level/commands/AdminTop.java @@ -2,15 +2,13 @@ package bskyblock.addon.level.commands; import java.util.List; import java.util.Map.Entry; - -import bskyblock.addon.level.Level; - import java.util.UUID; +import bskyblock.addon.level.Level; import us.tastybento.bskyblock.BSkyBlock; +import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.User; -import us.tastybento.bskyblock.config.Settings; public class AdminTop extends CompositeCommand { @@ -37,7 +35,7 @@ public class AdminTop extends CompositeCommand { @Override public void setup() { - this.setPermission(Settings.PERMPREFIX + "admin.top"); + this.setPermission(Constants.PERMPREFIX + "admin.top"); this.setOnlyPlayer(false); this.setDescription("admin.top.description"); } diff --git a/src/bskyblock/addon/level/commands/IslandLevel.java b/src/bskyblock/addon/level/commands/IslandLevel.java index 7634fe2..1b2a839 100644 --- a/src/bskyblock/addon/level/commands/IslandLevel.java +++ b/src/bskyblock/addon/level/commands/IslandLevel.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.UUID; import bskyblock.addon.level.Level; +import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.User; -import us.tastybento.bskyblock.config.Settings; public class IslandLevel extends CompositeCommand { @@ -43,7 +43,7 @@ public class IslandLevel extends CompositeCommand { @Override public void setup() { - this.setPermission(Settings.PERMPREFIX + "island.level"); + this.setPermission(Constants.PERMPREFIX + "island.level"); this.setParameters("island.level.parameters"); this.setDescription("island.level.description"); this.setOnlyPlayer(true); diff --git a/src/bskyblock/addon/level/commands/IslandTop.java b/src/bskyblock/addon/level/commands/IslandTop.java index 3916867..6ef8b0e 100644 --- a/src/bskyblock/addon/level/commands/IslandTop.java +++ b/src/bskyblock/addon/level/commands/IslandTop.java @@ -3,9 +3,9 @@ package bskyblock.addon.level.commands; import java.util.List; import bskyblock.addon.level.Level; +import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.User; -import us.tastybento.bskyblock.config.Settings; public class IslandTop extends CompositeCommand { @@ -24,7 +24,7 @@ public class IslandTop extends CompositeCommand { @Override public void setup() { - this.setPermission(Settings.PERMPREFIX + "island.top"); + this.setPermission(Constants.PERMPREFIX + "island.top"); this.setDescription("island.top.description"); diff --git a/src/bskyblock/addon/level/database/object/Levels.java b/src/bskyblock/addon/level/database/object/LevelsData.java similarity index 87% rename from src/bskyblock/addon/level/database/object/Levels.java rename to src/bskyblock/addon/level/database/object/LevelsData.java index 9b4e211..0bd79f8 100644 --- a/src/bskyblock/addon/level/database/object/Levels.java +++ b/src/bskyblock/addon/level/database/object/LevelsData.java @@ -2,17 +2,15 @@ package bskyblock.addon.level.database.object; import us.tastybento.bskyblock.database.objects.DataObject; -public class Levels extends DataObject { +public class LevelsData implements DataObject { private String uniqueId = ""; private long level = 0; - @Override public String getUniqueId() { return uniqueId; } - @Override public void setUniqueId(String uniqueId) { this.uniqueId = uniqueId; } diff --git a/src/bskyblock/addon/level/database/object/TopTenList.java b/src/bskyblock/addon/level/database/object/TopTenData.java similarity index 97% rename from src/bskyblock/addon/level/database/object/TopTenList.java rename to src/bskyblock/addon/level/database/object/TopTenData.java index b9ca079..44c3d1e 100644 --- a/src/bskyblock/addon/level/database/object/TopTenList.java +++ b/src/bskyblock/addon/level/database/object/TopTenData.java @@ -13,7 +13,7 @@ import us.tastybento.bskyblock.database.objects.DataObject; * @author ben * */ -public class TopTenList extends DataObject { +public class TopTenData implements DataObject { private String uniqueId = "topten"; private HashMap topTen = new HashMap<>();