diff --git a/src/main/java/me/goodandevil/skyblock/api/island/IslandManager.java b/src/main/java/me/goodandevil/skyblock/api/island/IslandManager.java index bbc85962..411a0f11 100644 --- a/src/main/java/me/goodandevil/skyblock/api/island/IslandManager.java +++ b/src/main/java/me/goodandevil/skyblock/api/island/IslandManager.java @@ -1,19 +1,17 @@ package me.goodandevil.skyblock.api.island; +import com.google.common.base.Preconditions; +import me.goodandevil.skyblock.api.structure.Structure; +import me.goodandevil.skyblock.api.utils.APIUtil; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.UUID; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - -import com.google.common.base.Preconditions; - -import me.goodandevil.skyblock.api.structure.Structure; -import me.goodandevil.skyblock.api.utils.APIUtil; - public class IslandManager { private final me.goodandevil.skyblock.island.IslandManager islandManager; @@ -134,31 +132,58 @@ public class IslandManager { /** * Gives the Island Upgrades to a player + * + * @deprecated use {@link #updateFlight(Player)} instead */ + @Deprecated public void giveUgrades(Player player, Island island) { Preconditions.checkArgument(player != null, "Cannot give upgrades to null player"); Preconditions.checkArgument(island != null, "Cannot give upgrades to null island"); - this.islandManager.giveUpgrades(player, island.getIsland()); + this.islandManager.updateFlight(player); } /** * Gives Fly to a player if they have permission at an Island + * + * @deprecated use {@link #updateFlight(Player)} instead */ + @Deprecated public void giveFly(Player player, Island island) { Preconditions.checkArgument(player != null, "Cannot give upgrades to null player"); Preconditions.checkArgument(island != null, "Cannot give upgrades to null island"); - this.islandManager.giveFly(player, island.getIsland()); + this.islandManager.updateFlight(player); } /** * Removes the Island Upgrades from a player + * + * @deprecated use {@link #updateFlight(Player)} instead */ + @Deprecated public void removeUpgrades(Player player) { Preconditions.checkArgument(player != null, "Cannot remove upgrades to null player"); - this.islandManager.removeUpgrades(player, false); + this.islandManager.updateFlight(player); + } + + /** + * Updates the flight of a player based on their permissions and current island upgrades + */ + public void updateFlight(Player player) { + Preconditions.checkArgument(player != null, "Cannot update flight of a null player"); + + this.islandManager.updateFlight(player); + } + + /** + * Updates the flight of all players on an island based on their permissions and island upgrades + */ + public void updateFlightAtIsland(Island island) { + Preconditions.checkArgument(island != null, "Cannot update flight of a null island"); + + this.islandManager.updateFlightAtIsland(island.getIsland()); } /** diff --git a/src/main/java/me/goodandevil/skyblock/island/IslandManager.java b/src/main/java/me/goodandevil/skyblock/island/IslandManager.java index b34a797d..af6cf671 100644 --- a/src/main/java/me/goodandevil/skyblock/island/IslandManager.java +++ b/src/main/java/me/goodandevil/skyblock/island/IslandManager.java @@ -1,35 +1,8 @@ package me.goodandevil.skyblock.island; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.IllegalPluginAccessException; - import com.google.common.base.Preconditions; - import me.goodandevil.skyblock.SkyBlock; -import me.goodandevil.skyblock.api.event.island.IslandCreateEvent; -import me.goodandevil.skyblock.api.event.island.IslandDeleteEvent; -import me.goodandevil.skyblock.api.event.island.IslandLoadEvent; -import me.goodandevil.skyblock.api.event.island.IslandOwnershipTransferEvent; -import me.goodandevil.skyblock.api.event.island.IslandUnloadEvent; +import me.goodandevil.skyblock.api.event.island.*; import me.goodandevil.skyblock.ban.BanManager; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; @@ -58,6 +31,21 @@ import me.goodandevil.skyblock.utils.world.WorldBorder; import me.goodandevil.skyblock.utils.world.block.BlockDegreesType; import me.goodandevil.skyblock.visit.VisitManager; import me.goodandevil.skyblock.world.WorldManager; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.Biome; +import org.bukkit.block.Block; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.IllegalPluginAccessException; + +import java.io.File; +import java.io.IOException; +import java.util.*; public class IslandManager { @@ -245,7 +233,7 @@ public class IslandManager { player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); player.setFallDistance(0.0F); }); - + String biomeName = fileManager .getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getString("Island.Biome.Default.Type").toUpperCase(); @@ -256,7 +244,7 @@ public class IslandManager { sBiome = SBiome.PLAINS; } Biome biome = sBiome.getBiome(); - + Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getBiomeManager() .setBiome(island, biome), 20L); @@ -720,12 +708,7 @@ public class IslandManager { if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Spawn.Protection")) { - Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() { - @Override - public void run() { - islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE); - } - }); + Bukkit.getServer().getScheduler().runTask(skyblock, () -> islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE)); } try { @@ -832,12 +815,9 @@ public class IslandManager { } } - Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() { - @Override - public void run() { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - player.setFallDistance(0.0F); - } + Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); + player.setFallDistance(0.0F); }); List islandWelcomeMessage = island.getMessage(IslandMessage.Welcome); @@ -884,9 +864,9 @@ public class IslandManager { public Island getIsland(org.bukkit.OfflinePlayer offlinePlayer) { PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - + // TODO: Find out how this can be fixed without this, for some reason IslandManager tries to load PlayerDataManager before it's even loaded - if (playerDataManager == null) return null; + if (playerDataManager == null) return null; if (islandStorage.containsKey(offlinePlayer.getUniqueId())) { return islandStorage.get(offlinePlayer.getUniqueId()); @@ -976,14 +956,10 @@ public class IslandManager { public boolean hasSetting(org.bukkit.Location location, IslandRole role, String setting) { Island island = getIslandAtLocation(location); + if (island == null) + return false; - if (island != null) { - if (island.getSetting(role, setting).getStatus()) { - return true; - } - } - - return false; + return island.getSetting(role, setting).getStatus(); } public void removeSpawnProtection(org.bukkit.Location location) { @@ -1078,106 +1054,72 @@ public class IslandManager { public void loadPlayer(Player player) { WorldManager worldManager = skyblock.getWorldManager(); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, new Runnable() { - @Override - public void run() { - if (worldManager.isIslandWorld(player.getWorld())) { - IslandWorld world = worldManager.getIslandWorld(player.getWorld()); - Island island = getIslandAtLocation(player.getLocation()); + Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + if (worldManager.isIslandWorld(player.getWorld())) { + IslandWorld world = worldManager.getIslandWorld(player.getWorld()); + Island island = getIslandAtLocation(player.getLocation()); - if (island != null) { - Config config = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); + if (island != null) { + Config config = skyblock.getFileManager() + .getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); - if (!island.isWeatherSynchronized()) { - player.setPlayerTime(island.getTime(), configLoad.getBoolean("Island.Weather.Time.Cycle")); - player.setPlayerWeather(island.getWeather()); + if (!island.isWeatherSynchronized()) { + player.setPlayerTime(island.getTime(), configLoad.getBoolean("Island.Weather.Time.Cycle")); + player.setPlayerWeather(island.getWeather()); + } + + updateFlight(player); + + if (world == IslandWorld.Nether) { + if (NMSUtil.getVersionNumber() < 13) { + return; } + } - giveUpgrades(player, island); - giveFly(player, island); - - if (world == IslandWorld.Nether) { - if (NMSUtil.getVersionNumber() < 13) { - return; - } - } - - if (configLoad.getBoolean("Island.WorldBorder.Enable") && island.isBorder()) { - WorldBorder.send(player, island.getBorderColor(), island.getSize() + 2.5, - island.getLocation(worldManager.getIslandWorld(player.getWorld()), - IslandEnvironment.Island)); - } else { - WorldBorder.send(player, null, 1.4999992E7D, - new org.bukkit.Location(player.getWorld(), 0, 0, 0)); - } - - return; + if (configLoad.getBoolean("Island.WorldBorder.Enable") && island.isBorder()) { + WorldBorder.send(player, island.getBorderColor(), island.getSize() + 2.5, + island.getLocation(worldManager.getIslandWorld(player.getWorld()), + IslandEnvironment.Island)); + } else { + WorldBorder.send(player, null, 1.4999992E7D, + new org.bukkit.Location(player.getWorld(), 0, 0, 0)); } } } }); } - public void giveUpgrades(Player player, Island island) { - UpgradeManager upgradeManager = skyblock.getUpgradeManager(); + public void updateFlightAtIsland(Island island) { + for (Player player : getPlayersAtIsland(island)) + this.updateFlight(player); + } + public void updateFlight(Player player) { + if (player.getGameMode() == GameMode.CREATIVE) + return; + + Island island = getIslandAtLocation(player.getLocation()); + + UpgradeManager upgradeManager = skyblock.getUpgradeManager(); List flyUpgrades = upgradeManager.getUpgrades(Upgrade.Type.Fly); - if (flyUpgrades != null && flyUpgrades.size() > 0 && flyUpgrades.get(0).isEnabled() && island.isUpgrade(Upgrade.Type.Fly) && player.getGameMode() != GameMode.CREATIVE) { - Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() { - @Override - public void run() { - player.setAllowFlight(true); - player.setFlying(true); - } + boolean isFlyUpgradeEnabled = flyUpgrades != null && flyUpgrades.size() > 0 && flyUpgrades.get(0).isEnabled(); + boolean setPlayerFlying = false; + if (isFlyUpgradeEnabled) { + boolean upgradeEnabled = island != null && island.isUpgrade(Upgrade.Type.Fly); + setPlayerFlying = upgradeEnabled; + Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + player.setAllowFlight(upgradeEnabled); }); } - } - - public void giveFly(Player player, Island island) { - if (island.hasRole(IslandRole.Member, player.getUniqueId()) - || island.hasRole(IslandRole.Operator, player.getUniqueId()) - || island.hasRole(IslandRole.Operator, player.getUniqueId())) { - if (player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.fly") - || player.hasPermission("fabledskyblock.*")) { - Bukkit.getServer().getScheduler().runTask(skyblock, () -> { - player.setAllowFlight(true); - player.setFlying(true); - }); - } - return; - } - if (player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.*")) { - Bukkit.getServer().getScheduler().runTask(skyblock, () -> { - player.setAllowFlight(true); - player.setFlying(true); - }); - } - } - - public void removeUpgrades(Player player, boolean bypassIsland) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - - if (!bypassIsland && playerDataManager.hasPlayerData(player)) { - PlayerData playerData = playerDataManager.getPlayerData(player); - - if (playerData.getIsland() != null) { - org.bukkit.OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(playerData.getIsland()); - Island island = getIsland(offlinePlayer); - - if (island != null) { - if (isPlayerAtIsland(island, player)) { - return; - } - } - } - } - - if (player.getGameMode() != GameMode.CREATIVE) { - player.setFlying(false); - player.setAllowFlight(false); + boolean hasFlyPermission = player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.*"); + if (hasFlyPermission && island != null && !setPlayerFlying) { + WorldManager worldManager = skyblock.getWorldManager(); + boolean canFlyInWorld = worldManager.isIslandWorld(player.getWorld()); + Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + player.setAllowFlight(canFlyInWorld); + }); } } @@ -1294,7 +1236,7 @@ public class IslandManager { } public List getCoopIslands(Player player) { - List islands = new ArrayList(); + List islands = new ArrayList<>(); for (UUID islandList : getIslands().keySet()) { Island island = getIslands().get(islandList); @@ -1338,12 +1280,6 @@ public class IslandManager { } public boolean isLocationAtIsland(Island island, org.bukkit.Location location, IslandWorld world) { - - if (LocationUtil.isLocationAtLocationRadius(location, island.getLocation(world, IslandEnvironment.Island), - island.getRadius())) { - return true; - } - - return false; + return LocationUtil.isLocationAtLocationRadius(location, island.getLocation(world, IslandEnvironment.Island), island.getRadius()); } } diff --git a/src/main/java/me/goodandevil/skyblock/listeners/Move.java b/src/main/java/me/goodandevil/skyblock/listeners/Move.java index c5d16a46..e88dd1b8 100644 --- a/src/main/java/me/goodandevil/skyblock/listeners/Move.java +++ b/src/main/java/me/goodandevil/skyblock/listeners/Move.java @@ -102,7 +102,6 @@ public class Move implements Listener { if (island != null) { - islandManager.removeUpgrades(player, false); if (islandManager.isLocationAtIsland(island, to)) { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -110,15 +109,9 @@ public class Move implements Listener { boolean keepItemsOnDeath; if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) { - if (island.getSetting(IslandRole.Owner, "KeepItemsOnDeath").getStatus()) { - keepItemsOnDeath = true; - } else { - keepItemsOnDeath = false; - } - } else if (configLoad.getBoolean("Island.KeepItemsOnDeath.Enable")) { - keepItemsOnDeath = true; + keepItemsOnDeath = island.getSetting(IslandRole.Owner, "KeepItemsOnDeath").getStatus(); } else { - keepItemsOnDeath = false; + keepItemsOnDeath = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable"); } if (configLoad.getBoolean("Island.World." + world.name() + ".Liquid.Enable")) { diff --git a/src/main/java/me/goodandevil/skyblock/listeners/Respawn.java b/src/main/java/me/goodandevil/skyblock/listeners/Respawn.java index 29decfa5..6ddb110c 100644 --- a/src/main/java/me/goodandevil/skyblock/listeners/Respawn.java +++ b/src/main/java/me/goodandevil/skyblock/listeners/Respawn.java @@ -1,8 +1,10 @@ package me.goodandevil.skyblock.listeners; -import java.io.File; -import java.util.logging.Level; - +import me.goodandevil.skyblock.SkyBlock; +import me.goodandevil.skyblock.config.FileManager; +import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.island.*; +import me.goodandevil.skyblock.world.WorldManager; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; @@ -12,15 +14,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import me.goodandevil.skyblock.SkyBlock; -import me.goodandevil.skyblock.config.FileManager; -import me.goodandevil.skyblock.config.FileManager.Config; -import me.goodandevil.skyblock.island.Island; -import me.goodandevil.skyblock.island.IslandEnvironment; -import me.goodandevil.skyblock.island.IslandManager; -import me.goodandevil.skyblock.island.IslandRole; -import me.goodandevil.skyblock.island.IslandWorld; -import me.goodandevil.skyblock.world.WorldManager; +import java.io.File; +import java.util.logging.Level; public class Respawn implements Listener { @@ -61,8 +56,7 @@ public class Respawn implements Listener { .callEvent(new PlayerTeleportEvent(player, playerLocation, islandLocation)); event.setRespawnLocation(islandLocation); - islandManager.giveUpgrades(player, island); - islandManager.giveFly(player, island); + islandManager.updateFlight(player); return; } diff --git a/src/main/java/me/goodandevil/skyblock/listeners/Teleport.java b/src/main/java/me/goodandevil/skyblock/listeners/Teleport.java index 901e3687..1967e630 100644 --- a/src/main/java/me/goodandevil/skyblock/listeners/Teleport.java +++ b/src/main/java/me/goodandevil/skyblock/listeners/Teleport.java @@ -1,17 +1,5 @@ package me.goodandevil.skyblock.listeners; -import java.io.File; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - import me.goodandevil.skyblock.SkyBlock; import me.goodandevil.skyblock.api.event.player.PlayerIslandEnterEvent; import me.goodandevil.skyblock.api.event.player.PlayerIslandExitEvent; @@ -29,6 +17,17 @@ import me.goodandevil.skyblock.utils.version.NMSUtil; import me.goodandevil.skyblock.utils.version.Sounds; import me.goodandevil.skyblock.visit.Visit; import me.goodandevil.skyblock.world.WorldManager; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; + +import java.io.File; +import java.util.UUID; public class Teleport implements Listener { @@ -51,8 +50,8 @@ public class Teleport implements Listener { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - - islandManager.removeUpgrades(player, true); + + Bukkit.getScheduler().runTaskLater(skyblock, () -> islandManager.updateFlight(player), 1L); islandManager.loadPlayer(player); if (worldManager.isIslandWorld(player.getWorld())) { @@ -85,7 +84,6 @@ public class Teleport implements Listener { Island island = islandManager.getIslandAtLocation(event.getTo()); if (island != null) { - islandManager.giveUpgrades(player, island); if (!island.getOwnerUUID().equals(playerData.getOwner())) { if (!player.hasPermission("fabledskyblock.bypass") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) { diff --git a/src/main/java/me/goodandevil/skyblock/menus/Upgrade.java b/src/main/java/me/goodandevil/skyblock/menus/Upgrade.java index 42359cc8..dec0ce8a 100644 --- a/src/main/java/me/goodandevil/skyblock/menus/Upgrade.java +++ b/src/main/java/me/goodandevil/skyblock/menus/Upgrade.java @@ -1,22 +1,5 @@ package me.goodandevil.skyblock.menus; -import java.io.File; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.potion.PotionType; - import me.goodandevil.skyblock.SkyBlock; import me.goodandevil.skyblock.api.event.island.IslandUpgradeEvent; import me.goodandevil.skyblock.api.utils.APIUtil; @@ -37,6 +20,21 @@ import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler; import me.goodandevil.skyblock.utils.version.Materials; import me.goodandevil.skyblock.utils.version.NMSUtil; import me.goodandevil.skyblock.utils.version.Sounds; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; + +import java.io.File; +import java.util.List; public class Upgrade { @@ -294,20 +292,10 @@ public class Upgrade { if (island.hasUpgrade(me.goodandevil.skyblock.upgrade.Upgrade.Type.Fly)) { if (island.isUpgrade(me.goodandevil.skyblock.upgrade.Upgrade.Type.Fly)) { island.setUpgrade(player, me.goodandevil.skyblock.upgrade.Upgrade.Type.Fly, false); - - for (Player all : islandManager.getPlayersAtIsland(island)) { - if (all.getGameMode() != GameMode.CREATIVE) { - all.setFlying(false); - all.setAllowFlight(false); - } - } + islandManager.updateFlightAtIsland(island); } else { island.setUpgrade(player, me.goodandevil.skyblock.upgrade.Upgrade.Type.Fly, true); - - for (Player all : islandManager.getPlayersAtIsland(island)) { - all.setAllowFlight(true); - all.setFlying(true); - } + islandManager.updateFlightAtIsland(island); } soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F); @@ -335,10 +323,7 @@ public class Upgrade { island.setUpgrade(player, me.goodandevil.skyblock.upgrade.Upgrade.Type.Fly, true); - for (Player all : islandManager.getPlayersAtIsland(island)) { - all.setAllowFlight(true); - all.setFlying(true); - } + islandManager.updateFlightAtIsland(island); Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() { diff --git a/src/main/java/me/goodandevil/skyblock/playerdata/PlayerDataManager.java b/src/main/java/me/goodandevil/skyblock/playerdata/PlayerDataManager.java index 325d19a7..a04570f8 100644 --- a/src/main/java/me/goodandevil/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/me/goodandevil/skyblock/playerdata/PlayerDataManager.java @@ -1,29 +1,12 @@ package me.goodandevil.skyblock.playerdata; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; - import me.goodandevil.skyblock.SkyBlock; import me.goodandevil.skyblock.ban.BanManager; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; -import me.goodandevil.skyblock.island.Island; -import me.goodandevil.skyblock.island.IslandLocation; -import me.goodandevil.skyblock.island.IslandManager; -import me.goodandevil.skyblock.island.IslandRole; -import me.goodandevil.skyblock.island.IslandWorld; +import me.goodandevil.skyblock.island.*; import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; import me.goodandevil.skyblock.scoreboard.ScoreboardManager; @@ -31,6 +14,17 @@ import me.goodandevil.skyblock.utils.player.OfflinePlayer; import me.goodandevil.skyblock.utils.world.LocationUtil; import me.goodandevil.skyblock.visit.Visit; import me.goodandevil.skyblock.world.WorldManager; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; public class PlayerDataManager { @@ -182,8 +176,7 @@ public class PlayerDataManager { } } - islandManager.giveUpgrades(player, island); - islandManager.giveFly(player, island); + islandManager.updateFlight(player); return; } else if (island.isOpen() || island.isCoopPlayer(player.getUniqueId())) { @@ -205,8 +198,7 @@ public class PlayerDataManager { } } - islandManager.giveUpgrades(player, island); - islandManager.giveFly(player, island); + islandManager.updateFlight(player); ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); @@ -305,21 +297,18 @@ public class PlayerDataManager { PlayerData playerData = getPlayerData(player); playerData.setIsland(visitIslandList); - if (island != null) { - if (world == IslandWorld.Normal) { - if (!island.isWeatherSynchronized()) { - player.setPlayerTime(island.getTime(), fileManager - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) - .getFileConfiguration() - .getBoolean("Island.Weather.Time.Cycle")); - player.setPlayerWeather(island.getWeather()); - } + if (world == IslandWorld.Normal) { + if (!island.isWeatherSynchronized()) { + player.setPlayerTime(island.getTime(), fileManager + .getConfig(new File(skyblock.getDataFolder(), "config.yml")) + .getFileConfiguration() + .getBoolean("Island.Weather.Time.Cycle")); + player.setPlayerWeather(island.getWeather()); } - - islandManager.giveUpgrades(player, island); - islandManager.giveFly(player, island); } + islandManager.updateFlight(player); + return; } else { islandManager.unloadIsland(island, @@ -336,8 +325,6 @@ public class PlayerDataManager { return; } } - - return; } } } diff --git a/src/main/java/me/goodandevil/skyblock/upgrade/UpgradeManager.java b/src/main/java/me/goodandevil/skyblock/upgrade/UpgradeManager.java index 230f29fd..37aed5c6 100644 --- a/src/main/java/me/goodandevil/skyblock/upgrade/UpgradeManager.java +++ b/src/main/java/me/goodandevil/skyblock/upgrade/UpgradeManager.java @@ -1,23 +1,18 @@ package me.goodandevil.skyblock.upgrade; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import me.goodandevil.skyblock.SkyBlock; +import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.island.Island; +import me.goodandevil.skyblock.island.IslandManager; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import me.goodandevil.skyblock.SkyBlock; -import me.goodandevil.skyblock.config.FileManager.Config; -import me.goodandevil.skyblock.island.Island; -import me.goodandevil.skyblock.island.IslandManager; +import java.io.File; +import java.io.IOException; +import java.util.*; public class UpgradeManager {