diff --git a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java index d9f319ef1..05ac0ad59 100755 --- a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java +++ b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java @@ -63,7 +63,6 @@ public class BSkyBlock extends JavaPlugin { settings = new Settings(); // Load settings from config.yml. This will check if there are any issues with it too. try { - //settings.saveSettings(); settings = settings.loadSettings(); } catch (Exception e) { getLogger().severe("Settings could not be loaded " + e.getMessage()); @@ -282,8 +281,6 @@ public class BSkyBlock extends JavaPlugin { return notifier; } - - /** * @return the headGetter */ diff --git a/src/main/java/us/tastybento/bskyblock/Constants.java b/src/main/java/us/tastybento/bskyblock/Constants.java index f2b12cc68..9ab76eb8e 100644 --- a/src/main/java/us/tastybento/bskyblock/Constants.java +++ b/src/main/java/us/tastybento/bskyblock/Constants.java @@ -1,8 +1,8 @@ package us.tastybento.bskyblock; /** - * All the plugin constants are here - * @author Tastybento + * Contains the plugin constants. + * @author tastybento */ public class Constants { // ----------------- Constants ----------------- @@ -10,17 +10,7 @@ public class Constants { public enum GameType { BSKYBLOCK, ACIDISLAND, BOTH } - /* - public static final GameType GAMETYPE = GameType.ACIDISLAND; - // The spawn command (Essentials spawn for example) - public static final String SPAWNCOMMAND = "spawn"; - // Permission prefix - public static final String PERMPREFIX = "acidisland."; - // The island command - public static final String ISLANDCOMMAND = "ai"; - // Admin command - public static final String ADMINCOMMAND = "acid"; - */ + public static final GameType GAMETYPE = GameType.BSKYBLOCK; // Permission prefix public static final String PERMPREFIX = "bskyblock."; diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java index af1d3dd21..5a211dd1f 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java @@ -404,7 +404,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi if (cmd.hasSubCommmands()) { // Check if subcommands are visible to this sender for (CompositeCommand subCommand: cmd.getSubCommands().values()) { - if ((sender instanceof Player)) { + if (sender instanceof Player) { // Player if (subCommand.getPermission().isEmpty() || sender.hasPermission(subCommand.getPermission())) { // Permission is okay @@ -419,7 +419,8 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi } } } - String lastArg = (args.length != 0 ? args[args.length - 1] : ""); + + String lastArg = args.length != 0 ? args[args.length - 1] : ""; return Util.tabLimit(options, lastArg); } diff --git a/src/main/java/us/tastybento/bskyblock/api/events/PremadeEvent.java b/src/main/java/us/tastybento/bskyblock/api/events/PremadeEvent.java index ab2f46a2e..e1630e52d 100644 --- a/src/main/java/us/tastybento/bskyblock/api/events/PremadeEvent.java +++ b/src/main/java/us/tastybento/bskyblock/api/events/PremadeEvent.java @@ -9,7 +9,7 @@ public abstract class PremadeEvent extends Event { @Override public HandlerList getHandlers() { - return handlers; + return getHandlerList(); } public static HandlerList getHandlerList() { diff --git a/src/main/java/us/tastybento/bskyblock/api/events/acid/EntityDamageByAcidEvent.java b/src/main/java/us/tastybento/bskyblock/api/events/acid/EntityDamageByAcidEvent.java index 1a4365a33..79c25200b 100755 --- a/src/main/java/us/tastybento/bskyblock/api/events/acid/EntityDamageByAcidEvent.java +++ b/src/main/java/us/tastybento/bskyblock/api/events/acid/EntityDamageByAcidEvent.java @@ -14,7 +14,7 @@ public class EntityDamageByAcidEvent extends IslandBaseEvent { private final Entity entity; private double damage; - public enum Acid { RAIN, WATER }; + public enum Acid { RAIN, WATER } private final Acid cause; public EntityDamageByAcidEvent(Island island, Entity entity, double damage, Acid cause) { diff --git a/src/main/java/us/tastybento/bskyblock/api/events/island/IslandEvent.java b/src/main/java/us/tastybento/bskyblock/api/events/island/IslandEvent.java index e0a0f418c..b84be3372 100644 --- a/src/main/java/us/tastybento/bskyblock/api/events/island/IslandEvent.java +++ b/src/main/java/us/tastybento/bskyblock/api/events/island/IslandEvent.java @@ -28,7 +28,7 @@ public class IslandEvent { RESETTED, UNLOCK, UNKNOWN - }; + } public static IslandEventBuilder builder() { return new IslandEventBuilder(); diff --git a/src/main/java/us/tastybento/bskyblock/api/events/team/TeamEvent.java b/src/main/java/us/tastybento/bskyblock/api/events/team/TeamEvent.java index 6a0c8b1ad..be5225beb 100644 --- a/src/main/java/us/tastybento/bskyblock/api/events/team/TeamEvent.java +++ b/src/main/java/us/tastybento/bskyblock/api/events/team/TeamEvent.java @@ -26,7 +26,7 @@ public class TeamEvent { DELETE, UNKNOWN, UNINVITE - }; + } public static TeamEventBuilder builder() { return new TeamEventBuilder(); diff --git a/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java b/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java index d3225e625..1243164e3 100644 --- a/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java +++ b/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java @@ -99,10 +99,8 @@ public class Flag implements Comparable { } else if (!id.equals(other.id)) { return false; } - if (type != other.type) { - return false; - } - return true; + + return type == other.type; } public PanelItem toPanelItem(User user) { diff --git a/src/main/java/us/tastybento/bskyblock/api/panels/PanelItem.java b/src/main/java/us/tastybento/bskyblock/api/panels/PanelItem.java index 3bf0d12e4..a79d1c11b 100644 --- a/src/main/java/us/tastybento/bskyblock/api/panels/PanelItem.java +++ b/src/main/java/us/tastybento/bskyblock/api/panels/PanelItem.java @@ -28,7 +28,6 @@ public class PanelItem { public PanelItem(ItemStack icon, String name, List description, boolean glow, ClickHandler clickHandler, boolean playerHead) { this.icon = icon; this.playerHead = playerHead; - setMeta(); // Get the meta meta = icon.getItemMeta(); @@ -48,11 +47,6 @@ public class PanelItem { icon.setItemMeta(meta); } - private void setMeta() { - // TODO Auto-generated method stub - - } - public ItemStack getItem() { return icon; } @@ -117,7 +111,6 @@ public class PanelItem { public void setHead(ItemStack itemStack) { this.icon = itemStack; - setMeta(); // Get the meta meta = icon.getItemMeta(); // Create the final item diff --git a/src/main/java/us/tastybento/bskyblock/api/user/Notifier.java b/src/main/java/us/tastybento/bskyblock/api/user/Notifier.java index 7e8b02fdb..853aa838d 100644 --- a/src/main/java/us/tastybento/bskyblock/api/user/Notifier.java +++ b/src/main/java/us/tastybento/bskyblock/api/user/Notifier.java @@ -16,7 +16,7 @@ public class Notifier { /** * Time in seconds before {@link #notificationCache} removes the entry related to the player. */ - private final int NOTIFICATION_DELAY = 5; + private static final int NOTIFICATION_DELAY = 5; private final LoadingCache notificationCache = CacheBuilder.newBuilder() .expireAfterAccess(NOTIFICATION_DELAY, TimeUnit.SECONDS) diff --git a/src/main/java/us/tastybento/bskyblock/database/AbstractDatabaseHandler.java b/src/main/java/us/tastybento/bskyblock/database/AbstractDatabaseHandler.java index 4920c105b..25a4c11cc 100644 --- a/src/main/java/us/tastybento/bskyblock/database/AbstractDatabaseHandler.java +++ b/src/main/java/us/tastybento/bskyblock/database/AbstractDatabaseHandler.java @@ -50,7 +50,7 @@ public abstract class AbstractDatabaseHandler { * Loads all the records in this table and returns a list of them * @return list of */ - public abstract List loadObjects() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IntrospectionException; + public abstract List loadObjects() throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException; /** * Creates a filled with values from the corresponding @@ -58,20 +58,20 @@ public abstract class AbstractDatabaseHandler { * @param uniqueId - unique ID * @return */ - public abstract T loadObject(String uniqueId) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IntrospectionException; + public abstract T loadObject(String uniqueId) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException; /** * Save T into the corresponding database * * @param instance that should be inserted into the database */ - public abstract void saveObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException ; + public abstract void saveObject(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException ; /** * Deletes the object with the unique id from the database * @param instance */ - public abstract void deleteObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException ; + public abstract void deleteObject(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException ; /** * Checks if a key exists or not diff --git a/src/main/java/us/tastybento/bskyblock/database/flatfile/ConfigHandler.java b/src/main/java/us/tastybento/bskyblock/database/flatfile/ConfigHandler.java index 45dfd67a6..505657ec1 100644 --- a/src/main/java/us/tastybento/bskyblock/database/flatfile/ConfigHandler.java +++ b/src/main/java/us/tastybento/bskyblock/database/flatfile/ConfigHandler.java @@ -21,12 +21,12 @@ public class ConfigHandler extends FlatFileDatabaseHandler { super(plugin, type, databaseConnecter); } - public void saveSettings(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException { + public void saveSettings(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException { configFlag = true; saveObject(instance); } - public T loadSettings(String uniqueId, T dbConfig) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IntrospectionException { + public T loadSettings(String uniqueId, T dbConfig) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException { if (dbConfig == null) { return loadObject(uniqueId); } diff --git a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabase.java b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabase.java index b158cfdf1..86bfba544 100755 --- a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabase.java +++ b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabase.java @@ -8,7 +8,7 @@ public class FlatFileDatabase extends BSBDbSetup{ @Override public AbstractDatabaseHandler getHandler(Class type) { - return new FlatFileDatabaseHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance(), null)); + return new FlatFileDatabaseHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance())); } /** @@ -17,7 +17,7 @@ public class FlatFileDatabase extends BSBDbSetup{ * @return - the config handler */ public AbstractDatabaseHandler getConfig(Class type) { - return new ConfigHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance(), null)); + return new ConfigHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance())); } } diff --git a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseConnecter.java b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseConnecter.java index e5b4aa55a..44726f46a 100644 --- a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseConnecter.java +++ b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseConnecter.java @@ -27,7 +27,7 @@ public class FlatFileDatabaseConnecter implements DatabaseConnecter { private File dataFolder; - public FlatFileDatabaseConnecter(Plugin plugin, DatabaseConnectionSettingsImpl databaseConnectionSettingsImpl) { + public FlatFileDatabaseConnecter(Plugin plugin) { this.plugin = plugin; dataFolder = new File(plugin.getDataFolder(), DATABASE_FOLDER_NAME); } diff --git a/src/main/java/us/tastybento/bskyblock/database/objects/Island.java b/src/main/java/us/tastybento/bskyblock/database/objects/Island.java index 6e67e129d..93fda515a 100755 --- a/src/main/java/us/tastybento/bskyblock/database/objects/Island.java +++ b/src/main/java/us/tastybento/bskyblock/database/objects/Island.java @@ -194,13 +194,6 @@ public class Island implements DataObject { return levelHandicap; } - /** - * @return true if the island is locked, otherwise false - */ - public boolean getLocked(){ - return locked; - } - /** * @return the members */ @@ -294,13 +287,6 @@ public class Island implements DataObject { return members.getOrDefault(user.getUniqueId(), RanksManager.VISITOR_RANK); } - /** - * @return true if the island is the spawn otherwise false - */ - public boolean getSpawn(){ - return spawn; - } - public Location getSpawnPoint() { return spawnPoint; } @@ -326,10 +312,8 @@ public class Island implements DataObject { if (holder.getType().equals(Material.BURNING_FURNACE)) { result++; } - } else if (material.toString().endsWith("BANNER")) { - if (holder.getType().toString().endsWith("BANNER")) { - result++; - } + } else if (material.toString().endsWith("BANNER") && holder.getType().toString().endsWith("BANNER")) { + result++; } else if (material.equals(Material.WALL_SIGN) || material.equals(Material.SIGN_POST)) { if (holder.getType().equals(Material.WALL_SIGN) || holder.getType().equals(Material.SIGN_POST)) { result++; @@ -519,9 +503,7 @@ public class Island implements DataObject { * Resets the flags to their default as set in config.yml for this island */ public void setFlagsDefaults(){ - /*for(SettingsFlag flag : SettingsFlag.values()){ - this.flags.put(flag, Settings.defaultIslandSettings.get(flag)); - }*/ //TODO default flags + //TODO default flags } /** @@ -650,9 +632,7 @@ public class Island implements DataObject { * Resets the flags to their default as set in config.yml for the spawn */ public void setSpawnFlagsDefaults(){ - /*for(SettingsFlag flag : SettingsFlag.values()){ - this.flags.put(flag, Settings.defaultSpawnSettings.get(flag)); - }*/ //TODO default flags + //TODO default flags } public void setSpawnPoint(Location location) { diff --git a/src/main/java/us/tastybento/bskyblock/database/objects/Players.java b/src/main/java/us/tastybento/bskyblock/database/objects/Players.java index 86f3bb177..83d2a9cda 100755 --- a/src/main/java/us/tastybento/bskyblock/database/objects/Players.java +++ b/src/main/java/us/tastybento/bskyblock/database/objects/Players.java @@ -232,7 +232,6 @@ public class Players implements DataObject { Date kickedDate = new Date(kickedList.get(location)); Calendar coolDownTime = Calendar.getInstance(); coolDownTime.setTime(kickedDate); - // coolDownTime.add(Calendar.HOUR_OF_DAY, Settings.inviteWait); coolDownTime.add(Calendar.MINUTE, getPlugin().getSettings().getInviteWait()); // Add the invite cooldown period Calendar timeNow = Calendar.getInstance(); diff --git a/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java b/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java index c6a6ccc82..b551194e7 100644 --- a/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java +++ b/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java @@ -40,13 +40,13 @@ public class IslandBuilder { private Island island; private World world; private IslandType type = IslandType.ISLAND; - //private List companionNames = new ArrayList<>(); private List chestItems; - //private List companions = new ArrayList<>(); private UUID playerUUID; private String playerName; private BSkyBlock plugin; + //TODO support companions? + public IslandBuilder(BSkyBlock plugin, Island island) { this.plugin = plugin; this.island = island; @@ -208,8 +208,6 @@ public class IslandBuilder { // Add tree (natural) Location treeLoc = new Location(world, x, y + 5D, z); world.generateTree(treeLoc, TreeType.ACACIA); - // Place the cow - //Location location = new Location(world, x, (islandHeight + 5), z - 2); // Place a helpful sign in front of player placeSign(x, islandHeight + 5, z + 3); @@ -295,8 +293,6 @@ public class IslandBuilder { // Add tree (natural) Location treeLoc = new Location(world, x, y + 5D, z); world.generateTree(treeLoc, TreeType.TREE); - // Place the cow - //Location location = new Location(world, x, (islandHeight + 5), z - 2); // Place a helpful sign in front of player placeSign(x, islandHeight + 5, z + 3); @@ -373,18 +369,11 @@ public class IslandBuilder { // Add island items y = islandHeight; - // Add tree (natural) - Location treeLoc = new Location(world, x, y + 5D, z); - treeLoc.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT); - world.generateTree(treeLoc, TreeType.TREE); - // Place the cow - //Location location = new Location(world, x, (islandHeight + 5), z - 2); // Place a helpful sign in front of player placeSign(x, islandHeight + 5, z + 3); // Place the chest - no need to use the safe spawn function - // because we - // know what this island looks like + // because we know what this island looks like placeChest(x, islandHeight + 5, z + 1); } @@ -456,12 +445,8 @@ public class IslandBuilder { // Add island items y = islandHeight; - // Add tree (natural) - Location treeLoc = new Location(world, x, y + 5D, z); - world.spawnEntity(treeLoc, EntityType.ENDER_CRYSTAL); - //world.generateTree(treeLoc, TreeType.TREE); - // Place the cow - //Location location = new Location(world, x, (islandHeight + 5), z - 2); + // Spawn an ender crystal + world.spawnEntity(new Location(world, x, y + 5D, z), EntityType.ENDER_CRYSTAL); // Place a helpful sign in front of player placeSign(x, islandHeight + 5, z + 3); diff --git a/src/main/java/us/tastybento/bskyblock/listeners/ObsidianToLava.java b/src/main/java/us/tastybento/bskyblock/listeners/ObsidianToLava.java index 960b3fbfc..399dae64e 100644 --- a/src/main/java/us/tastybento/bskyblock/listeners/ObsidianToLava.java +++ b/src/main/java/us/tastybento/bskyblock/listeners/ObsidianToLava.java @@ -16,6 +16,9 @@ import org.bukkit.event.player.PlayerInteractEvent; import us.tastybento.bskyblock.BSkyBlock; import us.tastybento.bskyblock.api.user.User; +import java.util.ArrayList; +import java.util.List; + /** * Enables changing of obsidian back into lava * @author tastybento @@ -25,7 +28,6 @@ public class ObsidianToLava implements Listener { private BSkyBlock plugin; - /** * @param plugin */ @@ -33,7 +35,6 @@ public class ObsidianToLava implements Listener { this.plugin = plugin; } - /** * Enables changing of obsidian back into lava * @@ -54,18 +55,14 @@ public class ObsidianToLava implements Listener { if (plugin.getIslands().playerIsOnIsland(user)) { // Look around to see if this is a lone obsidian block Block b = e.getClickedBlock(); - for (int x = -2; x <= 2; x++) { - for (int y = -2; y <= 2; y++) { - for (int z = -2; z <= 2; z++) { - Material testBlock = b.getWorld().getBlockAt(b.getX() + x, b.getY() + y, b.getZ() + z).getType(); - if ((x != 0 || y != 0 || z != 0) && testBlock.equals(Material.OBSIDIAN)) { - // Do nothing special - return false; - } - } + for (Block testBlock : getBlocksAround(b)) { + if (testBlock.getType().equals(Material.OBSIDIAN)) { + // Do nothing special + return false; } } + user.sendMessage("general.tips.changing-ob-to-lava"); e.getItem().setType(Material.LAVA_BUCKET); e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.ITEM_BUCKET_FILL_LAVA, 1F, 1F); @@ -76,4 +73,20 @@ public class ObsidianToLava implements Listener { return false; } + + private List getBlocksAround(Block b) { + List blocksAround = new ArrayList<>(); + for (int x = -2; x <= 2; x++) { + for (int y = -2; y <= 2; y++) { + for (int z = -2; z <= 2; z++) { + blocksAround.add(b.getWorld().getBlockAt(b.getX() + x, b.getY() + y, b.getZ() + z)); + } + } + } + + // Remove the block at x = 0, y = 0 and z = 0 (which is the base block) + blocksAround.remove(b); + + return blocksAround; + } } diff --git a/src/main/java/us/tastybento/bskyblock/listeners/protection/FlyingMobEvents.java b/src/main/java/us/tastybento/bskyblock/listeners/protection/FlyingMobEvents.java index 31a9fb042..e438165b3 100644 --- a/src/main/java/us/tastybento/bskyblock/listeners/protection/FlyingMobEvents.java +++ b/src/main/java/us/tastybento/bskyblock/listeners/protection/FlyingMobEvents.java @@ -68,7 +68,7 @@ public class FlyingMobEvents implements Listener { * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void mobSpawn(CreatureSpawnEvent e) { + public void onMobSpawn(CreatureSpawnEvent e) { // Only cover withers in the island world if (!Util.inWorld(e.getEntity())) { return; @@ -81,7 +81,7 @@ public class FlyingMobEvents implements Listener { } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void mobExplosion(EntityExplodeEvent e) { + public void onMobExplosion(EntityExplodeEvent e) { // Only cover in the island world if (e.getEntity() == null || !Util.inWorld(e.getEntity())) { return; @@ -100,7 +100,7 @@ public class FlyingMobEvents implements Listener { * Deal with pre-explosions */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void witherExplode(ExplosionPrimeEvent e) { + public void onWitherExplode(ExplosionPrimeEvent e) { // Only cover withers in the island world if (!Util.inWorld(e.getEntity()) || e.getEntity() == null) { return; @@ -115,7 +115,6 @@ public class FlyingMobEvents implements Listener { e.setCancelled(true); } } - // Testing only e.setCancelled(true); } if (e.getEntityType() == EntityType.WITHER_SKULL) { // Get shooter @@ -140,7 +139,7 @@ public class FlyingMobEvents implements Listener { * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void witherChangeBlocks(EntityChangeBlockEvent e) { + public void onWitherChangeBlocks(EntityChangeBlockEvent e) { // Only cover withers in the island world if (e.getEntityType() != EntityType.WITHER || !Util.inWorld(e.getEntity()) ) { return; @@ -158,7 +157,7 @@ public class FlyingMobEvents implements Listener { * Clean up the hashmap. It's probably not needed, but just in case. */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void mobDeath(EntityDeathEvent e) { + public void onMobDeath(EntityDeathEvent e) { mobSpawnInfo.remove(e.getEntity()); } } \ No newline at end of file diff --git a/src/main/java/us/tastybento/bskyblock/managers/AddonsManager.java b/src/main/java/us/tastybento/bskyblock/managers/AddonsManager.java index 45c38bf18..0604c46ca 100644 --- a/src/main/java/us/tastybento/bskyblock/managers/AddonsManager.java +++ b/src/main/java/us/tastybento/bskyblock/managers/AddonsManager.java @@ -117,12 +117,12 @@ public final class AddonsManager { YamlConfiguration data = new YamlConfiguration(); data.load(reader); // Load the addon - AddonClassLoader loader = new AddonClassLoader(this, data, f, this.getClass().getClassLoader()); + AddonClassLoader addonClassLoader = new AddonClassLoader(this, data, f, this.getClass().getClassLoader()); // Add to the list of loaders - this.loader.add(loader); + loader.add(addonClassLoader); // Get the addon itself - addon = loader.getAddon(); + addon = addonClassLoader.getAddon(); // Initialize some settings addon.setDataFolder(new File(f.getParent(), addon.getDescription().getName())); addon.setAddonFile(f); @@ -163,12 +163,12 @@ public final class AddonsManager { addons.forEach(addon -> { addon.onDisable(); Bukkit.getPluginManager().callEvent(AddonEvent.builder().addon(addon).reason(AddonEvent.Reason.DISABLE).build()); - System.out.println("Disabling " + addon.getDescription().getName() + "..."); + plugin.getLogger().info("Disabling " + addon.getDescription().getName() + "..."); }); - loader.forEach(loader -> { + loader.forEach(l -> { try { - loader.close(); + l.close(); } catch (IOException e) { // Do nothing } @@ -187,7 +187,6 @@ public final class AddonsManager { this.loader = loader; } - /** * Finds a class by name that has been loaded by this loader * Code copied from Bukkit JavaPluginLoader @@ -200,9 +199,9 @@ public final class AddonsManager { if (cachedClass != null) { return cachedClass; } else { - for (AddonClassLoader loader : loader) { + for (AddonClassLoader l : loader) { try { - cachedClass = loader.findClass(name, false); + cachedClass = l.findClass(name, false); } catch (ClassNotFoundException cnfe) {} if (cachedClass != null) { return cachedClass; @@ -237,7 +236,7 @@ public final class AddonsManager { * @return a list of files - if the file cannot be read */ - public List listJarYamlFiles(JarFile jar, String folderPath) throws IOException { + public List listJarYamlFiles(JarFile jar, String folderPath) { List result = new ArrayList<>(); /** diff --git a/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java b/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java index f03448cd3..d781a9212 100644 --- a/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java +++ b/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java @@ -727,14 +727,12 @@ public class IslandsManager { homeTeleport(player); } else { // Move player to spawn - Island spawn = getSpawn(); if (spawn != null) { // go to island spawn player.teleport(plugin.getIslandWorldManager().getIslandWorld().getSpawnLocation()); } else { if (!player.performCommand(Constants.SPAWNCOMMAND)) { - plugin.getLogger().warning(()-> - "During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry."); + plugin.getLogger().warning(()-> "During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry."); } } } diff --git a/src/main/java/us/tastybento/bskyblock/managers/LocalesManager.java b/src/main/java/us/tastybento/bskyblock/managers/LocalesManager.java index 14af34edd..327563724 100644 --- a/src/main/java/us/tastybento/bskyblock/managers/LocalesManager.java +++ b/src/main/java/us/tastybento/bskyblock/managers/LocalesManager.java @@ -59,10 +59,7 @@ public class LocalesManager { // Describe the filter - we only want files that are correctly named FilenameFilter ymlFilter = (dir, name) -> { // Files must be 9 chars long - if (name.toLowerCase().endsWith(".yml") && name.length() == 9) { - return true; - } - return false; + return name.toLowerCase().endsWith(".yml") && name.length() == 9; }; // Run through the files and store the locales diff --git a/src/main/java/us/tastybento/bskyblock/util/teleport/SafeSpotTeleport.java b/src/main/java/us/tastybento/bskyblock/util/teleport/SafeSpotTeleport.java index b9eaf8159..02e574d48 100644 --- a/src/main/java/us/tastybento/bskyblock/util/teleport/SafeSpotTeleport.java +++ b/src/main/java/us/tastybento/bskyblock/util/teleport/SafeSpotTeleport.java @@ -74,29 +74,24 @@ public class SafeSpotTeleport { checking = true; // Start a recurring task until done or cancelled - task = plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() { - - @Override - public void run() { - List chunkSnapshot = new ArrayList<>(); - if (checking) { - Iterator> it = chunksToScan.iterator(); - if (!it.hasNext()) { - // Nothing left - tidyUp(entity, failureMessage); - return; - } - // Add chunk snapshots to the list - while (it.hasNext() && chunkSnapshot.size() < MAX_CHUNKS) { - Pair pair = it.next(); - chunkSnapshot.add(location.getWorld().getChunkAt(pair.x, pair.z).getChunkSnapshot()); - it.remove(); - } - // Move to next step - checking = false; - checkChunks(chunkSnapshot); + task = plugin.getServer().getScheduler().runTaskTimer(plugin, () -> { + List chunkSnapshot = new ArrayList<>(); + if (checking) { + Iterator> it = chunksToScan.iterator(); + if (!it.hasNext()) { + // Nothing left + tidyUp(entity, failureMessage); + return; } - + // Add chunk snapshots to the list + while (it.hasNext() && chunkSnapshot.size() < MAX_CHUNKS) { + Pair pair = it.next(); + chunkSnapshot.add(location.getWorld().getChunkAt(pair.x, pair.z).getChunkSnapshot()); + it.remove(); + } + // Move to next step + checking = false; + checkChunks(chunkSnapshot); } }, 0L, SPEED); } @@ -119,8 +114,6 @@ public class SafeSpotTeleport { /** * Gets a set of chunk coords that will be scanned. - * @param entity - * @param location - the location * @return */ private List> getChunksToScan() {