diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 16534e1f..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..bbbc60f0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,16 @@ +image: maven:latest + +cache: + paths: + - .m2/repository/ + - target/ + +build: + stage: build + script: + - mvn compile + +test: + stage: test + script: + - mvn test \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..1aeb70c4 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +FabledSkyBlock LaborPatch +=========== +Forked from [FabledSkyBlock](https://gitlab.com/Songoda/fabledskyblock) + +This fork contains bug fixes, features and improvements: +- Added option to check location security when using `/is visit` +- Added option to remove water from Island Spawn +- Added an option to toggle fall damage in certain conditions like when using `/is home` +- Added per-world generator (editable only from generators.yml, GUI not supported yet) +- Added a "subtract" value to levels in order to have all the new islands to level 0 +- Added option to set default WorldBorder status +- Added permissions for WorldBorder colors +- Added permission to bypass `/is kick` +- Added water in Nether mechanics! +- Added option to let slime splitting bypass limits.yml +- Added option to define distance between islands +- Added option to clear inventory and/or enderchest on island delete (working only with online players) +- Added deletion cooldown +- Fixed bugs in Challenges that didn't remove all the items +- Fixed WorldBorder size not reflecting real island size +- Fixed bugs in island settings that prevented the from loading correctly +- Now you can use `/is chat ` to send messages to island chat +- Now Challenges can be per-island too +- Hide options in control panel if missing the permission +- Hide vanished players from visitors list +- Hide bank from leaderboard if disabled +- Minor bug fixes +- Little optimizations + +Use this fork at your own risk. No support provided. + +Compile +------ +To compile this fork, clone it and run the following command +``` +mvn clean package +``` +You will find the jar file in the target/ directory. + diff --git a/pom.xml b/pom.xml index 517031a1..914a3eb3 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2.16 + 2.2.16-LaborPatch-0.0.3 jar clean install diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index d21c1c6e..00000000 Binary files a/src/.DS_Store and /dev/null differ diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 75176f70..2c4335ad 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -39,6 +39,7 @@ import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.structure.StructureManager; +import com.songoda.skyblock.tasks.MobNetherWaterTask; import com.songoda.skyblock.upgrade.UpgradeManager; import com.songoda.skyblock.usercache.UserCacheManager; import com.songoda.skyblock.visit.VisitManager; @@ -80,6 +81,7 @@ public class SkyBlock extends SongodaPlugin { private PlaceholderManager placeholderManager; private MessageManager messageManager; private HologramTask hologramTask; + private MobNetherWaterTask mobNetherWaterTask; private LimitationInstanceHandler limitationHandler; private LocalizationManager localizationManager; private RewardManager rewardManager; @@ -161,6 +163,7 @@ public class SkyBlock extends SongodaPlugin { // Start Tasks hologramTask = HologramTask.startTask(this); + mobNetherWaterTask = MobNetherWaterTask.startTask(this); PluginManager pluginManager = getServer().getPluginManager(); pluginManager.registerEvents(new Join(this), this); @@ -228,6 +231,10 @@ public class SkyBlock extends SongodaPlugin { this.hologramTask.onDisable(); } + if (this.mobNetherWaterTask != null) { + this.mobNetherWaterTask.onDisable(); + } + if (this.fabledChallenge != null) { this.fabledChallenge.onDisable(); } @@ -341,6 +348,10 @@ public class SkyBlock extends SongodaPlugin { return hologramTask; } + public MobNetherWaterTask getMobNetherWaterTask() { + return mobNetherWaterTask; + } + public StackableManager getStackableManager() { return stackableManager; } diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java index d44267e8..eb1a3604 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -78,37 +78,37 @@ public class Challenge { } } } - + // GETTERS - + public ChallengeCategory getCategory() { return category; } - + public int getId() { return id; } - + public String getName() { return name; } - + public int getMaxTimes() { return maxTimes; } - + public boolean isShowInChat() { return showInChat; } - + public List> getRequires() { return requires; } - + public List> getRewards() { return rewards; } - + public ItemChallenge getItem() { return item; } @@ -151,14 +151,31 @@ public class Challenge { // Check if player has specific item in his inventory ItemStack is = (ItemStack) obj; return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount()); -// return p.getInventory().contains(is.getType(), is.getAmount()); } @Override public void executeRequire(Player p, Object obj) { - // Remove specific item in player's inventory - ItemStack is = (ItemStack) obj; - p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount())); + if(obj instanceof ItemStack){ + // Remove specific item in player's inventory + ItemStack is = (ItemStack) obj; + //p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount())); + int toRemove = is.getAmount(); + for(ItemStack jis : p.getInventory().getStorageContents()) { + if(jis != null && jis.isSimilar(is)) { + if(jis.getAmount() <= toRemove) { + toRemove -= jis.getAmount(); + jis.setAmount(0); + } else { + jis.setAmount(jis.getAmount() - toRemove); + toRemove = 0; + } + } + if(toRemove <= 0) { + p.updateInventory(); + break; + } + } + } // TODO LOG } @@ -422,7 +439,7 @@ public class Challenge { *
  • 7 = lingering extended
  • *
  • 8 = lingering ++
  • * - * + * * @param is * @param type * @param data @@ -451,7 +468,7 @@ public class Challenge { /** * Try to convert the value to a useable object used later - * + * * @param value * The value to convert * @return A useable object required @@ -460,7 +477,7 @@ public class Challenge { /** * Check if specific player has requirement for specific object - * + * * @param p * The player * @param obj @@ -471,7 +488,7 @@ public class Challenge { /** * Execute an action associated with specific object for specific player - * + * * @param p * The player * @param obj @@ -481,7 +498,7 @@ public class Challenge { /** * Give a reward to specific player for specific object - * + * * @param p * The player * @param obj diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java b/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java index 9d956657..3cd2cffa 100644 --- a/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java +++ b/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java @@ -10,6 +10,7 @@ import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import com.songoda.skyblock.challenge.FabledChallenge; @@ -21,6 +22,7 @@ import com.songoda.skyblock.challenge.defaultinv.Item; import com.songoda.skyblock.challenge.inventory.ClickableItem; import com.songoda.skyblock.challenge.inventory.Inventory; import com.songoda.skyblock.challenge.inventory.InventoryProvider; +import org.bukkit.inventory.meta.ItemMeta; public class ChallengeInventory implements InventoryProvider { public static final String CATEGORY = "ChallengeCategory"; @@ -78,6 +80,10 @@ public class ChallengeInventory implements InventoryProvider { // If challenge is done, add enchantment to show to player that it's done if (count >= c.getMaxTimes()) is.addUnsafeEnchantment(Enchantment.OXYGEN, 1); + ItemMeta im = is.getItemMeta(); + im.addItemFlags(ItemFlag.HIDE_ENCHANTS); + is.setItemMeta(im); + Consumer consumer = e -> { // Count the new value int count2 = done.getOrDefault(c, 0); @@ -97,6 +103,9 @@ public class ChallengeInventory implements InventoryProvider { // If challenge is done, add enchantment to show to player that it's done if (count2 >= c.getMaxTimes()) is2.addUnsafeEnchantment(Enchantment.OXYGEN, 1); + ItemMeta im2 = is2.getItemMeta(); + im2.addItemFlags(ItemFlag.HIDE_ENCHANTS); + is2.setItemMeta(im2); // Update inv.updateItem(ic.getCol(), ic.getRow(), is2); } else diff --git a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java index 0efb5173..47a822e5 100644 --- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java +++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; +import com.songoda.skyblock.island.Island; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; @@ -22,19 +23,32 @@ import com.songoda.skyblock.config.FileManager.Config; public class PlayerManager { private SkyBlock skyblock; - private HashMap> players; + private HashMap> islands; private File playersDirectory; public PlayerManager(SkyBlock skyblock) { this.skyblock = skyblock; - players = new HashMap<>(); + islands = new HashMap<>(); playersDirectory = new File(skyblock.getDataFolder(), "challenge-data"); if (!playersDirectory.exists()) playersDirectory.mkdirs(); + + Bukkit.getScheduler().runTask(skyblock, () -> { + for(Player p : Bukkit.getServer().getOnlinePlayers()){ + loadPlayer(p.getUniqueId()); + } + }); } public HashMap getPlayer(UUID uuid) { - return players.get(uuid); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)) { + Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + if(is != null){ + uuid = is.getOwnerUUID(); + } + } + return islands.get(uuid); } /** @@ -44,7 +58,15 @@ public class PlayerManager { * The uuid of specific player */ public void loadPlayer(UUID uuid) { - Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml")); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)) { + Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + if(is != null){ + uuid = is.getOwnerUUID(); + } + } + Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, + uuid.toString() + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); HashMap challenges = new HashMap<>(); ConfigurationSection section = fileConfig.getConfigurationSection("challenges"); @@ -67,7 +89,7 @@ public class PlayerManager { challenges.put(c, count); } } - players.put(uuid, challenges); + islands.put(uuid, challenges); } /** @@ -77,8 +99,16 @@ public class PlayerManager { * The uuid of specific player */ public void unloadPlayer(UUID uuid) { - players.remove(uuid); - skyblock.getFileManager().unloadConfig(new File(playersDirectory, uuid.toString() + ".yml")); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)) { + Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + if(is != null){ + uuid = is.getOwnerUUID(); + } + } + islands.remove(uuid); + skyblock.getFileManager().unloadConfig(new File(playersDirectory, + uuid.toString() + ".yml")); } @@ -95,11 +125,18 @@ public class PlayerManager { if (c == null) return false; UUID uuid = p.getUniqueId(); - HashMap done = players.get(uuid); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)) { + Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + if(is != null){ + uuid = is.getOwnerUUID(); + } + } + HashMap done = islands.get(uuid); if (done == null) { // Wtf ? loadPlayer(uuid); - done = players.get(uuid); + done = islands.get(uuid); } int count = done.getOrDefault(c, 0); if (c.getMaxTimes() != 0 && count >= c.getMaxTimes()) @@ -124,7 +161,14 @@ public class PlayerManager { if (!canDoChallenge(p, c)) return false; UUID uuid = p.getUniqueId(); - HashMap done = players.get(uuid); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)) { + Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + if(is != null){ + uuid = is.getOwnerUUID(); + } + } + HashMap done = islands.get(uuid); int count = done.getOrDefault(c, 0); done.put(c, count + 1); addChallenge(uuid, c); @@ -146,7 +190,15 @@ public class PlayerManager { } public void addChallenge(UUID uuid, Challenge c) { - Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml")); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)) { + Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + if(is != null){ + uuid = is.getOwnerUUID(); + } + } + Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, + uuid.toString() + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); int ccId = c.getCategory().getId(); int cId = c.getId(); @@ -173,12 +225,21 @@ public class PlayerManager { * @return The number of time specific challenge has been done by player */ public int getChallengeCount(UUID uuid, Challenge c) { - HashMap challenges = players.get(uuid); + HashMap challenges = islands.get(uuid); if (challenges != null) { return challenges.getOrDefault(c, 0); } else { + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)) { + Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + if(is != null){ + uuid = is.getOwnerUUID(); + } + } + // Not connected, check in file - Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml")); + Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, + uuid.toString() + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); int ccId = c.getCategory().getId(); int cId = c.getId(); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java index b33caff9..87a2b4f4 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java @@ -3,6 +3,7 @@ package com.songoda.skyblock.command.commands.island; import java.io.File; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.skyblock.island.IslandManager; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -24,6 +25,7 @@ public class ChallengeCommand extends SubCommand { SoundManager soundManager = skyblock.getSoundManager(); FileManager fileManager = skyblock.getFileManager(); FabledChallenge fabledChallenge = skyblock.getFabledChallenge(); + IslandManager islandManager = skyblock.getIslandManager(); Config langConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration langConfigLoad = langConfig.getFileConfiguration(); @@ -36,6 +38,15 @@ public class ChallengeCommand extends SubCommand { return; } if (args.length == 0) { + if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland")){ + if(islandManager.getIsland(player) == null){ + messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.NoIsland.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + return; + } + } + // Open challenge inventory ChallengeCategory cc = fabledChallenge.getChallengeManager().getChallenge(1); if (cc == null) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java index bcb4c3ea..19a8cbc9 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java @@ -1,22 +1,27 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent; import com.songoda.skyblock.api.event.player.PlayerIslandChatSwitchEvent; import com.songoda.skyblock.command.SubCommand; +import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.placeholder.PlaceholderManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; +import java.util.UUID; public class ChatCommand extends SubCommand { @@ -26,6 +31,7 @@ public class ChatCommand extends SubCommand { MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); SoundManager soundManager = skyblock.getSoundManager(); + FileManager fileManager = skyblock.getFileManager(); Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -33,32 +39,73 @@ public class ChatCommand extends SubCommand { Island island = islandManager.getIsland(player); PlayerData playerData = playerDataManager.getPlayerData(player); - if (playerData.isChat() && island != null) { - Bukkit.getServer().getPluginManager() - .callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), false)); - playerData.setChat(false); + if(args.length == 0){ + if (playerData.isChat() && island != null) { + Bukkit.getServer().getPluginManager() + .callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), false)); + playerData.setChat(false); - messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message")); - soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); - return; - } + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message")); + soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); + return; + } - if (island == null) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()) == 0) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Team.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if ((islandManager.getMembersOnline(island).size() - 1) <= 0) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Offline.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + if (island == null) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } else if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()) == 0) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Team.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } else if ((islandManager.getMembersOnline(island).size() - 1) <= 0) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Offline.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } else { + Bukkit.getServer().getPluginManager() + .callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), true)); + playerData.setChat(true); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); + } } else { - Bukkit.getServer().getPluginManager() - .callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), true)); - playerData.setChat(true); + if (playerDataManager.hasPlayerData(player)) { + if (playerData.getOwner() != null) { + island = skyblock.getIslandManager().getIsland(player); + } - messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); + String islandRole = ""; + + if (island.hasRole(IslandRole.Member, player.getUniqueId())) { + islandRole = configLoad.getString("Island.Chat.Format.Role.Member"); + } else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) { + islandRole = configLoad.getString("Island.Chat.Format.Role.Operator"); + } else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { + islandRole = configLoad.getString("Island.Chat.Format.Role.Owner"); + } + + Island finalIsland = island; + String finalIslandRole = islandRole; + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(), + String.join(" ", args), configLoad.getString("Island.Chat.Format.Message")); + Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); + + if (!islandChatEvent.isCancelled()) { + for (UUID islandMembersOnlineList : islandManager.getMembersOnline(finalIsland)) { + Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); + String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, + islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName()))) + .replace("%message", islandChatEvent.getMessage()); + targetPlayer.sendMessage(message); + } + + if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { + messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName()) + .replace("%message", islandChatEvent.getMessage())); + } + } + }); + } } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java index 204d44b9..47e8146d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/DeleteCommand.java @@ -5,6 +5,10 @@ import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.confirmation.Confirmation; +import com.songoda.skyblock.cooldown.Cooldown; +import com.songoda.skyblock.cooldown.CooldownManager; +import com.songoda.skyblock.cooldown.CooldownPlayer; +import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; @@ -12,6 +16,7 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.ChatComponent; +import com.songoda.skyblock.utils.NumberUtil; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; @@ -28,6 +33,7 @@ public class DeleteCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { + CooldownManager cooldownManager = skyblock.getCooldownManager(); MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); SoundManager soundManager = skyblock.getSoundManager(); @@ -44,6 +50,32 @@ public class DeleteCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Owner.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); } else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { + if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable") + && cooldownManager.hasPlayer(CooldownType.Deletion, player)) { + CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Deletion, player); + Cooldown cooldown = cooldownPlayer.getCooldown(); + + if (cooldown.getTime() < 60) { + messageManager.sendMessage(player, + config.getFileConfiguration().getString("Island.Deletion.Cooldown.Message") // TODO Add language.yml values + .replace("%time", cooldown.getTime() + " " + config.getFileConfiguration() + .getString("Island.Deletion.Cooldown.Word.Second"))); + } else { + long[] durationTime = NumberUtil.getDuration(cooldown.getTime()); + messageManager.sendMessage(player, + config.getFileConfiguration().getString("Island.Deletion.Cooldown.Message") + .replace("%time", durationTime[2] + " " + + config.getFileConfiguration() + .getString("Island.Deletion.Cooldown.Word.Minute") + + " " + durationTime[3] + " " + config.getFileConfiguration() + .getString("Island.Deletion.Cooldown.Word.Second"))); + } + + soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + + return; + } if (playerData.getConfirmationTime() > 0) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/KickAllCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/KickAllCommand.java index 11794bf7..4f2f9251 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/KickAllCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/KickAllCommand.java @@ -49,7 +49,9 @@ public class KickAllCommand extends SubCommand { for (UUID islandVisitorList : islandVisitors) { Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitorList); - if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban")) + if (targetPlayer != null && + (targetPlayer.hasPermission("fabledskyblock.bypass.ban") || + targetPlayer.hasPermission("fabledskyblock.bypass.kick"))) continue; IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java index a4563ebb..53976a39 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/KickCommand.java @@ -72,7 +72,12 @@ public class KickCommand extends SubCommand { targetPlayerName = targetPlayer.getName(); } - if (targetPlayerUUID.equals(player.getUniqueId())) { + assert targetPlayer != null; + if(targetPlayer.hasPermission("fabledskyblock.bypass.kick") && islandVisitors.contains(targetPlayer.getUniqueId())){ + // messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt")); // TODO + messageManager.sendMessage(player, "&cNon puoi cacciare questo utente!"); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } else if (targetPlayerUUID.equals(player.getUniqueId())) { messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (islandOperators.contains(player.getUniqueId()) && islandOperators.contains(targetPlayerUUID)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java index f4d7510b..89479fc1 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java @@ -11,9 +11,13 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; +import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.visit.Visit; import com.songoda.skyblock.visit.VisitManager; import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.Waterlogged; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -105,8 +109,13 @@ public class TeleportCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTask(skyblock, () -> { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); - player.setFallDistance(0.0F); + Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); + LocationUtil.removeWaterFromLoc(skyblock, loc); + player.teleport(loc); + + if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ + player.setFallDistance(0.0F); + } }); } } diff --git a/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java b/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java index 9418e52d..37f9b99b 100644 --- a/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java +++ b/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java @@ -36,7 +36,7 @@ public class CooldownManager { for (Player all : Bukkit.getOnlinePlayers()) { CooldownPlayer cooldownPlayer = null; - if (cooldownTypeList == CooldownType.Biome || cooldownTypeList == CooldownType.Creation) { + if (cooldownTypeList == CooldownType.Biome || cooldownTypeList == CooldownType.Creation || cooldownTypeList == CooldownType.Deletion) { cooldownPlayer = loadCooldownPlayer(cooldownTypeList, all); } else if (cooldownTypeList == CooldownType.Levelling || cooldownTypeList == CooldownType.Ownership) { Island island = islandManager.getIsland(all); @@ -69,7 +69,7 @@ public class CooldownManager { } public CooldownPlayer loadCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) { - if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) { + if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { Config config = skyblock.getFileManager() .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -99,7 +99,7 @@ public class CooldownManager { int time = 0; - if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) { + if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getInt("Island." + cooldownType.name() + ".Cooldown.Time"); @@ -139,7 +139,7 @@ public class CooldownManager { public void deletePlayer(CooldownType cooldownType, OfflinePlayer player) { for (Iterator it = getCooldownPlayersOrEmptyList(cooldownType).iterator(); it.hasNext();) { if (it.next().getUUID().equals(player.getUniqueId())) { - if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) { + if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { skyblock.getFileManager() .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")) @@ -197,7 +197,7 @@ public class CooldownManager { public void setCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) { for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) { if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) { - if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) { + if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { skyblock.getFileManager() .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")) @@ -222,7 +222,7 @@ public class CooldownManager { public void saveCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) { Config config = null; - if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) { + if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { config = skyblock.getFileManager() .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); } else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) { diff --git a/src/main/java/com/songoda/skyblock/cooldown/CooldownType.java b/src/main/java/com/songoda/skyblock/cooldown/CooldownType.java index f96010b4..7d0a31bb 100644 --- a/src/main/java/com/songoda/skyblock/cooldown/CooldownType.java +++ b/src/main/java/com/songoda/skyblock/cooldown/CooldownType.java @@ -8,6 +8,7 @@ public enum CooldownType { Biome, Creation, + Deletion, Levelling, Ownership, Teleport; diff --git a/src/main/java/com/songoda/skyblock/generator/Generator.java b/src/main/java/com/songoda/skyblock/generator/Generator.java index ea4c7382..0e5a53f1 100644 --- a/src/main/java/com/songoda/skyblock/generator/Generator.java +++ b/src/main/java/com/songoda/skyblock/generator/Generator.java @@ -1,19 +1,22 @@ package com.songoda.skyblock.generator; import com.songoda.core.compatibility.CompatibleMaterial; - +import com.songoda.skyblock.island.IslandWorld; + import java.util.List; public class Generator { private String name; + private IslandWorld isWorld; private CompatibleMaterial materials; private List generatorMaterials; private boolean permission; - public Generator(String name, CompatibleMaterial materials, List generatorMaterials, boolean permission) { + public Generator(String name, IslandWorld isWorld, CompatibleMaterial materials, List generatorMaterials, boolean permission) { this.name = name; + this.isWorld = isWorld; this.materials = materials; this.generatorMaterials = generatorMaterials; this.permission = permission; @@ -23,6 +26,10 @@ public class Generator { return name; } + public IslandWorld getIsWorld() { + return isWorld; + } + public CompatibleMaterial getMaterials() { return materials; } diff --git a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java index 61f430e6..fc822d1e 100644 --- a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java +++ b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java @@ -4,7 +4,8 @@ import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager.Config; - + +import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -56,6 +57,7 @@ public class GeneratorManager { } generatorStorage.add(new Generator(configLoad.getString("Generators." + generatorList + ".Name"), + IslandWorld.valueOf(configLoad.getString("Generators." + generatorList + ".World", "Normal")), oreMaterials[rnd.nextInt(oreMaterials.length)], generatorMaterials, configLoad.getBoolean("Generators." + generatorList + ".Permission"))); } @@ -150,10 +152,10 @@ public class GeneratorManager { return CompatibleMaterial.COBBLESTONE; } - public void addGenerator(String name, List generatorMaterials, boolean permission) { + public void addGenerator(String name, IslandWorld isWorld, List generatorMaterials, boolean permission) { CompatibleMaterial[] oreMaterials = new CompatibleMaterial[]{CompatibleMaterial.COAL, CompatibleMaterial.CHARCOAL, CompatibleMaterial.DIAMOND, CompatibleMaterial.IRON_INGOT, CompatibleMaterial.GOLD_INGOT, CompatibleMaterial.EMERALD}; - generatorStorage.add(new Generator(name, oreMaterials[new Random().nextInt(oreMaterials.length)], + generatorStorage.add(new Generator(name, isWorld, oreMaterials[new Random().nextInt(oreMaterials.length)], generatorMaterials, permission)); } diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 5faf476c..bc72846e 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -52,7 +52,6 @@ public class Island { this.skyblock = SkyBlock.getInstance(); FileManager fileManager = skyblock.getFileManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); this.islandUUID = UUID.randomUUID(); this.ownerUUID = player.getUniqueId(); @@ -113,7 +112,7 @@ public class Island { } if (configLoad.getString("Border") == null) { - configLoad.set("Border.Enable", true); + configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false)); configLoad.set("Border.Color", WorldBorder.Color.Blue.name()); } @@ -162,10 +161,10 @@ public class Island { } for (IslandRole roleList : IslandRole.getRoles()) { - List permissions = new ArrayList<>(); - - for (BasicPermission permission : skyblock.getPermissionManager().getPermissions()) { + List allPermissions = skyblock.getPermissionManager().getPermissions(); + List permissions = new ArrayList<>(allPermissions.size()); + for (BasicPermission permission : allPermissions) { if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration() .getString("Settings." + roleList.name() + "." + permission.getName()) == null) { permissions.add( @@ -184,10 +183,10 @@ public class Island { configLoad.set("UUID", islandUUID.toString()); configLoad.set("Visitor.Open", mainConfigLoad.getBoolean("Island.Visitor.Open")); - configLoad.set("Border.Enable", true); + configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false)); configLoad.set("Border.Color", WorldBorder.Color.Blue.name()); configLoad.set("Biome.Type", mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase()); - configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised")); + configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised")); // TODO: Synchronized configLoad.set("Weather.Time", mainConfigLoad.getInt("Island.Weather.Default.Time")); configLoad.set("Weather.Weather", mainConfigLoad.getString("Island.Weather.Default.Weather").toUpperCase()); configLoad.set("Ownership.Original", ownerUUID.toString()); @@ -198,7 +197,8 @@ public class Island { for (BasicPermission permission : allPermissions) { permissions.add( - new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + permission, true))); + new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration() + .getBoolean("Settings." + roleList.name() + "." + permission.getName(), true))); } islandPermissions.put(roleList, permissions); diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java index cd26c143..be1825f3 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java @@ -114,7 +114,15 @@ public class IslandLevel { division = 1; } - return getPoints() / division; + long points = getPoints(); + long subtract = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Subtract"); + if(points >= subtract){ + points -= subtract; + } else { + points = 0; + } + + return points / division; } public void checkLevelUp() { diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 1577302e..f25eb3b8 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -61,7 +61,7 @@ public class IslandManager { private List islandPositions = new ArrayList<>(); private Map islandProxies = new HashMap<>(); private Map islandStorage = new HashMap<>(); - private int offset = 1200; + private int offset; private HashMap oldSystemIslands; @@ -71,6 +71,9 @@ public class IslandManager { Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "worlds.yml")); FileConfiguration configLoad = config.getFileConfiguration(); + offset = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")) + .getFileConfiguration().getInt("Island.Creation.Distance", 1200); + for (IslandWorld worldList : IslandWorld.values()) { ConfigurationSection configSection = configLoad.getConfigurationSection("World." + worldList.name() + ".nextAvailableLocation"); islandPositions.add(new IslandPosition(worldList, configSection.getDouble("x"), configSection.getDouble("z"))); @@ -241,6 +244,9 @@ public class IslandManager { if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) skyblock.getCooldownManager().createPlayer(CooldownType.Creation, player); + if (configLoad.getBoolean("Island.Deletion.Cooldown.Deletion.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") + && !player.hasPermission("fabledskyblock.*")) + skyblock.getCooldownManager().createPlayer(CooldownType.Deletion, player); Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player))); @@ -455,6 +461,16 @@ public class IslandManager { fileManager.unloadConfig(newIslandDataFile); oldIslandDataFile.renameTo(newIslandDataFile); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)){ + File oldChallengeDataFile = new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), uuid2.toString() + ".yml"); + File newChallengeDataFile = new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), player.getUniqueId().toString() + ".yml"); + + fileManager.unloadConfig(oldChallengeDataFile); + fileManager.unloadConfig(newChallengeDataFile); + oldChallengeDataFile.renameTo(newChallengeDataFile); + } + skyblock.getVisitManager().transfer(uuid2, player.getUniqueId()); skyblock.getBanManager().transfer(uuid2, player.getUniqueId()); skyblock.getInviteManager().tranfer(uuid2, player.getUniqueId()); @@ -509,8 +525,6 @@ public class IslandManager { } } - int j = 0; - public boolean deleteIsland(Island island, boolean force) { ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); @@ -566,7 +580,8 @@ public class IslandManager { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - boolean cooldownEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable"); + boolean cooldownCreationEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable"); + boolean cooldownDeletionEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable"); config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); configLoad = config.getFileConfiguration(); @@ -590,11 +605,26 @@ public class IslandManager { LocationUtil.teleportPlayerToSpawn(all); } - if (cooldownEnabled) { + // TODO - Find a way to delete also offline players + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Deletion.ClearInventory", false)){ + all.getInventory().clear(); + } + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Deletion.ClearEnderChest", false)){ + all.getEnderChest().clear(); + } + + if (cooldownCreationEnabled) { if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) { skyblock.getCooldownManager().createPlayer(CooldownType.Creation, all); } } + if (cooldownDeletionEnabled) { + if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) { + skyblock.getCooldownManager().createPlayer(CooldownType.Deletion, all); + } + } } InviteManager inviteManager = skyblock.getInviteManager(); @@ -612,6 +642,10 @@ public class IslandManager { fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), island.getOwnerUUID().toString() + ".yml")); fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID().toString() + ".yml")); fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)){ + fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID().toString() + ".yml")); + } Bukkit.getServer().getPluginManager().callEvent(new IslandDeleteEvent(island.getAPIWrapper())); @@ -627,6 +661,10 @@ public class IslandManager { fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/level-data", uuid.toString() + ".yml")); fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", uuid.toString() + ".yml")); fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/visit-data", uuid.toString() + ".yml")); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)){ + fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/challenge-data", uuid.toString() + ".yml")); + } } public Island loadIsland(org.bukkit.OfflinePlayer player) { @@ -851,6 +889,11 @@ public class IslandManager { fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID() + ".yml")); fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), island.getOwnerUUID() + ".yml")); + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", true)){ + fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID() + ".yml")); + } + islandStorage.remove(island.getOwnerUUID()); Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper())); @@ -1033,8 +1076,17 @@ public class IslandManager { FileConfiguration configLoad = languageConfig.getFileConfiguration(); if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - player.setFallDistance(0.0F); + Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); + if(loc != null){ + player.teleport(loc); + if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ + player.setFallDistance(0.0F); + } + } else { + player.sendMessage(ChatColor.translateAlternateColorCodes('&', + Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Island.Teleport.Unsafe.Message")))); + } } else { if (scoreboardManager != null) { int islandVisitors = getVisitorsAtIsland(island).size(), islandMembers = island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1; @@ -1052,8 +1104,6 @@ public class IslandManager { } else { scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname"))); scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); - - } scoreboard.run(); @@ -1063,8 +1113,23 @@ public class IslandManager { } Bukkit.getServer().getScheduler().runTask(skyblock, () -> { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - player.setFallDistance(0.0F); + Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor); + if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { + loc = LocationUtil.getSafeLocation(loc); + } + if(loc != null){ + player.teleport(loc); + if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ + player.setFallDistance(0.0F); + } + } else { + player.sendMessage(ChatColor.translateAlternateColorCodes('&', + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message"))); + } + if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ + player.setFallDistance(0.0F); + } }); List islandWelcomeMessage = island.getMessage(IslandMessage.Welcome); @@ -1429,7 +1494,7 @@ public class IslandManager { } for (Player all : getPlayersAtIsland(island)) { - WorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island)); + WorldBorder.send(all, island.getBorderColor(), island.getSize()+2, island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island)); } } } diff --git a/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java b/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java index 5dd588df..d772b8c7 100644 --- a/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java +++ b/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java @@ -7,6 +7,8 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.limit.EnumLimitation; import com.songoda.skyblock.utils.player.PlayerUtil; import com.songoda.skyblock.utils.version.CompatibleSpawners; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -54,13 +56,16 @@ public final class BlockLimitation extends EnumLimitation { } - @SuppressWarnings("deprecation") public long getBlockLimit(Player player, Block block) { - if (player == null || block == null) return -1; + return this.getBlockLimit(player, block.getType()); + } + + public long getBlockLimit(Player player, Material type) { + if (player == null || type == null) return -1; if (player.hasPermission("fabledskyblock.limit.block.*")) return -1; - final CompatibleMaterial material = CompatibleMaterial.getMaterial(block.getType()); + final CompatibleMaterial material = CompatibleMaterial.getMaterial(type); if (material == null) return -1; @@ -69,19 +74,22 @@ public final class BlockLimitation extends EnumLimitation { return Math.max(getMap().getOrDefault(material, getDefault()), PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.block." + name, true, -1)); } - @SuppressWarnings("deprecation") public boolean isBlockLimitExceeded(Block block, long limit) { + return this.isBlockLimitExceeded(block.getType(), block.getLocation(), limit); + } + + public boolean isBlockLimitExceeded(Material type, Location loc, long limit) { if (limit == -1) return false; final IslandManager islandManager = SkyBlock.getInstance().getIslandManager(); - final Island island = islandManager.getIslandAtLocation(block.getLocation()); + final Island island = islandManager.getIslandAtLocation(loc); final long totalPlaced; - if (block.getType() == CompatibleMaterial.SPAWNER.getBlockMaterial()) { + if (type == CompatibleMaterial.SPAWNER.getBlockMaterial()) { totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum(); } else { - totalPlaced = island.getLevel().getMaterialAmount(CompatibleMaterial.getMaterial(block.getType()).name()); + totalPlaced = island.getLevel().getMaterialAmount(CompatibleMaterial.getMaterial(type).name()); } return limit <= totalPlaced; diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 57b41bb1..3e084222 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -20,14 +20,13 @@ import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; import org.apache.commons.lang.WordUtils; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.*; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.CreatureSpawner; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -192,6 +191,10 @@ public class Block implements Listener { Island island = islandManager.getIslandAtLocation(blockLoc); + // Check permissions. + if (!skyblock.getPermissionManager().processPermission(event, player, island)) + return; + if (island == null) { event.setCancelled(true); return; @@ -204,14 +207,34 @@ public class Block implements Listener { return; } - // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) - return; - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); IslandWorld world = worldManager.getIslandWorld(block.getWorld()); + if(!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)){ + for(String s : Objects.requireNonNull(configLoad.getConfigurationSection("Island.Restrict.NetherBlocks")).getKeys(false)){ + if(s.equalsIgnoreCase(block.getType().toString())){ + if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s)){ + skyblock.getMessageManager().sendMessage(player, Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message"))); + event.setCancelled(true); + } + } + } + } + + if(!player.hasPermission("fabledskyblock.bypass.endplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.End)){ + for(String s : Objects.requireNonNull(configLoad.getConfigurationSection("Island.Restrict.EndBlocks")).getKeys(false)){ + if(s.equalsIgnoreCase(block.getType().toString())){ + if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){ + skyblock.getMessageManager().sendMessage(player, Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message"))); + event.setCancelled(true); + } + } + } + } + if (configLoad.getBoolean("Island.WorldBorder.Block") && block.getType() == Material.DISPENSER) { if (!islandManager.isLocationAtIsland(island, blockLoc, world)) { event.setCancelled(true); @@ -296,6 +319,32 @@ public class Block implements Listener { return; } + // Nether mobs + if(configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)){ + Collection entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d); + if(entities.size() > 0){ + EntityCycle: for(Entity ent : entities){ + switch(ent.getType()){ + case PIG_ZOMBIE: + case BLAZE: + case MAGMA_CUBE: + case WITHER_SKELETON: + case WITHER: + case GHAST: + if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){ + event.setCancelled(true); + event.getToBlock().getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); + event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); + } + break EntityCycle; // TODO No spaghetti code + default: + break; + } + } + } + } + + // Generators if (NMSUtil.getVersionNumber() < 12) { if (generatorManager != null && generatorManager.getGenerators().size() > 0 && generatorManager.isGenerator(block)) { List generators = new ArrayList<>(generatorManager.getGenerators()); @@ -313,23 +362,25 @@ public class Block implements Listener { // Find highest generator available for (Generator generator : generators) { - for (Player p : possiblePlayers) { + if(generator.getIsWorld().equals(world)){ + for (Player p : possiblePlayers) { - if (generator.isPermission() && - !p.hasPermission(generator.getPermission()) && - !p.hasPermission("fabledskyblock.generator.*") && - !p.hasPermission("fabledskyblock.*")) { - continue; + if (generator.isPermission() && + !p.hasPermission(generator.getPermission()) && + !p.hasPermission("fabledskyblock.generator.*") && + !p.hasPermission("fabledskyblock.*")) { + continue; + } + + org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block); + org.bukkit.block.BlockState toBlockState = event.getToBlock().getState(); + + toBlockState.setData(genState.getData()); + toBlockState.setType(genState.getType()); + toBlockState.update(); + updateLevel(island, genState.getLocation()); + return; } - - org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block); - org.bukkit.block.BlockState toBlockState = event.getToBlock().getState(); - - toBlockState.setData(genState.getData()); - toBlockState.setType(genState.getType()); - toBlockState.update(); - updateLevel(island, genState.getLocation()); - return; } } } @@ -534,7 +585,9 @@ public class Block implements Listener { boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) || island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Coop, player.getUniqueId()) || - island.hasRole(IslandRole.Operator, player.getUniqueId()); + island.hasRole(IslandRole.Operator, player.getUniqueId()) || + (island.getVisit().getVisitors().contains(player.getUniqueId()) && + player.hasPermission("fabledskyblock.generator.anywhere")); if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) { possiblePlayers.add(player); @@ -550,12 +603,14 @@ public class Block implements Listener { } } - org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block); - state.setType(genState.getType()); + if(worldManager.getIslandWorld(event.getBlock().getWorld()).equals(generator.getIsWorld())){ + org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block); + state.setType(genState.getType()); - if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData()); - updateLevel(island, genState.getLocation()); - return; + if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData()); + updateLevel(island, genState.getLocation()); + return; + } } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 45842642..14d8e7b0 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -2,6 +2,7 @@ package com.songoda.skyblock.listeners; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.*; import com.songoda.skyblock.limit.impl.EntityLimitaton; @@ -54,22 +55,32 @@ public class Entity implements Listener { @EventHandler public void onEntityDamage(EntityDamageEvent event) { IslandManager islandManager = skyblock.getIslandManager(); - if (!(event.getEntity() instanceof Player)) { - return; - } + if(event.getEntity() instanceof Blaze){ + WorldManager worldManager = skyblock.getWorldManager(); - Player player = (Player) event.getEntity(); + Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); - if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { - // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); - } + if(configLoad.getBoolean("Island.Nether.BlazeImmuneToWaterInNether", false) && + worldManager.getIslandWorld(event.getEntity().getWorld()).equals(IslandWorld.Nether)){ + if(event.getCause().equals(DamageCause.DROWNING)){ + event.setCancelled(true); + } + } + } else if (event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); - // Fix a bug in minecraft where arrows with flame still apply fire ticks even if - // the shot entity isn't damaged - if (preventFireTicks.contains(player.getUniqueId()) && event.getCause() == DamageCause.FIRE_TICK) { - player.setFireTicks(0); - event.setCancelled(true); + if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { + // Check permissions. + skyblock.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); + } + + // Fix a bug in minecraft where arrows with flame still apply fire ticks even if + // the shot entity isn't damaged + if (preventFireTicks.contains(player.getUniqueId()) && event.getCause() == DamageCause.FIRE_TICK) { + player.setFireTicks(0); + event.setCancelled(true); + } } } @@ -513,12 +524,20 @@ public class Entity implements Listener { EntityType type = entity.getType(); if (limits.isBeingTracked(type)) { - long count = limits.getEntityCount(island, skyblock.getWorldManager().getIslandWorld(entityLocation.getWorld()), type); + FileManager fileManager = skyblock.getFileManager(); + Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); - if (limits.hasTooMuch(count + 1, type)) { - entity.remove(); - event.setCancelled(true); - return; + boolean isSplit = event.getSpawnReason().equals(SpawnReason.SLIME_SPLIT); + boolean splitBypass = configLoad.getBoolean("Island.Challenge.PerIsland", true); + + if(!isSplit || !splitBypass){ + long count = limits.getEntityCount(island, skyblock.getWorldManager().getIslandWorld(entityLocation.getWorld()), type); + if (limits.hasTooMuch(count + 1, type)) { + entity.remove(); + event.setCancelled(true); + return; + } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 49a14c00..b13b2185 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -18,11 +18,11 @@ import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.structure.StructureUtil; +import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; import org.apache.commons.lang.WordUtils; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; +import org.bukkit.*; +import org.bukkit.block.BlockFace; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -48,6 +48,87 @@ public class Interact implements Listener { this.skyblock = skyblock; } + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onWaterPlace(PlayerInteractEvent event){ + if(event.getItem() == null) return; + Player player = event.getPlayer(); + org.bukkit.block.Block block = event.getClickedBlock().getRelative(event.getBlockFace()); + + IslandManager islandManager = skyblock.getIslandManager(); + WorldManager worldManager = skyblock.getWorldManager(); + IslandLevelManager levellingManager = skyblock.getLevellingManager(); + if (!worldManager.isIslandWorld(block.getWorld())) return; + + if (event.getAction() == Action.RIGHT_CLICK_BLOCK && + worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether) && + event.getItem().getType().equals(Material.WATER_BUCKET)){ + Location blockLoc = block.getLocation(); + + Island island = islandManager.getIslandAtLocation(blockLoc); + + // Check permissions. + if (!skyblock.getPermissionManager().processPermission(event, player, island)) + return; + + if (island == null) { + event.setCancelled(true); + return; + } + + if (levellingManager.isScanning(island)) { + skyblock.getMessageManager().sendMessage(player, + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message")); + event.setCancelled(true); + return; + } + + FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + IslandWorld world = worldManager.getIslandWorld(block.getWorld()); + + // Check spawn protection + if (configLoad.getBoolean("Island.Spawn.Protection")) { + boolean isObstructing = false; + // Directly on the block + if (LocationUtil.isLocationAffectingIslandSpawn(blockLoc, island, world)) { + isObstructing = true; + } + + if (isObstructing) { + skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message")); + skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + + event.setCancelled(true); + return; + } + } + + BlockLimitation limits = skyblock.getLimitationHandler().getInstance(BlockLimitation.class); + + long limit = limits.getBlockLimit(player, Material.WATER); + + if (limits.isBlockLimitExceeded(event.getItem().getType(), block.getLocation(), limit)) { + CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getItem().getType()); + + skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message") + .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit))); + skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + + event.setCancelled(true); + return; + } + + if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){ + event.setCancelled(true); + block.setType(Material.WATER, true); + block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f); + if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){ + event.getItem().setType(Material.BUCKET); + } + } + } + } + @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index 1b47536c..9777b402 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -100,6 +100,7 @@ public class Join implements Listener { cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player)); cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player)); + cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player)); if (scoreboardManager != null) { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 55cf5071..0fb33b34 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -2,6 +2,7 @@ package com.songoda.skyblock.listeners; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.command.commands.island.TeleportCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.*; @@ -13,9 +14,9 @@ import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; -import org.bukkit.Bukkit; -import org.bukkit.Location; +import org.bukkit.*; import org.bukkit.attribute.Attribute; +import org.bukkit.block.data.Waterlogged; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -26,6 +27,7 @@ import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.potion.PotionEffect; import java.io.File; +import java.util.Objects; public class Move implements Listener { @@ -73,15 +75,7 @@ public class Move implements Listener { Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland())); if (island != null) { - if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) - || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); - } else { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - } - - player.setFallDistance(0.0F); - soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + teleportPlayerToIslandSpawn(player, soundManager, island); return; } @@ -116,16 +110,7 @@ public class Move implements Listener { if (to.getY() <= configLoad.getInt("Island.World." + world.name() + ".Liquid.Height")) { if (keepItemsOnDeath && configLoad.getBoolean("Island.Liquid.Teleport.Enable")) { player.setFallDistance(0.0F); - - if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) - || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); - } else { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - } - - player.setFallDistance(0.0F); - soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + teleportPlayerToIslandSpawn(player, soundManager, island); } return; } @@ -139,7 +124,7 @@ public class Move implements Listener { player.setExp(0.0F); if (NMSUtil.getVersionNumber() > 8) { - player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); + player.setHealth(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue()); } else { player.setHealth(player.getMaxHealth()); } @@ -150,16 +135,10 @@ public class Move implements Listener { player.removePotionEffect(potionEffect.getType()); } } - player.setFallDistance(0.0F); if (configLoad.getBoolean("Island.Void.Teleport.Island")) { - if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) - || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); - } else { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - } + teleportPlayerToIslandSpawn(player, island); } else { LocationUtil.teleportPlayerToSpawn(player); } @@ -169,14 +148,16 @@ public class Move implements Listener { } } } else { - if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius() + 0.5)) { - if (island.getVisit().isVisitor(player.getUniqueId())) { - player.teleport(island.getLocation(world, IslandEnvironment.Visitor)); - } else { - player.teleport(island.getLocation(world, IslandEnvironment.Main)); + if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius())) { + teleportPlayerToIslandSpawn(player, world, island); + Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + + if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ + player.setFallDistance(0.0F); } - player.setFallDistance(0.0F); messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration() .getString("Island.WorldBorder.Outside.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); @@ -204,6 +185,50 @@ public class Move implements Listener { } } + private void teleportPlayerToIslandSpawn(Player player, IslandWorld world, Island island) { + Location loc; + if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) + || island.hasRole(IslandRole.Owner, player.getUniqueId())) { + if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { + loc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main)); + } else { + loc = island.getLocation(world, IslandEnvironment.Main); + LocationUtil.removeWaterFromLoc(skyblock, loc); + } + } else { + if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { + loc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor)); + } else { + loc = island.getLocation(world, IslandEnvironment.Visitor); + } + } + if(loc != null){ + player.teleport(loc); + } else { + LocationUtil.teleportPlayerToSpawn(player); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', + Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message")))); + } + } + + private void teleportPlayerToIslandSpawn(Player player, Island island) { + this.teleportPlayerToIslandSpawn(player, IslandWorld.Normal, island); + } + + private void teleportPlayerToIslandSpawn(Player player, SoundManager soundManager, Island island) { + teleportPlayerToIslandSpawn(player, island); + + FileManager fileManager = skyblock.getFileManager(); + Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ + player.setFallDistance(0.0F); + } + soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTeleport(PlayerTeleportEvent e) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 03c79bd1..2dc5a66d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -2,6 +2,7 @@ package com.songoda.skyblock.listeners; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.utils.LocationUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -15,6 +16,7 @@ import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -131,21 +133,13 @@ public class Portal implements Listener { switch (toWorld) { case Nether: if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) { - IslandWorld toWorldF = toWorld; - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L); - soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); - player.setFallDistance(0.0F); - tick.setTick(1); + teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld); } break; case End: if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) { - IslandWorld toWorldF = toWorld; - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L); - soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); - player.setFallDistance(0.0F); - tick.setTick(1); + teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld); } break; @@ -160,6 +154,21 @@ public class Portal implements Listener { } + private void teleportPlayerToWorld(Player player, SoundManager soundManager, Island island, IslandEnvironment spawnEnvironment, Tick tick, IslandWorld toWorld) { + IslandWorld toWorldF = toWorld; + Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> { + Location loc = island.getLocation(toWorldF, spawnEnvironment); + Location safeLoc = LocationUtil.getSafeLocation(loc); + if(safeLoc != null){ + loc = safeLoc; + } + player.teleport(loc); + }, 1L); + soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + player.setFallDistance(0.0F); + tick.setTick(1); + } + public static class Tick { private int tick = 1; private long last = System.currentTimeMillis() - 1001; diff --git a/src/main/java/com/songoda/skyblock/listeners/Quit.java b/src/main/java/com/songoda/skyblock/listeners/Quit.java index daa024a9..6e4b735f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Quit.java +++ b/src/main/java/com/songoda/skyblock/listeners/Quit.java @@ -2,6 +2,8 @@ package com.songoda.skyblock.listeners; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.challenge.challenge.ChallengeManager; +import com.songoda.skyblock.challenge.player.PlayerManager; import com.songoda.skyblock.cooldown.CooldownManager; import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.invite.Invite; @@ -44,6 +46,7 @@ public class Quit implements Listener { MessageManager messageManager = skyblock.getMessageManager(); InviteManager inviteManager = skyblock.getInviteManager(); IslandManager islandManager = skyblock.getIslandManager(); + PlayerManager challengePlayerManager = skyblock.getFabledChallenge().getPlayerManager(); PlayerData playerData = playerDataManager.getPlayerData(player); @@ -91,9 +94,42 @@ public class Quit implements Listener { cooldownManager.setCooldownPlayer(CooldownType.Creation, player); cooldownManager.removeCooldownPlayer(CooldownType.Creation, player); + cooldownManager.setCooldownPlayer(CooldownType.Deletion, player); + cooldownManager.removeCooldownPlayer(CooldownType.Deletion, player); + playerDataManager.savePlayerData(player); playerDataManager.unloadPlayerData(player); + boolean offline = true; + if(island != null && skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Challenge.PerIsland", false)){ + if(island.getRole(IslandRole.Member) != null){ + for(UUID uuid : island.getRole(IslandRole.Member)){ + if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){ + offline = false; + } + } + } + if(offline && island.getRole(IslandRole.Operator) != null){ + for(UUID uuid : island.getRole(IslandRole.Operator)){ + if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){ + offline = false; + } + } + } + if(offline && island.getRole(IslandRole.Owner) != null){ + for(UUID uuid : island.getRole(IslandRole.Owner)){ + if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){ + offline = false; + } + } + } + } + + if(offline){ + challengePlayerManager.unloadPlayer(player.getUniqueId()); + } + for (Island islandList : islandManager.getCoopIslands(player)) { if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Coop.Unload") || islandList.getCoopType(player.getUniqueId()) == IslandCoop.TEMP) { @@ -129,6 +165,6 @@ public class Quit implements Listener { } }); // Unload Challenge - SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(event.getPlayer().getUniqueId()); + SkyBlock.getInstance().getFabledChallenge().getPlayerManager().unloadPlayer(event.getPlayer().getUniqueId()); } } diff --git a/src/main/java/com/songoda/skyblock/menus/Border.java b/src/main/java/com/songoda/skyblock/menus/Border.java index dc72f77d..f03bacef 100644 --- a/src/main/java/com/songoda/skyblock/menus/Border.java +++ b/src/main/java/com/songoda/skyblock/menus/Border.java @@ -165,54 +165,67 @@ public class Border { configLoad.getStringList("Menu.Border.Item.Toggle.Lore"), new Placeholder[]{new Placeholder("%toggle", borderToggle)}, null, null), 1); - if (borderColor == WorldBorder.Color.Blue) { - nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(), - configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", - configLoad.getString("Menu.Border.Item.Word.Blue")), - configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"), - new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))}, - null, null), 2); + if(player.hasPermission("fabledskyblock.island.border.blue")){ + if (borderColor == WorldBorder.Color.Blue) { + nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(), + configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", + configLoad.getString("Menu.Border.Item.Word.Blue")), + configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"), + new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))}, + null, null), 2); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(), + configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", + configLoad.getString("Menu.Border.Item.Word.Blue")), + configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"), + new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))}, + null, null), 2); + } } else { - nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(), - configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", - configLoad.getString("Menu.Border.Item.Word.Blue")), - configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"), - new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))}, - null, null), 2); + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + "", null, null, null, null), 2); } - - if (borderColor == WorldBorder.Color.Green) { - nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(), - configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", - configLoad.getString("Menu.Border.Item.Word.Green")), - configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"), - new Placeholder[]{ - new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))}, - null, null), 3); + if(player.hasPermission("fabledskyblock.island.border.green")){ + if (borderColor == WorldBorder.Color.Green) { + nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(), + configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", + configLoad.getString("Menu.Border.Item.Word.Green")), + configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"), + new Placeholder[]{ + new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))}, + null, null), 3); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(), + configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", + configLoad.getString("Menu.Border.Item.Word.Green")), + configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"), + new Placeholder[]{ + new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))}, + null, null), 3); + } } else { - nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(), - configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", - configLoad.getString("Menu.Border.Item.Word.Green")), - configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"), - new Placeholder[]{ - new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))}, - null, null), 3); + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + "", null, null, null, null), 3); } - - if (borderColor == WorldBorder.Color.Red) { - nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(), - configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", - configLoad.getString("Menu.Border.Item.Word.Red")), - configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"), - new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))}, - null, null), 4); + if(player.hasPermission("fabledskyblock.island.border.red")){ + if (borderColor == WorldBorder.Color.Red) { + nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(), + configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", + configLoad.getString("Menu.Border.Item.Word.Red")), + configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"), + new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))}, + null, null), 4); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(), + configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", + configLoad.getString("Menu.Border.Item.Word.Red")), + configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"), + new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))}, + null, null), 4); + } } else { - nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(), - configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color", - configLoad.getString("Menu.Border.Item.Word.Red")), - configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"), - new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))}, - null, null), 4); + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + "", null, null, null, null), 4); } nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Border.Title"))); diff --git a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java index 5d7175fa..9af4c2e4 100644 --- a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java +++ b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java @@ -93,34 +93,85 @@ public final class ControlPanel { }); // Teleport to island and open/close island - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Teleport.Lore"), null, null, null), 1); - nInv.addItem(nInv.createItem(CompatibleMaterial.IRON_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Lock.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Lock.Lore"), null, null, null), 10); + if(player.hasPermission("fabledskyblock.island.teleport")){ + nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Teleport.Lore"), null, null, null), 1); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 1); + } + + if(player.hasPermission("fabledskyblock.island.close")){ + nInv.addItem(nInv.createItem(CompatibleMaterial.IRON_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Lock.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Lock.Lore"), null, null, null), 10); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 10); + } // Glass panes barriers nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 0, 2, 5, 8, 9, 11, 14, 17); // 4 Items at the left - nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.EXPERIENCE_BOTTLE.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Level.Lore"), null, null, null), 3); - nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Settings.Lore"), null, null, null), 4); - nInv.addItem(nInv.createItem(CompatibleMaterial.CLOCK.getItem(), configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Weather.Lore"), null, null, null), 12); - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(), configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Biome.Lore"), null, null, null), 13); + if(player.hasPermission("fabledskyblock.island.level")){ + nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.EXPERIENCE_BOTTLE.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Level.Lore"), null, null, null), 3); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 3); + } + if(player.hasPermission("fabledskyblock.island.settings")){ + nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Settings.Lore"), null, null, null), 4); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 4); + } + if(player.hasPermission("fabledskyblock.island.weather")){ + nInv.addItem(nInv.createItem(CompatibleMaterial.CLOCK.getItem(), configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Weather.Lore"), null, null, null), 12); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 12); + } + if(player.hasPermission("fabledskyblock.island.biome")){ + nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(), configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Biome.Lore"), null, null, null), 13); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 13); + } // 4 Items at the right - nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME), configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Members.Lore"), null, null, null), 16); - nInv.addItem(nInv.createItem(new ItemStack(Material.IRON_AXE), configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Bans.Lore"), null, null, new ItemFlag[] { ItemFlag.HIDE_ATTRIBUTES }), 6); - nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Visitors.Lore"), null, null, null), 7); - nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.ANVIL.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Upgrades.Displayname"), - configLoad.getStringList("Menu.ControlPanel.Item.Upgrades.Lore"), null, null, null), 15); + if(player.hasPermission("fabledskyblock.island.members")){ + nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME), configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Members.Lore"), null, null, null), 16); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 16); + } + if(player.hasPermission("fabledskyblock.island.bans")){ + nInv.addItem(nInv.createItem(new ItemStack(Material.IRON_AXE), configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Bans.Lore"), null, null, new ItemFlag[] { ItemFlag.HIDE_ATTRIBUTES }), 6); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 6); + } + if(player.hasPermission("fabledskyblock.island.visitors")){ + nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Visitors.Lore"), null, null, null), 7); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 7); + } + if(player.hasPermission("fabledskyblock.island.upgrade")){ + nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.ANVIL.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Upgrades.Displayname"), + configLoad.getStringList("Menu.ControlPanel.Item.Upgrades.Lore"), null, null, null), 15); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 15); + } nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title"))); nInv.setRows(2); diff --git a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java index 8b84a114..892521f7 100644 --- a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java +++ b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java @@ -109,16 +109,22 @@ public class Leaderboard { new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.Level.name())}, null, null), 1); - nInv.addItem( - nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad - .getString( - "Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname") - .replace("%leaderboard", Viewer.Type.Bank.name()), - configLoad.getStringList( - "Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), - new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.Bank.name())}, null, - null), - 2); + + if(fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")){ + nInv.addItem( + nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad + .getString( + "Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname") + .replace("%leaderboard", Viewer.Type.Bank.name()), + configLoad.getStringList( + "Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), + new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.Bank.name())}, null, + null), + 2); + } else { + nInv.addItem( + nInv.createItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), "", null, null, null, null), 2); + } nInv.addItem( nInv.createItem(new ItemStack(Material.EMERALD), configLoad .getString( diff --git a/src/main/java/com/songoda/skyblock/menus/Visitors.java b/src/main/java/com/songoda/skyblock/menus/Visitors.java index e7187130..5e0ffc0d 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visitors.java +++ b/src/main/java/com/songoda/skyblock/menus/Visitors.java @@ -134,7 +134,7 @@ public class Visitors { Bukkit.getServer().dispatchCommand(player, "island kick " + playerName); } } else { - if (banningEnabled && ((isOperator && canBan) || isOwner)) { + if (banningEnabled && ((isOperator && canBan))) { Bukkit.getServer().dispatchCommand(player, "island ban " + playerName); } else { soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, @@ -159,24 +159,28 @@ public class Visitors { Set islandVisitors = islandManager.getVisitorsAtIsland(island); Map sortedIslandVisitors = new TreeMap<>(); + for (UUID islandVisitorList : islandVisitors) { + Player targetPlayer = Bukkit.getPlayer(islandVisitorList); + if(targetPlayer != null && player.canSee(targetPlayer)){ // Remove vanished players + sortedIslandVisitors.put( + playerDataManager.getPlayerData(targetPlayer).getVisitTime(), + islandVisitorList); + } + } + nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Visitors.Item.Exit.Displayname"), null, null, null, null), 0, 8); nInv.addItem( nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Visitors.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Visitors.Item.Statistics.Lore"), - new Placeholder[]{new Placeholder("%visitors", "" + islandVisitors.size())}, null, null), + new Placeholder[]{new Placeholder("%visitors", "" + sortedIslandVisitors.size())}, null, null), 4); nInv.addItem( nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.Visitors.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - for (UUID islandVisitorList : islandVisitors) { - sortedIslandVisitors.put( - playerDataManager.getPlayerData(Bukkit.getServer().getPlayer(islandVisitorList)).getVisitTime(), - islandVisitorList); - } islandVisitors.clear(); diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java index fd819e6b..7eb193c3 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java @@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.generator.GeneratorManager; import com.songoda.skyblock.generator.GeneratorMaterial; +import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; @@ -277,7 +278,7 @@ public class Generator implements Listener { configLoad.getString("Island.Admin.Generator.Characters.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { - generatorManager.addGenerator(event1.getName(), new ArrayList<>(), false); + generatorManager.addGenerator(event1.getName(), IslandWorld.Normal, new ArrayList<>(), false); messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Created.Message") diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 32adb7fe..4eee2198 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -26,86 +26,84 @@ public class PermissionManager { public PermissionManager(SkyBlock plugin) { this.plugin = plugin; - Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> { - // Load default permissions. - registerPermissions( - //Listening - new StoragePermission(plugin), - new DragonEggUsePermission(plugin), - new BeaconPermission(plugin), - new ProjectilePermission(plugin), - new DestroyPermission(plugin), - new AnvilPermission(plugin), - new BedPermission(plugin), - new BrewingPermission(plugin), - new WorkbenchPermission(plugin), - new DoorPermission(plugin), - new EnchantPermission(plugin), - new FurnacePermission(plugin), - new LeverButtonPermission(plugin), - new JukeboxPermission(plugin), - new HopperPermission(plugin), - new NoteblockPermission(plugin), - new RedstonePermission(plugin), - new GatePermission(plugin), - new DropperDispenserPermission(plugin), - new BucketPermission(plugin), - new WaterCollectionPermission(plugin), - new SpawnEggPermission(plugin), - new EntityPlacementPermission(plugin), - new FirePermission(plugin), - new TramplePermission(plugin), - new PressurePlatePermission(plugin), - new CakePermission(plugin), - new PlacePermission(plugin), - new LeashPermission(plugin), - new AnimalBreedingPermission(plugin), - new MinecartPermission(plugin), - new BoatPermission(plugin), - new TradingPermission(plugin), - new MilkingPermission(plugin), - new ShearingPermission(plugin), - new MobRidingPermission(plugin), - new HorseInventoryPermission(plugin), - new MobHurtingPermission(plugin), - new ArmorStandUsePermission(plugin), - new MonsterHurtingPermission(plugin), - new PvpPermission(plugin), - new HangingDestroyPermission(plugin), - new DamagePermission(plugin), - new ExplosionsPermission(plugin), - new MobTamingPermission(plugin), - new MobGriefingPermission(plugin), - new ExperienceOrbPickupPermission(plugin), - new NaturalMobSpawningPermission(), - new HungerPermission(plugin), - new PortalPermission(plugin), - new ItemPickupPermission(), - new ItemDropPermission(), - new FishingPermission(plugin), + // Load default permissions. + registerPermissions( + //Listening + new StoragePermission(plugin), + new DragonEggUsePermission(plugin), + new BeaconPermission(plugin), + new ProjectilePermission(plugin), + new DestroyPermission(plugin), + new AnvilPermission(plugin), + new BedPermission(plugin), + new BrewingPermission(plugin), + new WorkbenchPermission(plugin), + new DoorPermission(plugin), + new EnchantPermission(plugin), + new FurnacePermission(plugin), + new LeverButtonPermission(plugin), + new JukeboxPermission(plugin), + new HopperPermission(plugin), + new NoteblockPermission(plugin), + new RedstonePermission(plugin), + new GatePermission(plugin), + new DropperDispenserPermission(plugin), + new BucketPermission(plugin), + new WaterCollectionPermission(plugin), + new SpawnEggPermission(plugin), + new EntityPlacementPermission(plugin), + new FirePermission(plugin), + new TramplePermission(plugin), + new PressurePlatePermission(plugin), + new CakePermission(plugin), + new PlacePermission(plugin), + new LeashPermission(plugin), + new AnimalBreedingPermission(plugin), + new MinecartPermission(plugin), + new BoatPermission(plugin), + new TradingPermission(plugin), + new MilkingPermission(plugin), + new ShearingPermission(plugin), + new MobRidingPermission(plugin), + new HorseInventoryPermission(plugin), + new MobHurtingPermission(plugin), + new ArmorStandUsePermission(plugin), + new MonsterHurtingPermission(plugin), + new PvpPermission(plugin), + new HangingDestroyPermission(plugin), + new DamagePermission(plugin), + new ExplosionsPermission(plugin), + new MobTamingPermission(plugin), + new MobGriefingPermission(plugin), + new ExperienceOrbPickupPermission(plugin), + new NaturalMobSpawningPermission(), + new HungerPermission(plugin), + new PortalPermission(plugin), + new ItemPickupPermission(), + new ItemDropPermission(), + new FishingPermission(plugin), - // Basic - new MemberPermission(), - new VisitorPermission(), - new KickPermission(), - new BiomePermission(), - new KeepItemsOnDeathPermission(), - new UnbanPermission(), - new BanPermission(), - new BorderPermission(), - new FireSpreadPermission(), - new CoopPlayersPermission(), - new IslandPermission(), - new LeafDecayPermission(), - new WeatherPermission(), - new MainSpawnPermission(), - new VisitorSpawnPermission()); + // Basic + new MemberPermission(), + new VisitorPermission(), + new KickPermission(), + new BiomePermission(), + new KeepItemsOnDeathPermission(), + new UnbanPermission(), + new BanPermission(), + new BorderPermission(), + new FireSpreadPermission(), + new CoopPlayersPermission(), + new IslandPermission(), + new LeafDecayPermission(), + new WeatherPermission(), + new MainSpawnPermission(), + new VisitorSpawnPermission()); - registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> { - final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class); - return permissionHandler.priority().ordinal(); - })).collect(Collectors.toList()); - }, 20L); + registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> { + final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class); + return permissionHandler.priority().ordinal(); + })).collect(Collectors.toList()); } public boolean registerPermission(BasicPermission permission) { diff --git a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java new file mode 100644 index 00000000..5ae7bd69 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java @@ -0,0 +1,87 @@ +package com.songoda.skyblock.tasks; + +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.hologram.Hologram; +import com.songoda.skyblock.hologram.HologramType; +import com.songoda.skyblock.island.IslandLevel; +import com.songoda.skyblock.island.IslandWorld; +import com.songoda.skyblock.leaderboard.Leaderboard; +import com.songoda.skyblock.leaderboard.LeaderboardManager; +import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.skyblock.utils.player.OfflinePlayer; +import com.songoda.skyblock.utils.world.LocationUtil; +import com.songoda.skyblock.visit.Visit; +import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class MobNetherWaterTask extends BukkitRunnable { + + private static MobNetherWaterTask instance; + private static SkyBlock plugin; + + public MobNetherWaterTask(SkyBlock plug) { + plugin = plug; + } + + public static MobNetherWaterTask startTask(SkyBlock plug) { + plugin = plug; + if (instance == null) { + instance = new MobNetherWaterTask(plugin); + instance.runTaskTimer(plugin, 0, 2L); + } + + return instance; + } + + @Override + public void run() { + FileManager fileManager = plugin.getFileManager(); + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false)){ + for(World world : Bukkit.getServer().getWorlds()){ + if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){ + for(Entity ent : world.getEntities()){ + switch(ent.getType()){ + case PIG_ZOMBIE: + case BLAZE: + case MAGMA_CUBE: + case WITHER_SKELETON: + case WITHER: + case GHAST: + Block block = ent.getLocation().getBlock(); + if(block.getType().equals(Material.WATER)){ + block.setType(Material.AIR, true); + world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); + world.playEffect(block.getLocation(), Effect.SMOKE, 1); + } + block = block.getRelative(BlockFace.UP); + if(block.getType().equals(Material.WATER)){ + block.setType(Material.AIR, true); + world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); + world.playEffect(block.getLocation(), Effect.SMOKE, 1); + } + default: + break; + } + } + } + } + } + } + + public void onDisable() { + } + + +} diff --git a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java index bbabc85c..722233ad 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -15,6 +15,7 @@ import org.bukkit.*; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; import java.io.File; @@ -25,6 +26,100 @@ import java.util.logging.Level; public final class LocationUtil { + public static void removeWaterFromLoc(SkyBlock plugin, Location loc) { + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.RemoveWater", false)){ + Location tempLoc = LocationUtil.getDefinitiveLocation(loc); + if(tempLoc.getBlock().getType().equals(Material.WATER)){ + tempLoc.getBlock().setType(Material.AIR); + } else if(tempLoc.getBlock().getBlockData() instanceof Waterlogged){ + Waterlogged blockData = (Waterlogged) tempLoc.getBlock().getBlockData(); + blockData.setWaterlogged(false); + tempLoc.getBlock().setBlockData(blockData); + } + } + } + + public static Location getSafeLocation(Location loc){ + boolean found = false; + Location locChecked = loc.clone(); + loc.getWorld().loadChunk(loc.getWorld().getChunkAt(loc)); + for(int i=loc.getBlockY(); i>=0 && !found; i--){ + locChecked = locChecked.subtract(0d, 1d, 0d); + found = checkBlock(locChecked); + } + if(!found){ + for(int i=loc.getBlockY(); i<256 && !found; i++){ + locChecked = locChecked.add(0d, 1d, 0d); + found = checkBlock(locChecked); + } + } + if (found) { + locChecked = locChecked.add(0d,1d,0d); + } else { + locChecked = null; + } + return locChecked; + } + + public static Location getDefinitiveLocation(Location loc){ + Location locWorking = loc.clone(); + for(int i=locWorking.getBlockY(); i>=0; i--){ + if(!locWorking.getBlock().isEmpty()){ + if(locWorking.getBlock().getType().equals(Material.WATER) || locWorking.getBlock().getBlockData() instanceof Waterlogged){ + loc = locWorking; + } + break; + } + } + return loc; + } + + private static boolean checkBlock(Location locChecked) { + boolean safe = false; + if(!locChecked.getBlock().isEmpty() && + !locChecked.getBlock().isLiquid() && + !locChecked.getBlock().isPassable() && + locChecked.getBlock().getType().isSolid() && + locChecked.getBlock().getType().isBlock() && + locChecked.add(0d,1d,0d).getBlock().getType().isAir() && + locChecked.add(0d,2d,0d).getBlock().getType().isAir() && + !(locChecked.getBlock().getBlockData() instanceof Waterlogged)){ + safe = true; + switch(locChecked.getBlock().getType()){ + case ACACIA_BUTTON: + case ACACIA_DOOR: + case ACACIA_FENCE_GATE: + case ACACIA_TRAPDOOR: + case BIRCH_DOOR: + case BIRCH_FENCE_GATE: + case BIRCH_TRAPDOOR: + case CACTUS: + case CAKE: + case CAMPFIRE: + case COBWEB: + case DARK_OAK_DOOR: + case DARK_OAK_FENCE_GATE: + case DARK_OAK_TRAPDOOR: + case IRON_TRAPDOOR: + case JUNGLE_DOOR: + case JUNGLE_FENCE_GATE: + case JUNGLE_TRAPDOOR: + case LADDER: + case MAGMA_BLOCK: + case NETHER_PORTAL: + case OAK_DOOR: + case OAK_FENCE_GATE: + case SPRUCE_DOOR: + case SPRUCE_FENCE_GATE: + safe = false; + break; + } + } + + return safe; + } + public static boolean isLocationLocation(Location location1, Location location2) { return location1.getBlockX() == location2.getBlockX() && location1.getBlockY() == location2.getBlockY() && location1.getBlockZ() == location2.getBlockZ(); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 730e3cff..e68afb67 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -32,10 +32,25 @@ Island: # When enabled cooldown will start when a player deletes their Island. Deletion: Enable: true - # Time until player can create another island. + # Time in seconds until player can create another island. Time: 60 # [!] How many seconds to wait before teleporting to a newly created island TeleportTimeout: 1 + # The distance between the islands + Distance: 1200 + Deletion: + # [!] 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: true + # When enabled cooldown will start when a player deletes their Island. + Deletion: + Enable: true + # Time in seconds until player can delete their island. + Time: 60 + ClearInventory: false + ClearEnderChest: false World: # Delete the Island world when changing the liquid option. # If lava disabled, the world will be a water world. @@ -87,6 +102,8 @@ Island: # Prevent blocks being placed that would go outside of the Island border # Pistons | Dispensers | Liquid Flow Block: true + # Enabled/Disabled by default + Default: false Spawn: # Prevents blocks being placed inside the location where players spawn on # an Island. When setting the spawn points, this option when enabled will @@ -191,6 +208,8 @@ Island: IncludeEmptyPointsInList: true # Island Level Points divided by value Division: 100 + # Points to subtract to Island Level Points + Subtract: 1000 Cooldown: # Time until Island level rescan expires Time: 60 @@ -308,3 +327,54 @@ Island: Challenge: # Enable or disable challenges. Configuration for challenges are in challenges.yml file Enable: true + # Disabling this will make challenges per player + PerIsland: true + Teleport: + # Enable or disable Fall damage + FallDamage: true + RemoveWater: true + Limits: + # Should slime split bypass limits.yml + AllowSlimeSplit: true + Nether: + AllowNetherWater: false + WaterDisappearWithNetherMobs: false + WaterDoNotFlowNearNetherMobs: false + BlazeImmuneToWaterInNether: false + Restrict: + NetherBlocks: + NETHERRACK: true + SOUL_SAND: true + GLOWSTONE: true + NETHER_BRICKS: true + NETHER_BRICK_STAIRS: true + NETHER_BRICK_SLAB: true + NETHER_QUARTZ_ORE: true + QUARTZ_BLOCK: true + QUARTZ_PILLAR: true + CHISELED_QUARTZ_BLOCK: true + QUARTZ_STAIRS: true + NETHER_BRICK_WALL: true + NETHER_BRICK_FENCE: true + RED_NETHER_BRICKS: true + RED_NETHER_BRICK_STAIRS: true + RED_NETHER_BRICK_SLAB: true + RED_NETHER_BRICK_WALL: true + NETHER_WART: true + NETHER_WART_BLOCK: true + WITHER_SKELETON_SKULL: true + WITHER_ROSE: true + EndBlocks: + END_STONE: true + END_STONE_BRICKS: true + END_STONE_BRICK_WALL: true + END_STONE_BRICK_STAIRS: true + END_STONE_BRICK_SLAB: true + PURPUR_BLOCK: true + PURPUR_SLAB: true + PURPUR_PILLAR: true + PURPUR_STAIRS: true + END_ROD: true + END_CRYSTAL: true + CHORUS_FLOWER: true + CHORUS_PLANT: true \ No newline at end of file diff --git a/src/main/resources/generators.yml b/src/main/resources/generators.yml index 923ee7f2..842098f2 100644 --- a/src/main/resources/generators.yml +++ b/src/main/resources/generators.yml @@ -1,6 +1,7 @@ Generators: - Default: - Name: Default + Normal: + Name: Normal + World: Normal Permission: false Materials: COBBLESTONE: @@ -14,4 +15,22 @@ Generators: EMERALD_ORE: Chance: 5.5 DIAMOND_ORE: - Chance: 2.5 \ No newline at end of file + Chance: 2.5 + Nether: + Name: Nether + World: Nether + Permission: false + Materials: + NETHERRACK: + Chance: 80 + GLOWSTONE: + Chance: 10.0 + QUARTZ_ORE: + Chance: 10.0 + End: + Name: End + World: End + Permission: false + Materials: + END_STONE: + Chance: 100.0 \ No newline at end of file diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 7a63ec40..d4f45456 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -905,6 +905,8 @@ Command: Message: '&bSkyBlock &8| &aInfo&8: &eYou have been teleported to your Island.' Other: Message: '&bSkyBlock &8| &aInfo&8: &eYou have been teleported to &a%player''s &eIsland.' + Unsafe: + Message: '&bSkyBlock &8| &cError&8: &eNo safe position found' Create: Owner: Message: '&bSkyBlock &8| &cError&8: &eYou are already an Island Owner.' @@ -988,6 +990,8 @@ Command: Message: '&bSkyBlock &8| &cError&8: &eCategory not found.' ChallengeNotFound: Message: '&bSkyBlock &8| &cError&8: &eChallenge not found.' + NoIsland: + Message: '&bSkyBlock &8| &cError&8: &eYou don''t have an island.' Preview: Info: Message: '&f&oAllows you to preview island before choosing' @@ -3462,6 +3466,12 @@ Island: Message: '&bSkyBlock &8| &cError&8: &eThat Structure does not exist.' File: Message: '&bSkyBlock &8| &cError&8: &eThat file does not exist in the Structures directory.' + Deletion: + Cooldown: + Word: + Minute: minute(s) + Second: second(s) + Message: '&bSkyBlock &8| &cError&8: &eYou must wait &c&o%time &ebefore deleting an Island.' Creator: Selector: Created: @@ -3578,6 +3588,10 @@ Island: Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock the Nether. To do that use &7/island unlock nether&e This will cost ''&7$%cost%&e''.' End: Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock The End. To do that use &7/island unlock end&e This will cost ''&7$%cost%&e''.' + NetherBlocksPlace: + Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock the Nether in order to place this block.' + EndBlocksPlace: + Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock The End in order to place this block.' Settings: Visitor: Welcome: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d44cd917..c1218e25 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,6 +4,7 @@ version: maven-version-number api-version: 1.13 description: A unique SkyBlock plugin author: Songoda +authors: [Fabrimat] softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit] loadbefore: [Multiverse-Core, ProtocolLib] commands: