diff --git a/config.yml b/config.yml index ba2e579d..7af6f31b 100644 --- a/config.yml +++ b/config.yml @@ -23,14 +23,15 @@ Island: # [!] The first created structure will be selected. Menu: Enable: true + # [!] You are adviced to keep these options both enabled to prevent any issues. Cooldown: # When enabled cooldown will start when a player creates an Island. Creation: - Enable: false + Enable: true # When enabled cooldown will start when a player deletes their Island. Deletion: - Enable: false - Time: 300 + Enable: true + Time: 60 # Commands that are executed either by the player or the console on Island creation. # [!] To add commands, create a list and remove the open and closed brackets. # Use the variable %player to get the players name. diff --git a/plugin.yml b/plugin.yml index 1c9682ba..929e00b4 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SkyBlock main: me.goodandevil.skyblock.SkyBlock -version: 30 +version: 31 api-version: 1.13 description: A unique SkyBlock plugin author: GoodAndEvil diff --git a/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java b/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java index b4a7793b..9ef35bab 100644 --- a/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java @@ -1,6 +1,8 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import java.util.logging.Level; @@ -21,6 +23,7 @@ import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; +import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; import me.goodandevil.skyblock.scoreboard.ScoreboardManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -39,115 +42,122 @@ public class ConfirmCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); SoundManager soundManager = skyblock.getSoundManager(); FileManager fileManager = skyblock.getFileManager(); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); - - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (playerData.getConfirmationTime() > 0) { - if (islandManager.hasIsland(player)) { - me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner()); - Confirmation confirmation = playerData.getConfirmation(); - - if (confirmation == Confirmation.Ownership || confirmation == Confirmation.Deletion) { - if (island.isRole(Role.Owner, player.getUniqueId())) { - if (confirmation == Confirmation.Ownership) { - UUID targetPlayerUUID = playerData.getOwnership(); - - if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID)) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Confirmed.Message")); + if (playerDataManager.hasPlayerData(player)) { + PlayerData playerData = playerDataManager.getPlayerData(player); + + Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (playerData.getConfirmationTime() > 0) { + if (islandManager.hasIsland(player)) { + me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner()); + Confirmation confirmation = playerData.getConfirmation(); + + if (confirmation == Confirmation.Ownership || confirmation == Confirmation.Deletion) { + if (island.isRole(Role.Owner, player.getUniqueId())) { + if (confirmation == Confirmation.Ownership) { + UUID targetPlayerUUID = playerData.getOwnership(); - String targetPlayerName; - Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID); - - if (targetPlayer == null) { - targetPlayerName = new OfflinePlayer(targetPlayerUUID).getName(); - } else { - targetPlayerName = targetPlayer.getName(); - messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Confirmation.Ownership.Assigned.Message")); - soundManager.playSound(targetPlayer, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F); - } - - for (Player all : Bukkit.getOnlinePlayers()) { - if ((island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) && (!all.getUniqueId().equals(targetPlayerUUID))) { - all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Assigned.Broadcast.Message").replace("%player", targetPlayerName))); - soundManager.playSound(all, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F); - } - } - - playerData.setConfirmation(null); - playerData.setConfirmationTime(0); - - islandManager.giveIslandOwnership(targetPlayerUUID); - } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Ownership.Member.Message")); - soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); - } - } else if (confirmation == Confirmation.Deletion) { - playerData.setConfirmation(null); - playerData.setConfirmationTime(0); - - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Confirmed.Message")); - - boolean hasSpawnPoint = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") != null; - - for (Player all : Bukkit.getOnlinePlayers()) { - if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) { - if (scoreboardManager != null) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - scoreboard.cancel(); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Tutorial.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Tutorial.Displaylines")); - scoreboard.run(); + if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID)) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Confirmed.Message")); + + String targetPlayerName; + Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID); + + if (targetPlayer == null) { + targetPlayerName = new OfflinePlayer(targetPlayerUUID).getName(); + } else { + targetPlayerName = targetPlayer.getName(); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Confirmation.Ownership.Assigned.Message")); + soundManager.playSound(targetPlayer, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F); } - for (Location.World worldList : Location.World.values()) { - if (LocationUtil.isLocationAtLocationRadius(all.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) { - if (hasSpawnPoint) { - LocationUtil.teleportPlayerToSpawn(all); - } else { - Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set."); - } - - break; + for (Player all : Bukkit.getOnlinePlayers()) { + if ((island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) && (!all.getUniqueId().equals(targetPlayerUUID))) { + all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Assigned.Broadcast.Message").replace("%player", targetPlayerName))); + soundManager.playSound(all, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F); } } - if (!island.isRole(Role.Owner, all.getUniqueId())) { - all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Deletion.Broadcast.Message"))); - soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F); + playerData.setConfirmation(null); + playerData.setConfirmationTime(0); + + islandManager.giveIslandOwnership(targetPlayerUUID); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Ownership.Member.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } + } else if (confirmation == Confirmation.Deletion) { + playerData.setConfirmation(null); + playerData.setConfirmationTime(0); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Confirmed.Message")); + + boolean hasSpawnPoint = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") != null; + List islandMembers = new ArrayList<>(); + + for (Player all : Bukkit.getOnlinePlayers()) { + if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) { + if (scoreboardManager != null) { + Scoreboard scoreboard = scoreboardManager.getScoreboard(all); + scoreboard.cancel(); + scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Tutorial.Displayname"))); + scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Tutorial.Displaylines")); + scoreboard.run(); + } + + for (Location.World worldList : Location.World.values()) { + if (LocationUtil.isLocationAtLocationRadius(all.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) { + if (hasSpawnPoint) { + LocationUtil.teleportPlayerToSpawn(all); + } else { + Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set."); + } + + break; + } + } + + if (!island.isRole(Role.Owner, all.getUniqueId())) { + all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Deletion.Broadcast.Message"))); + soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F); + } + + islandMembers.add(all.getUniqueId()); } } + + islandManager.deleteIsland(island); + + skyblock.getVisitManager().deleteIsland(player.getUniqueId()); + skyblock.getBanManager().deleteIsland(player.getUniqueId()); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Deletion.Sender.Message")); + soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F); } - - islandManager.deleteIsland(island); - skyblock.getVisitManager().deleteIsland(player.getUniqueId()); - skyblock.getBanManager().deleteIsland(player.getUniqueId()); - - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Deletion.Sender.Message")); - soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Role.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Role.Message")); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Specified.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Specified.Message")); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Owner.Message")); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Pending.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } - } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Pending.Message")); - soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/VoteCommand.java b/src/me/goodandevil/skyblock/command/commands/VoteCommand.java index 8e0bec90..c1e3c64e 100644 --- a/src/me/goodandevil/skyblock/command/commands/VoteCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/VoteCommand.java @@ -63,7 +63,7 @@ public class VoteCommand extends SubCommand { islandOwnerUUID = targetPlayerOffline.getOwner(); targetPlayerName = targetPlayerOffline.getName(); } else { - islandOwnerUUID = playerDataManager.getPlayerData(player).getOwner(); + islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner(); targetPlayerName = targetPlayer.getName(); } diff --git a/src/me/goodandevil/skyblock/island/IslandManager.java b/src/me/goodandevil/skyblock/island/IslandManager.java index 7a3e5636..b9cb241e 100644 --- a/src/me/goodandevil/skyblock/island/IslandManager.java +++ b/src/me/goodandevil/skyblock/island/IslandManager.java @@ -325,15 +325,24 @@ public class IslandManager { } public void deleteIsland(Island island) { + PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + FileManager fileManager = skyblock.getFileManager(); + skyblock.getVisitManager().removeVisitors(island, VisitManager.Removal.Deleted); + FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); + for (Player all : Bukkit.getOnlinePlayers()) { - if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) { - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(all); + if ((island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) && playerDataManager.hasPlayerData(all)) { + PlayerData playerData = playerDataManager.getPlayerData(all); playerData.setOwner(null); playerData.setMemberSince(null); playerData.setChat(false); playerData.save(); + + if (configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable")) { + skyblock.getCreationManager().createPlayer(all, configLoad.getInt("Island.Creation.Cooldown.Time")); + } } InviteManager inviteManager = skyblock.getInviteManager(); @@ -347,20 +356,8 @@ public class IslandManager { } } - FileManager fileManager = skyblock.getFileManager(); fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - Player player = Bukkit.getServer().getPlayer(island.getOwnerUUID()); - - if (player != null) { - if (configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable")) { - skyblock.getCreationManager().createPlayer(player, configLoad.getInt("Island.Creation.Cooldown.Time")); - } - } - Bukkit.getServer().getPluginManager().callEvent(new IslandDeleteEvent(island)); islandStorage.remove(island.getOwnerUUID()); diff --git a/src/me/goodandevil/skyblock/listeners/Entity.java b/src/me/goodandevil/skyblock/listeners/Entity.java index bb18daa0..a993247e 100644 --- a/src/me/goodandevil/skyblock/listeners/Entity.java +++ b/src/me/goodandevil/skyblock/listeners/Entity.java @@ -192,6 +192,10 @@ public class Entity implements Listener { if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.NATURAL) { LivingEntity livingEntity = event.getEntity(); + if (event.getEntity() instanceof ArmorStand) { + return; + } + if (livingEntity.getWorld().getName().equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName()) || livingEntity.getWorld().getName().equals(skyblock.getWorldManager().getWorld(Location.World.Nether).getName())) { if (!livingEntity.hasMetadata("SkyBlock")) { IslandManager islandManager = skyblock.getIslandManager(); diff --git a/src/me/goodandevil/skyblock/playerdata/PlayerData.java b/src/me/goodandevil/skyblock/playerdata/PlayerData.java index 50ed23f2..45fdbe65 100644 --- a/src/me/goodandevil/skyblock/playerdata/PlayerData.java +++ b/src/me/goodandevil/skyblock/playerdata/PlayerData.java @@ -30,6 +30,7 @@ public class PlayerData { private Object sort; private Area area; + private boolean chat; private Object viewer; @@ -45,6 +46,7 @@ public class PlayerData { playTime = getConfig().getFileConfiguration().getInt("Statistics.Island.Playtime"); area = new Area(); + chat = false; } @@ -175,7 +177,7 @@ public class PlayerData { public void setChat(boolean chat) { this.chat = chat; } - + public Object getViewer() { return viewer; }