diff --git a/language.yml b/language.yml index 0394808f..85a905ca 100644 --- a/language.yml +++ b/language.yml @@ -658,6 +658,9 @@ Island: Signature: Disabled: Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to use that feature." + World: + Nether: + Message: "&bSkyBlock &8| &aInfo&8: &eYou have been teleported out of the nether because the nether is disabled." WorldBorder: Outside: Message: "&bSkyBlock &8| &cError&8: &eYou went too far outside the Island WorldBorder." diff --git a/plugin.yml b/plugin.yml index 8036eecb..c018429d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SkyBlock main: me.goodandevil.skyblock.Main -version: 21 +version: 22 api-version: 1.13 description: A unique SkyBlock plugin author: GoodAndEvil diff --git a/src/me/goodandevil/skyblock/command/CommandManager.java b/src/me/goodandevil/skyblock/command/CommandManager.java index 0b8bcabe..f38ebbbd 100644 --- a/src/me/goodandevil/skyblock/command/CommandManager.java +++ b/src/me/goodandevil/skyblock/command/CommandManager.java @@ -245,21 +245,51 @@ public class CommandManager implements CommandExecutor, TabCompleter { List commandAliases = new ArrayList<>(); if (args.length == 1) { - commandAliases.add("admin"); - - for (SubCommand subCommandList : subCommands.get(Type.Default)) { - commandAliases.add(subCommandList.getName()); + if (args[0] == null || args[0].isEmpty()) { + commandAliases.add("admin"); + + for (SubCommand subCommandList : subCommands.get(Type.Default)) { + commandAliases.add(subCommandList.getName()); + } + } else { + if ("admin".contains(args[0].toLowerCase())) { + commandAliases.add("admin"); + } + + for (SubCommand subCommandList : subCommands.get(Type.Default)) { + if (subCommandList.getName().toLowerCase().contains(args[0].toLowerCase())) { + commandAliases.add(subCommandList.getName()); + } + } } } else if (args.length == 2) { if (args[0].equalsIgnoreCase("admin")) { - for (SubCommand subCommandList : subCommands.get(Type.Admin)) { - commandAliases.add(subCommandList.getName()); + if (args[1] == null || args[1].isEmpty()) { + for (SubCommand subCommandList : subCommands.get(Type.Admin)) { + commandAliases.add(subCommandList.getName()); + } + } else { + for (SubCommand subCommandList : subCommands.get(Type.Admin)) { + if (subCommandList.getName().toLowerCase().contains(args[1].toLowerCase())) { + commandAliases.add(subCommandList.getName()); + } + } } } } else if (args.length == 3) { if (args[0].equalsIgnoreCase("admin") && args[1].equalsIgnoreCase("structure")) { - commandAliases.add("tool"); - commandAliases.add("save"); + if (args[2] == null || args[2].isEmpty()) { + commandAliases.add("tool"); + commandAliases.add("save"); + } else { + if ("tool".contains(args[2].toLowerCase())) { + commandAliases.add("tool"); + } + + if ("save".contains(args[2].toLowerCase())) { + commandAliases.add("save"); + } + } } } diff --git a/src/me/goodandevil/skyblock/island/Island.java b/src/me/goodandevil/skyblock/island/Island.java index 728373b8..a22ef8e2 100644 --- a/src/me/goodandevil/skyblock/island/Island.java +++ b/src/me/goodandevil/skyblock/island/Island.java @@ -146,12 +146,12 @@ public class Island { }.runTask(plugin); } - level = new Level(this, plugin); + level = new Level(getOwnerUUID(), plugin); VisitManager visitManager = plugin.getVisitManager(); if (!visitManager.hasIsland(getOwnerUUID())) { - visitManager.createIsland(getOwnerUUID(), new org.bukkit.Location[] { getLocation(Location.World.Normal, Location.Environment.Island), getLocation(Location.World.Nether, Location.Environment.Island) }, size, getRole(Role.Member).size() + getRole(Role.Operator).size() + 1, level.getLevel(), getMessage(Message.Signature), isOpen()); + visitManager.createIsland(getOwnerUUID(), new org.bukkit.Location[] { getLocation(Location.World.Normal, Location.Environment.Island), getLocation(Location.World.Nether, Location.Environment.Island) }, size, getRole(Role.Member).size() + getRole(Role.Operator).size() + 1, level, getMessage(Message.Signature), isOpen()); } BanManager banManager = plugin.getBanManager(); diff --git a/src/me/goodandevil/skyblock/island/IslandManager.java b/src/me/goodandevil/skyblock/island/IslandManager.java index 261e72ce..52fae264 100644 --- a/src/me/goodandevil/skyblock/island/IslandManager.java +++ b/src/me/goodandevil/skyblock/island/IslandManager.java @@ -39,6 +39,7 @@ import me.goodandevil.skyblock.structure.Structure; import me.goodandevil.skyblock.utils.OfflinePlayer; import me.goodandevil.skyblock.utils.structure.StructureUtil; import me.goodandevil.skyblock.utils.version.Materials; +import me.goodandevil.skyblock.utils.version.NMSUtil; import me.goodandevil.skyblock.utils.world.LocationUtil; import me.goodandevil.skyblock.utils.world.WorldBorder; import me.goodandevil.skyblock.utils.world.block.BlockDegreesType; @@ -185,12 +186,14 @@ public class IslandManager { } }.runTask(plugin); - Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { - @Override - public void run() { - plugin.getBiomeManager().setBiome(null, island, Biome.valueOf(fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase())); - } - }, 20L); + if (NMSUtil.getVersionNumber() < 13) { + Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { + @Override + public void run() { + plugin.getBiomeManager().setBiome(null, island, Biome.valueOf(fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase())); + } + }, 20L); + } } public void giveIslandOwnership(UUID uuid) { @@ -209,6 +212,7 @@ public class IslandManager { if (containsIsland(islandOwnerUUID)) { Island island = getIsland(islandOwnerUUID); + island.getLevel().setOwnerUUID(uuid); island.setOwnerUUID(uuid); Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); diff --git a/src/me/goodandevil/skyblock/island/Level.java b/src/me/goodandevil/skyblock/island/Level.java index 50a5f8c6..73e4fd95 100644 --- a/src/me/goodandevil/skyblock/island/Level.java +++ b/src/me/goodandevil/skyblock/island/Level.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.UUID; import org.bukkit.configuration.file.FileConfiguration; @@ -13,18 +14,19 @@ import me.goodandevil.skyblock.config.FileManager.Config; public class Level { private final Main plugin; - private final Island island; + + private UUID ownerUUID; private int lastLevel = 0; private int lastPoints = 0; private Map materials; - public Level(Island island, Main plugin) { - this.island = island; + public Level(UUID ownerUUID, Main plugin) { this.plugin = plugin; + this.ownerUUID = ownerUUID; - Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); Map materials = new HashMap<>(); @@ -40,6 +42,10 @@ public class Level { this.materials = materials; } + public void setOwnerUUID(UUID ownerUUID) { + this.ownerUUID = ownerUUID; + } + public int getPoints() { Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -72,7 +78,7 @@ public class Level { } public void setMaterials(Map materials) { - Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); diff --git a/src/me/goodandevil/skyblock/leaderboard/LeaderboardManager.java b/src/me/goodandevil/skyblock/leaderboard/LeaderboardManager.java index 89c4192e..167eb0eb 100644 --- a/src/me/goodandevil/skyblock/leaderboard/LeaderboardManager.java +++ b/src/me/goodandevil/skyblock/leaderboard/LeaderboardManager.java @@ -2,9 +2,8 @@ package me.goodandevil.skyblock.leaderboard; import java.io.File; import java.util.ArrayList; -import java.util.LinkedHashMap; +import java.util.Comparator; import java.util.List; -import java.util.Map; import java.util.UUID; import me.goodandevil.skyblock.Main; @@ -28,23 +27,37 @@ public class LeaderboardManager { public void resetLeaderboard() { VisitManager visitManager = plugin.getVisitManager(); - Map islandLevels = new LinkedHashMap<>(); - Map islandVotes = new LinkedHashMap<>(); + List islandLevels = new ArrayList<>(); + List islandVotes = new ArrayList<>(); for (int i = 0; i < visitManager.getIslands().size(); i++) { UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i]; Visit visit = visitManager.getIslands().get(ownerUUID); - islandLevels.put(ownerUUID, visit.getLevel()); - islandVotes.put(ownerUUID, visit.getVoters().size()); + islandLevels.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel())); + islandVotes.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size())); } + islandLevels.sort(new Comparator() { + @Override + public int compare(LeaderboardPlayer leaderboardPlayer1, LeaderboardPlayer leaderboardPlayer2) { + return Integer.valueOf(leaderboardPlayer2.getValue()).compareTo(leaderboardPlayer1.getValue()); + } + }); + + islandVotes.sort(new Comparator() { + @Override + public int compare(LeaderboardPlayer leaderboardPlayer1, LeaderboardPlayer leaderboardPlayer2) { + return Integer.valueOf(leaderboardPlayer2.getValue()).compareTo(leaderboardPlayer1.getValue()); + } + }); + for (int i = 0; i < 10; i++) { if (islandLevels.size() != 0 && i <= islandLevels.size()-1) { - leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Level, visitManager.getIsland((UUID) islandLevels.keySet().toArray()[i]), i)); + leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Level, visitManager.getIsland((UUID) islandLevels.get(i).getUUID()), i)); } if (islandVotes.size() != 0 && i <= islandVotes.size()-1) { - leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Votes, visitManager.getIsland((UUID) islandLevels.keySet().toArray()[i]), i)); + leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Votes, visitManager.getIsland((UUID) islandLevels.get(i).getUUID()), i)); } } } diff --git a/src/me/goodandevil/skyblock/leaderboard/LeaderboardPlayer.java b/src/me/goodandevil/skyblock/leaderboard/LeaderboardPlayer.java new file mode 100644 index 00000000..dc0bd364 --- /dev/null +++ b/src/me/goodandevil/skyblock/leaderboard/LeaderboardPlayer.java @@ -0,0 +1,22 @@ +package me.goodandevil.skyblock.leaderboard; + +import java.util.UUID; + +public class LeaderboardPlayer { + + private UUID uuid; + private int value; + + public LeaderboardPlayer(UUID uuid, int value) { + this.uuid = uuid; + this.value = value; + } + + public UUID getUUID() { + return uuid; + } + + public int getValue() { + return value; + } +} diff --git a/src/me/goodandevil/skyblock/levelling/LevellingManager.java b/src/me/goodandevil/skyblock/levelling/LevellingManager.java index 9c2c6e9b..e4acf3e9 100644 --- a/src/me/goodandevil/skyblock/levelling/LevellingManager.java +++ b/src/me/goodandevil/skyblock/levelling/LevellingManager.java @@ -155,7 +155,6 @@ public class LevellingManager { level.setLastPoints(level.getPoints()); level.setLastLevel(level.getLevel()); level.setMaterials(materials); - island.getVisit().setLevel(level.getLevel()); if (player != null) { me.goodandevil.skyblock.menus.Levelling.getInstance().open(player); diff --git a/src/me/goodandevil/skyblock/listeners/Move.java b/src/me/goodandevil/skyblock/listeners/Move.java index ed18a402..dd41bae8 100644 --- a/src/me/goodandevil/skyblock/listeners/Move.java +++ b/src/me/goodandevil/skyblock/listeners/Move.java @@ -12,6 +12,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import me.goodandevil.skyblock.Main; +import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; @@ -38,16 +39,48 @@ public class Move implements Listener { Location to = event.getTo(); if (from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ()) { - if (player.getWorld().getName().equals(plugin.getWorldManager().getWorld(me.goodandevil.skyblock.island.Location.World.Normal).getName()) || player.getWorld().getName().equals(plugin.getWorldManager().getWorld(me.goodandevil.skyblock.island.Location.World.Nether).getName())) { + String netherWorldName = plugin.getWorldManager().getWorld(me.goodandevil.skyblock.island.Location.World.Nether).getName(); + + if (player.getWorld().getName().equals(plugin.getWorldManager().getWorld(me.goodandevil.skyblock.island.Location.World.Normal).getName()) || player.getWorld().getName().equals(netherWorldName)) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); + + if (player.getWorld().getName().equals(netherWorldName)) { + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World.Nether.Enable")) { + player.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.World.Nether.Message"))); + + if (playerDataManager.hasPlayerData(player)) { + PlayerData playerData = playerDataManager.getPlayerData(player); + + if (playerData.getIsland() != null) { + Island island = islandManager.getIsland(playerData.getIsland()); + + if (island != null) { + 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); + + return; + } + } + } + + LocationUtil.teleportPlayerToSpawn(player); + soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); + } + } if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); UUID islandOwnerUUID = playerData.getIsland(); if (islandOwnerUUID != null) { - IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIsland(islandOwnerUUID); if (island != null) { @@ -60,7 +93,7 @@ public class Move implements Listener { } if (world != null) { - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.World." + world.name() + ".Liquid.Enable")) { diff --git a/src/me/goodandevil/skyblock/listeners/Portal.java b/src/me/goodandevil/skyblock/listeners/Portal.java index 25b4896d..e2cbffdf 100644 --- a/src/me/goodandevil/skyblock/listeners/Portal.java +++ b/src/me/goodandevil/skyblock/listeners/Portal.java @@ -10,6 +10,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityPortalEnterEvent; import me.goodandevil.skyblock.Main; +import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.sound.SoundManager; @@ -35,18 +36,19 @@ public class Portal implements Listener { IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (player.getWorld().getName().equals(plugin.getWorldManager().getWorld(Location.World.Normal).getName())) { for (UUID islandList : islandManager.getIslands().keySet()) { Island island = islandManager.getIslands().get(islandList); if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(Location.World.Normal, Location.Environment.Island), island.getRadius())) { - if (islandManager.hasPermission(player, "Portal")) { + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World.Nether.Enable") && islandManager.hasPermission(player, "Portal")) { player.teleport(island.getLocation(Location.World.Nether, Location.Environment.Main)); soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } else { player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } @@ -58,12 +60,12 @@ public class Portal implements Listener { Island island = islandManager.getIslands().get(islandList); if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(Location.World.Nether, Location.Environment.Island), island.getRadius())) { - if (islandManager.hasPermission(player, "Portal")) { + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World.Nether.Enable") && islandManager.hasPermission(player, "Portal")) { player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main)); soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } else { player.teleport(island.getLocation(Location.World.Nether, Location.Environment.Main)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } diff --git a/src/me/goodandevil/skyblock/menus/Leaderboard.java b/src/me/goodandevil/skyblock/menus/Leaderboard.java index 5dc4c7dc..0ef8c739 100644 --- a/src/me/goodandevil/skyblock/menus/Leaderboard.java +++ b/src/me/goodandevil/skyblock/menus/Leaderboard.java @@ -125,7 +125,7 @@ public class Leaderboard implements Listener { } } - inv.addItem(inv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Displayname").replace("%position", "" + (leaderboard.getPosition() + 1)), itemLore, inv.createItemLoreVariable(new String[] { "%position#" + (leaderboard.getPosition() + 1), "%owner#" + playerName, "%level#" + visit.getLevel(), "%votes#" + visit.getVoters().size(), "%members#" + visit.getMembers() }), null, null), itemSlot); + inv.addItem(inv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Displayname").replace("%position", "" + (leaderboard.getPosition() + 1)), itemLore, inv.createItemLoreVariable(new String[] { "%position#" + (leaderboard.getPosition() + 1), "%owner#" + playerName, "%level#" + visit.getLevel().getLevel(), "%votes#" + visit.getVoters().size(), "%members#" + visit.getMembers() }), null, null), itemSlot); } int[] itemSlots = new int[] { 13, 21, 22, 23, 29, 31, 33, 37, 40, 43 }; diff --git a/src/me/goodandevil/skyblock/menus/Visit.java b/src/me/goodandevil/skyblock/menus/Visit.java index 691282e9..1bcc7f09 100644 --- a/src/me/goodandevil/skyblock/menus/Visit.java +++ b/src/me/goodandevil/skyblock/menus/Visit.java @@ -90,7 +90,7 @@ public class Visit implements Listener { islandInteger = islandManager.getPlayersAtIsland(islandManager.getIsland(visitIslandList)).size(); } } else if (sort == Visit.Sort.Level) { - islandInteger = visitIslands.get(visitIslandList).getLevel(); + islandInteger = visitIslands.get(visitIslandList).getLevel().getLevel(); } else if (sort == Visit.Sort.Members) { islandInteger = visitIslands.get(visitIslandList).getMembers(); } else if (sort == Visit.Sort.Visits) { @@ -333,7 +333,7 @@ public class Visit implements Listener { if ((!island.isRole(Role.Member, player.getUniqueId()) && !island.isRole(Role.Operator, player.getUniqueId()) && !island.isRole(Role.Owner, player.getUniqueId())) && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) { if (event.getClick() == ClickType.RIGHT) { - if (playerData.getIsland().equals(island.getOwnerUUID())) { + if (playerData.getIsland() != null && playerData.getIsland().equals(island.getOwnerUUID())) { List islandVotes = visit.getVoters(); if (islandVotes.contains(player.getUniqueId())) { diff --git a/src/me/goodandevil/skyblock/utils/version/NMSUtil.java b/src/me/goodandevil/skyblock/utils/version/NMSUtil.java index d6320da8..ddd0eb3a 100644 --- a/src/me/goodandevil/skyblock/utils/version/NMSUtil.java +++ b/src/me/goodandevil/skyblock/utils/version/NMSUtil.java @@ -17,6 +17,11 @@ public class NMSUtil { return Integer.valueOf(name.substring(0, name.length() - 4)); } + public static int getVersionReleaseNumber() { + String NMSVersion = getVersion(); + return Integer.valueOf(NMSVersion.substring(NMSVersion.length() - 2).replace(".", "")); + } + public static Class getNMSClass(String className) { try { String fullName = "net.minecraft.server." + getVersion() + className; diff --git a/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java b/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java index 6fa2b115..78477177 100644 --- a/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java +++ b/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java @@ -401,7 +401,12 @@ public final class BlockUtil { Object block = NMSUtil.getNMSClass("Blocks").getField(material.name()).get(null); Object IBlockData = block.getClass().getMethod("getBlockData").invoke(block); worldHandle.getClass().getMethod("setTypeAndData", blockPosition.getClass(), IBlockDataClass, int.class).invoke(worldHandle, blockPosition, IBlockData, 2); - chunk.getClass().getMethod("setType", blockPosition.getClass(), IBlockDataClass, boolean.class).invoke(chunk, blockPosition, IBlockData, true); + + if (NMSUtil.getVersionReleaseNumber() > 1) { + chunk.getClass().getMethod("setType", blockPosition.getClass(), IBlockDataClass, boolean.class).invoke(chunk, blockPosition, IBlockData, true); + } else { + chunk.getClass().getMethod("a", blockPosition.getClass(), IBlockDataClass, boolean.class).invoke(chunk, blockPosition, IBlockData, true); + } } else { Object IBlockData = NMSUtil.getNMSClass("Block").getMethod("getByCombinedId", int.class).invoke(null, material.getId() + (data << 12)); worldHandle.getClass().getMethod("setTypeAndData", blockPosition.getClass(), IBlockDataClass, int.class).invoke(worldHandle, blockPosition, IBlockData, 3); diff --git a/src/me/goodandevil/skyblock/visit/Visit.java b/src/me/goodandevil/skyblock/visit/Visit.java index d16120a6..a75cebc7 100644 --- a/src/me/goodandevil/skyblock/visit/Visit.java +++ b/src/me/goodandevil/skyblock/visit/Visit.java @@ -11,6 +11,7 @@ import org.bukkit.configuration.file.FileConfiguration; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.island.Level; public class Visit { @@ -22,13 +23,14 @@ public class Visit { private int islandSize; private int islandMembers; - private int islandLevel; + + private final Level islandLevel; private List islandSignature; private boolean open; - protected Visit(Main plugin, UUID islandOwnerUUID, Location[] islandLocations, int islandSize, int islandMembers, int islandLevel, List islandSignature, boolean open) { + protected Visit(Main plugin, UUID islandOwnerUUID, Location[] islandLocations, int islandSize, int islandMembers, Level islandLevel, List islandSignature, boolean open) { this.plugin = plugin; this.islandOwnerUUID = islandOwnerUUID; this.islandLocations = islandLocations; @@ -73,14 +75,10 @@ public class Visit { this.islandSize = islandSize; } - public int getLevel() { + public Level getLevel() { return islandLevel; } - public void setLevel(int islandLevel) { - this.islandLevel = islandLevel; - } - public boolean isVisitor(UUID uuid) { return getVisitors().contains(uuid); } diff --git a/src/me/goodandevil/skyblock/visit/VisitManager.java b/src/me/goodandevil/skyblock/visit/VisitManager.java index b81858a9..19843b61 100644 --- a/src/me/goodandevil/skyblock/visit/VisitManager.java +++ b/src/me/goodandevil/skyblock/visit/VisitManager.java @@ -19,6 +19,7 @@ import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Island; +import me.goodandevil.skyblock.island.Level; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; import me.goodandevil.skyblock.utils.world.LocationUtil; @@ -73,7 +74,7 @@ public class VisitManager { size = configLoad.getInt("Size"); } - createIsland(islandOwnerUUID, new Location[] { fileManager.getLocation(config, "Location.Normal.Island", true), fileManager.getLocation(config, "Location.Nether.Island", true) }, size, configLoad.getStringList("Members").size() + configLoad.getStringList("Operators").size() + 1, configLoad.getInt("Levelling.Points") / division, islandSignature, configLoad.getBoolean("Visitor.Open")); + createIsland(islandOwnerUUID, new Location[] { fileManager.getLocation(config, "Location.Normal.Island", true), fileManager.getLocation(config, "Location.Nether.Island", true) }, size, configLoad.getStringList("Members").size() + configLoad.getStringList("Operators").size() + 1, new Level(islandOwnerUUID, plugin), islandSignature, configLoad.getBoolean("Visitor.Open")); } } } @@ -81,6 +82,8 @@ public class VisitManager { public void transfer(UUID uuid, UUID islandOwnerUUID) { Visit visit = getIsland(islandOwnerUUID); + visit.setOwnerUUID(uuid); + visit.getLevel().setOwnerUUID(uuid); visit.save(); File oldVisitDataFile = new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml"); @@ -146,7 +149,7 @@ public class VisitManager { return visitIslands; } - public void createIsland(UUID islandOwnerUUID, Location[] islandLocations, int islandSize, int islandMembers, int islandLevel, List islandSignature, boolean open) { + public void createIsland(UUID islandOwnerUUID, Location[] islandLocations, int islandSize, int islandMembers, Level islandLevel, List islandSignature, boolean open) { visitStorage.put(islandOwnerUUID, new Visit(plugin, islandOwnerUUID, islandLocations, islandSize, islandMembers, islandLevel, islandSignature, open)); }