diff --git a/pom.xml b/pom.xml index f6f1e47b..8b4db826 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ com.songoda SkyBlock 4.0.0 - 40 + 41 clean package diff --git a/src/main/java/me/goodandevil/skyblock/island/Island.java b/src/main/java/me/goodandevil/skyblock/island/Island.java index 382659b5..4d83269e 100644 --- a/src/main/java/me/goodandevil/skyblock/island/Island.java +++ b/src/main/java/me/goodandevil/skyblock/island/Island.java @@ -89,6 +89,42 @@ public class Island { configLoad.set("Settings", null); } + if (configLoad.getString("Members") != null) { + List members = configLoad.getStringList("Members"); + + for (int i = 0; i < members.size(); i++) { + String member = members.get(i); + Config playerDataConfig = new FileManager.Config(fileManager, + new File(skyblock.getDataFolder().toString() + "/player-data", member + ".yml")); + FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration(); + + if (playerDataConfigLoad.getString("Island.Owner") == null + || !playerDataConfigLoad.getString("Island.Owner").equals(uuid.toString())) { + members.remove(member); + } + } + + configLoad.set("Members", members); + } + + if (configLoad.getString("Operators") != null) { + List operators = configLoad.getStringList("Operators"); + + for (int i = 0; i < operators.size(); i++) { + String operator = operators.get(i); + Config playerDataConfig = new FileManager.Config(fileManager, + new File(skyblock.getDataFolder().toString() + "/player-data", operator + ".yml")); + FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration(); + + if (playerDataConfigLoad.getString("Island.Owner") == null + || !playerDataConfigLoad.getString("Island.Owner").equals(uuid.toString())) { + operators.remove(operator); + } + } + + configLoad.set("Operators", operators); + } + for (Location.World worldList : Location.World.values()) { for (Location.Environment environmentList : Location.Environment.values()) { if (environmentList != Location.Environment.Island) { @@ -480,8 +516,9 @@ public class Island { public boolean removeRole(IslandRole role, UUID uuid) { if (!(role == IslandRole.Visitor || role == IslandRole.Coop || role == IslandRole.Owner)) { if (hasRole(role, uuid)) { - Config config = skyblock.getFileManager().getConfig(new File( - new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); + Config config = skyblock.getFileManager() + .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + getOwnerUUID().toString() + ".yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); List islandMembers = configLoad.getStringList(role.name() + "s"); diff --git a/src/main/java/me/goodandevil/skyblock/island/IslandManager.java b/src/main/java/me/goodandevil/skyblock/island/IslandManager.java index b014a355..29e62ff4 100644 --- a/src/main/java/me/goodandevil/skyblock/island/IslandManager.java +++ b/src/main/java/me/goodandevil/skyblock/island/IslandManager.java @@ -436,21 +436,29 @@ public class IslandManager { UUID islandOwnerUUID = null; + Config config = fileManager.getConfig( + new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + if (isIslandExist(uuid)) { + if (configLoad.getString("Island.Owner") == null + || !configLoad.getString("Island.Owner").equals(uuid.toString())) { + fileManager.deleteConfig( + new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml")); + + return; + } + islandOwnerUUID = uuid; } else { - Config config = fileManager.getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - if (configLoad.getString("Island.Owner") != null) { islandOwnerUUID = UUID.fromString(configLoad.getString("Island.Owner")); } } if (islandOwnerUUID != null && !hasIsland(islandOwnerUUID)) { - File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); - Config config = fileManager.getConfig(new File(configFile, islandOwnerUUID.toString() + ".yml")); + config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", + islandOwnerUUID.toString() + ".yml")); org.bukkit.Location islandNormalLocation = fileManager.getLocation(config, "Location.Normal.Island", true); diff --git a/src/main/java/me/goodandevil/skyblock/listeners/Move.java b/src/main/java/me/goodandevil/skyblock/listeners/Move.java index e0777e4f..73e509dd 100644 --- a/src/main/java/me/goodandevil/skyblock/listeners/Move.java +++ b/src/main/java/me/goodandevil/skyblock/listeners/Move.java @@ -135,8 +135,16 @@ public class Move implements Listener { if (keepItemsOnDeath) { player.setFallDistance(0.0F); - player.teleport(island.getLocation(world, - me.goodandevil.skyblock.island.Location.Environment.Main)); + if (island.getVisit().isVisitor(player.getUniqueId())) { + player.teleport(island.getLocation( + me.goodandevil.skyblock.island.Location.World.Normal, + me.goodandevil.skyblock.island.Location.Environment.Visitor)); + } else { + player.teleport(island.getLocation( + me.goodandevil.skyblock.island.Location.World.Normal, + me.goodandevil.skyblock.island.Location.Environment.Main)); + } + soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } @@ -168,8 +176,16 @@ public class Move implements Listener { player.setFallDistance(0.0F); - player.teleport(island.getLocation(world, - me.goodandevil.skyblock.island.Location.Environment.Main)); + if (island.getVisit().isVisitor(player.getUniqueId())) { + player.teleport(island.getLocation( + me.goodandevil.skyblock.island.Location.World.Normal, + me.goodandevil.skyblock.island.Location.Environment.Visitor)); + } else { + player.teleport(island.getLocation( + me.goodandevil.skyblock.island.Location.World.Normal, + me.goodandevil.skyblock.island.Location.Environment.Main)); + } + soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } diff --git a/src/main/java/me/goodandevil/skyblock/utils/world/WorldBorder.java b/src/main/java/me/goodandevil/skyblock/utils/world/WorldBorder.java index 0febc095..6fbe1e37 100644 --- a/src/main/java/me/goodandevil/skyblock/utils/world/WorldBorder.java +++ b/src/main/java/me/goodandevil/skyblock/utils/world/WorldBorder.java @@ -61,7 +61,6 @@ public final class WorldBorder { Method transitionSizeBetween = worldBorder.getClass().getMethod("transitionSizeBetween", double.class, double.class, long.class); - transitionSizeBetween.invoke(worldBorder, size, size - 1.0D, 20000000L); if (color == Color.Green) { transitionSizeBetween.invoke(worldBorder, size - 0.2D, size - 0.1D + 0.1D, 20000000L); diff --git a/src/main/java/me/goodandevil/skyblock/utils/world/entity/EntityUtil.java b/src/main/java/me/goodandevil/skyblock/utils/world/entity/EntityUtil.java index 4c0a8b75..25734be6 100644 --- a/src/main/java/me/goodandevil/skyblock/utils/world/entity/EntityUtil.java +++ b/src/main/java/me/goodandevil/skyblock/utils/world/entity/EntityUtil.java @@ -35,23 +35,23 @@ public final class EntityUtil { ArmorStand armorStand = (ArmorStand) entity; entityData.setArms(armorStand.hasArms()); - if (armorStand.getItemInHand() != null) { + if (armorStand.getItemInHand() != null && armorStand.getItemInHand().getType() != Material.AIR) { entityData.setHand(ItemStackUtil.serializeItemStack(armorStand.getItemInHand())); } - if (armorStand.getHelmet() != null) { + if (armorStand.getHelmet() != null && armorStand.getHelmet().getType() != Material.AIR) { entityData.setHelmet(ItemStackUtil.serializeItemStack(armorStand.getHelmet())); } - if (armorStand.getChestplate() != null) { + if (armorStand.getChestplate() != null && armorStand.getChestplate().getType() != Material.AIR) { entityData.setChestplate(ItemStackUtil.serializeItemStack(armorStand.getChestplate())); } - if (armorStand.getLeggings() != null) { + if (armorStand.getLeggings() != null && armorStand.getLeggings().getType() != Material.AIR) { entityData.setLeggings(ItemStackUtil.serializeItemStack(armorStand.getLeggings())); } - if (armorStand.getBoots() != null) { + if (armorStand.getBoots() != null && armorStand.getBoots().getType() != Material.AIR) { entityData.setBoots(ItemStackUtil.serializeItemStack(armorStand.getBoots())); } @@ -84,38 +84,41 @@ public final class EntityUtil { if (NMSVersion > 8) { entityData.setAI(livingEntity.hasAI()); - if (entityEquipment.getItemInMainHand() != null) { + if (entityEquipment.getItemInMainHand() != null + && entityEquipment.getItemInMainHand().getType() != Material.AIR) { entityData.setHand(ItemStackUtil.serializeItemStack(entityEquipment.getItemInMainHand())); } entityData.setHandChance(entityEquipment.getItemInMainHandDropChance()); - if (entityEquipment.getItemInOffHand() != null) { + if (entityEquipment.getItemInOffHand() != null + && entityEquipment.getItemInOffHand().getType() != Material.AIR) { entityData.setOffHand(ItemStackUtil.serializeItemStack(entityEquipment.getItemInOffHand())); } entityData.setOffHandChange(entityEquipment.getItemInOffHandDropChance()); } else { - if (entityEquipment.getItemInHand() != null) { + if (entityEquipment.getItemInHand() != null + && entityEquipment.getItemInHand().getType() != Material.AIR) { entityData.setHand(ItemStackUtil.serializeItemStack(entityEquipment.getItemInHand())); } entityData.setHandChance(entityEquipment.getItemInHandDropChance()); } - if (entityEquipment.getHelmet() != null) { + if (entityEquipment.getHelmet() != null && entityEquipment.getHelmet().getType() != Material.AIR) { entityData.setHelmet(ItemStackUtil.serializeItemStack(entityEquipment.getHelmet())); } - if (entityEquipment.getChestplate() != null) { + if (entityEquipment.getChestplate() != null && entityEquipment.getChestplate().getType() != Material.AIR) { entityData.setChestplate(ItemStackUtil.serializeItemStack(entityEquipment.getChestplate())); } - if (entityEquipment.getLeggings() != null) { + if (entityEquipment.getLeggings() != null && entityEquipment.getLeggings().getType() != Material.AIR) { entityData.setLeggings(ItemStackUtil.serializeItemStack(entityEquipment.getLeggings())); } - if (entityEquipment.getBoots() != null) { + if (entityEquipment.getBoots() != null && entityEquipment.getBoots().getType() != Material.AIR) { entityData.setBoots(ItemStackUtil.serializeItemStack(entityEquipment.getBoots())); } @@ -144,9 +147,7 @@ public final class EntityUtil { List items = new ArrayList<>(); for (ItemStack itemList : horse.getInventory().getContents()) { - if (itemList == null) { - items.add(ItemStackUtil.serializeItemStack(new ItemStack(Material.AIR))); - } else { + if (itemList != null && itemList.getType() != Material.AIR) { items.add(ItemStackUtil.serializeItemStack(itemList)); } } @@ -181,9 +182,7 @@ public final class EntityUtil { List items = new ArrayList<>(); for (ItemStack itemList : villager.getInventory().getContents()) { - if (itemList == null) { - items.add(ItemStackUtil.serializeItemStack(new ItemStack(Material.AIR))); - } else { + if (itemList != null && itemList.getType() != Material.AIR) { items.add(ItemStackUtil.serializeItemStack(itemList)); } } @@ -200,9 +199,7 @@ public final class EntityUtil { List items = new ArrayList<>(); for (ItemStack itemList : llama.getInventory().getContents()) { - if (itemList == null) { - items.add(ItemStackUtil.serializeItemStack(new ItemStack(Material.AIR))); - } else { + if (itemList != null && itemList.getType() != Material.AIR) { items.add(ItemStackUtil.serializeItemStack(itemList)); } } @@ -229,9 +226,7 @@ public final class EntityUtil { List items = new ArrayList<>(); for (ItemStack itemList : ((InventoryHolder) entity).getInventory().getContents()) { - if (itemList == null) { - items.add(ItemStackUtil.serializeItemStack(new ItemStack(Material.AIR))); - } else { + if (itemList != null && itemList.getType() != Material.AIR) { items.add(ItemStackUtil.serializeItemStack(itemList)); } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 1ab6952b..9a13afdc 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -439,7 +439,7 @@ Command: Coop: Info: Message: "&f&oOpen the Island Coop menu or add/remove coop players." - Permisison: + Permission: Message: "&bSkyBlock &8| &cError&8: &eYou do not have the right to do that." Invalid: Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island coop []" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8eac3ea0..57cd352f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: SkyBlock main: me.goodandevil.skyblock.SkyBlock -version: 40 +version: 41 api-version: 1.13 description: A unique SkyBlock plugin author: GoodAndEvil