From 4b9f543b0a5ff3e02449e08bdc60877db27e8175 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 16 Jun 2020 19:17:28 +0200 Subject: [PATCH 001/366] Initial work to add maxMembers upgrade --- .../com/songoda/skyblock/island/Island.java | 24 + .../songoda/skyblock/menus/Information.java | 6 +- .../com/songoda/skyblock/menus/Upgrade.java | 113 +++++ .../songoda/skyblock/menus/admin/Upgrade.java | 478 +++++++++++++++++- .../com/songoda/skyblock/upgrade/Upgrade.java | 2 +- .../skyblock/upgrade/UpgradeManager.java | 41 ++ src/main/resources/config.yml | 1 + src/main/resources/language.yml | 101 +++- src/main/resources/upgrades.yml | 10 + 9 files changed, 757 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index bc72846e..2c112ae3 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -46,6 +46,7 @@ public class Island { private UUID ownerUUID; private IslandLevel level; private int size; + private int maxMembers; private boolean deleted = false; public Island(OfflinePlayer player) { @@ -57,6 +58,8 @@ public class Island { this.ownerUUID = player.getUniqueId(); this.size = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getInt("Island.Size.Minimum"); + this.maxMembers = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getInt("Island.InitialMaxMembers", 3); if (this.size > 1000) { this.size = 50; @@ -99,6 +102,12 @@ public class Island { configLoad.set("UUID", islandUUID.toString()); } + if (configLoad.getString("MaxMembers") != null) { + maxMembers = configLoad.getInt("MaxMembers"); + } else { + configLoad.set("MaxMembers", maxMembers); + } + if (configLoad.getString("Size") != null) { size = configLoad.getInt("Size"); } @@ -256,6 +265,21 @@ public class Island { .getFileConfiguration().getString("Ownership.Original")); } + public int getMaxMembers() { + return maxMembers; + } + + public void setMaxMembers(int maxMembers) { + if (maxMembers > 100000 || maxMembers < 0) { + maxMembers = 2; + } + + this.maxMembers = maxMembers; + skyblock.getFileManager().getConfig( + new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + .getFileConfiguration().set("MaxMembers", maxMembers); + } + public int getSize() { return size; } diff --git a/src/main/java/com/songoda/skyblock/menus/Information.java b/src/main/java/com/songoda/skyblock/menus/Information.java index 50044f23..82a330f5 100644 --- a/src/main/java/com/songoda/skyblock/menus/Information.java +++ b/src/main/java/com/songoda/skyblock/menus/Information.java @@ -346,10 +346,8 @@ public class Information { new Placeholder[]{ new Placeholder("%island_members", "" + (islandMembers.size() + islandOperators.size() + 1)), - new Placeholder("%island_capacity", - "" + skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) - .getFileConfiguration().getInt("Island.Member.Capacity")), + new Placeholder("%island_maxMembers", // %island_capacity + "" + island.getMaxMembers()), new Placeholder("%members", "" + islandMembers.size()), new Placeholder("%operators", "" + islandOperators.size())}, null, null), diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java index 09ec20a2..ee097aa8 100644 --- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java @@ -355,6 +355,59 @@ public class Upgrade { event.setWillDestroy(false); } } + } else if ((is.getType() == Material.BOOKSHELF) && (is.hasItemMeta())) { + List upgrades = upgradeManager + .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members); + + if (upgrades != null && upgrades.size() > 0) { + for (int i = 0; i < upgrades.size(); i++) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(i); + int tier = i + 1; + + if (is.getItemMeta().getDisplayName() + .equals(ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Members.Displayname") + .replace("%tier", "" + tier)))) { + if (upgrade.getValue() > island.getMaxMembers() + && upgrade.getValue() != island.getMaxMembers()) { + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + messageManager.sendMessage(player, + configLoad.getString("Island.Upgrade.Bought.Message").replace( + "%upgrade", is.getItemMeta().getDisplayName())); + soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, + 1.0F); + + EconomyManager.withdrawBalance(player, upgrade.getCost()); + island.setMaxMembers(upgrade.getValue()); + + Bukkit.getServer().getPluginManager().callEvent(new IslandUpgradeEvent( + island.getAPIWrapper(), player, APIUtil.fromImplementation( + com.songoda.skyblock.upgrade.Upgrade.Type.Members))); + + Bukkit.getServer().getScheduler().runTaskLater(skyblock, + () -> open(player), 1L); + } else { + messageManager.sendMessage(player, + configLoad.getString("Island.Upgrade.Money.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event.setWillClose(false); + event.setWillDestroy(false); + } + + return; + } + } + } + + messageManager.sendMessage(player, + configLoad.getString("Island.Upgrade.Claimed.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + + event.setWillClose(false); + event.setWillDestroy(false); + } } else if ((is.getType() == Material.BEACON) && (is.hasItemMeta())) { List upgrades = upgradeManager .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Size); @@ -678,6 +731,66 @@ public class Upgrade { } } + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members); + + if (upgrades != null && upgrades.size() > 0) { + for (int i = 0; i < upgrades.size(); i++) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(i); + int tier = i + 1; + + if (tier != upgrades.size()) { + if (upgrade.getValue() <= island.getMaxMembers()) { + continue; + } + } + + if (island.getMaxMembers() >= upgrade.getValue()) { + nInv.addItem(nInv.createItem(new ItemStack(Material.BOOKSHELF), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Members.Displayname").replace("%tier", + "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Members.Claimed.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%maxMembers", "" + upgrade.getValue())}, + null, null), 6); + } else { + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem( + nInv.createItem(new ItemStack(Material.BOOKSHELF), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Members.Displayname") + .replace("%tier", "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Members.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", + NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%maxMembers", "" + upgrade.getValue())}, + null, null), + 6); + } else { + nInv.addItem( + nInv.createItem(new ItemStack(Material.BOOKSHELF), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Members.Displayname") + .replace("%tier", "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Members.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", + NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%maxMembers", "" + upgrade.getValue())}, + null, null), + 6); + } + } + + break; + } + } + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Size); if (upgrades != null && upgrades.size() > 0) { diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java index 327a21db..d0602168 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java @@ -118,6 +118,15 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); + Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + } else if ((is.getType() == Material.BOOKSHELF) && (is.hasItemMeta()) + && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Members.Displayname"))))) { + viewer.setType(Viewer.Type.Members); + viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Members); + + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); + Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); } else if ((is.getType() == CompatibleMaterial.SPAWNER.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() @@ -270,7 +279,7 @@ public class Upgrade { new Placeholder[]{ new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, - null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); + null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); if (NMSVersion > 12) { PotionMeta pm = (PotionMeta) jumpPotion.getItemMeta(); @@ -288,7 +297,7 @@ public class Upgrade { new Placeholder[]{ new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, - null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 2); + null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Crop).get(0); nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), @@ -298,7 +307,7 @@ public class Upgrade { new Placeholder[]{ new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, - null, null), 3); + null, null), 2); upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Fly).get(0); nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), @@ -308,7 +317,7 @@ public class Upgrade { new Placeholder[]{ new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, - null, null), 4); + null, null), 3); upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Drops).get(0); nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), @@ -318,21 +327,37 @@ public class Upgrade { new Placeholder[]{ new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, - null, null), 5); + null, null), 4); - List upgrades = upgradeManager + // Size + List upgradesSize = upgradeManager .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Size); - int upgradeTiers = 0; + int upgradeTiersSize = 0; - if (upgrades != null) { - upgradeTiers = upgrades.size(); + if (upgradesSize != null) { + upgradeTiersSize = upgradesSize.size(); } nInv.addItem(nInv.createItem(new ItemStack(Material.BEACON), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Size.Displayname")), configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Size.Lore"), - new Placeholder[]{new Placeholder("%tiers", "" + upgradeTiers)}, null, null), 6); + new Placeholder[]{new Placeholder("%tiers", "" + upgradeTiersSize)}, null, null), 5); + + // Members + List upgradesMembers = upgradeManager + .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members); + int upgradeTiersMembers = 0; + + if (upgradesMembers != null) { + upgradeTiersMembers = upgradesMembers.size(); + } + + nInv.addItem(nInv.createItem(CompatibleMaterial.BOOKSHELF.getItem(), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Members.Displayname")), + configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Members.Lore"), + new Placeholder[]{new Placeholder("%tiers", "" + upgradeTiersMembers)}, null, null), 4); upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner).get(0); nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), @@ -342,12 +367,12 @@ public class Upgrade { new Placeholder[]{ new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), new Placeholder("%status", getStatus(upgrade))}, - null, null), 7); + null, null), 6); nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Exit.Displayname")), - null, null, null, null), 0, 8); + null, null, null, null), 8); nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Upgrade.Upgrades.Title"))); @@ -780,6 +805,433 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Size.Title"))); nInv.setRows(1); + Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + } else if (viewer.getType() == Viewer.Type.Members) { + nInventoryUtil nInv = new nInventoryUtil(player, event -> { + if (!(player.hasPermission("fabledskyblock.admin.upgrade") || player.hasPermission("fabledskyblock.admin.*") + || player.hasPermission("fabledskyblock.*"))) { + messageManager.sendMessage(player, + configLoad.getString("Island.Admin.Upgrade.Permission.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + + return; + } + + if (playerDataManager.hasPlayerData(player)) { + PlayerData playerData = playerDataManager.getPlayerData(player); + ItemStack is = event.getItem(); + + if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta()) + && (is.getItemMeta().getDisplayName() + .equals(ChatColor.translateAlternateColorCodes('&', configLoad + .getString("Menu.Admin.Upgrade.Members.Item.Return.Displayname"))))) { + playerData.setViewer(new Viewer(Viewer.Type.Upgrades, null)); + soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); + + Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta() + .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad + .getString("Menu.Admin.Upgrade.Members.Item.Information.Displayname"))))) { + List upgrades = upgradeManager + .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members); + + if (upgrades != null && upgrades.size() >= 5) { + messageManager.sendMessage(player, + configLoad.getString("Island.Admin.Upgrade.Tier.Limit.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + + event.setWillClose(false); + event.setWillDestroy(false); + } else { + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); + + Bukkit.getServer().getScheduler().runTaskLater(skyblock, + () -> { + AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { + if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { + if (playerDataManager.hasPlayerData(player) + && playerDataManager + .getPlayerData(player) != null) { + if (!event1.getName().matches("[0-9]+")) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Numerical.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event1.setWillClose(false); + event1.setWillDestroy(false); + + return; + } else { + List upgrades1 = upgradeManager + .getUpgrades( + com.songoda.skyblock.upgrade.Upgrade.Type.Members); + + if (upgrades1 != null && upgrades1.size() >= 5) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Tier.Limit.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + Bukkit.getServer().getScheduler() + .runTaskLater(skyblock, + () -> open(player), 1L); + + return; + } + } + + int size = Integer.valueOf(event1.getName()); + + if (size > 1000) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Tier.Members.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event.setWillClose(false); + event.setWillDestroy(false); + + return; + } else if (upgradeManager.hasUpgrade( + com.songoda.skyblock.upgrade.Upgrade.Type.Members, + size)) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Tier.Exist.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event1.setWillClose(false); + event1.setWillDestroy(false); + + return; + } + + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F); + upgradeManager.addUpgrade( + com.songoda.skyblock.upgrade.Upgrade.Type.Members, + size); + + Bukkit.getServer().getScheduler() + .runTaskLater(skyblock, + () -> open(player), 1L); + } + + event1.setWillClose(true); + event1.setWillDestroy(true); + } else { + event1.setWillClose(false); + event1.setWillDestroy(false); + } + }); + + ItemStack is12 = new ItemStack(Material.NAME_TAG); + ItemMeta im = is12.getItemMeta(); + im.setDisplayName(configLoad + .getString("Menu.Admin.Upgrade.Members.Item.Word.Members.Enter")); + is12.setItemMeta(im); + + gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is12); + gui.open(); + }, 1L); + } + } else if ((is.getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial()) + && (is.hasItemMeta()) + && (is.getItemMeta().getDisplayName() + .equals(ChatColor.translateAlternateColorCodes('&', configLoad + .getString("Menu.Admin.Upgrade.Members.Item.Barrier.Displayname"))))) { + soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); + + event.setWillClose(false); + event.setWillDestroy(false); + } else if ((is.getType() == Material.PAPER) && (is.hasItemMeta())) { + int slot = event.getSlot(); + int tier = slot - 3; + + com.songoda.skyblock.upgrade.Upgrade upgrade = upgradeManager + .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members).get(tier); + + if (upgrade != null) { + if (event.getClick() == ClickType.LEFT) { + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); + + Bukkit.getServer().getScheduler().runTaskLater(skyblock, + () -> { + AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { + if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { + if (!(player.hasPermission("fabledskyblock.admin.upgrade") + || player.hasPermission("fabledskyblock.admin.*") + || player.hasPermission("fabledskyblock.*"))) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Permission.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + return; + } + + if (playerDataManager.hasPlayerData(player) + && playerDataManager + .getPlayerData(player) != null) { + if (!event1.getName().matches("[0-9]+")) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Numerical.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event1.setWillClose(false); + event1.setWillDestroy(false); + + return; + } else if (upgradeManager.getUpgrades( + com.songoda.skyblock.upgrade.Upgrade.Type.Members) + .get(tier) == null) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Tier.Selected.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + Bukkit.getServer().getScheduler() + .runTaskLater(skyblock, + () -> open(player), 1L); + + return; + } + + int size = Integer.valueOf(event1.getName()); + + if (size > 1000) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Tier.Members.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event.setWillClose(false); + event.setWillDestroy(false); + + return; + } else if (upgradeManager.hasUpgrade( + com.songoda.skyblock.upgrade.Upgrade.Type.Members, + size)) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Tier.Exist.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event.setWillClose(false); + event.setWillDestroy(false); + + return; + } + + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F); + upgradeManager.getUpgrades( + com.songoda.skyblock.upgrade.Upgrade.Type.Members) + .get(tier).setValue(size); + fileManager + .getConfig( + new File(skyblock.getDataFolder(), + "upgrades.yml")) + .getFileConfiguration() + .set("Upgrades.Members." + tier + ".Value", + size); + + Bukkit.getServer().getScheduler() + .runTaskLater(skyblock, + () -> open(player), 1L); + } + + event1.setWillClose(true); + event1.setWillDestroy(true); + } else { + event1.setWillClose(false); + event1.setWillDestroy(false); + } + }); + + ItemStack is13 = new ItemStack(Material.NAME_TAG); + ItemMeta im = is13.getItemMeta(); + im.setDisplayName(configLoad.getString( + "Menu.Admin.Upgrade.Members.Item.Word.Members.Enter")); + is13.setItemMeta(im); + + gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is13); + gui.open(); + }, 1L); + + return; + } else if (event.getClick() == ClickType.MIDDLE) { + soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); + upgradeManager.removeUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Members, + upgrade.getCost(), upgrade.getValue()); + } else if (event.getClick() == ClickType.RIGHT) { + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); + + Bukkit.getServer().getScheduler().runTaskLater(skyblock, + () -> { + AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { + if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { + if (!(player.hasPermission("fabledskyblock.admin.upgrade") + || player.hasPermission("fabledskyblock.admin.*") + || player.hasPermission("fabledskyblock.*"))) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Permission.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + return; + } + + if (playerDataManager.hasPlayerData(player) + && playerDataManager + .getPlayerData(player) != null) { + if (!(event1.getName().matches("[0-9]+") + || event1.getName().matches( + "([0-9]*)\\.([0-9]{2}$)"))) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Numerical.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + event1.setWillClose(false); + event1.setWillDestroy(false); + + return; + } else if (upgradeManager.getUpgrades( + com.songoda.skyblock.upgrade.Upgrade.Type.Members) + .get(tier) == null) { + messageManager.sendMessage(player, + configLoad.getString( + "Island.Admin.Upgrade.Tier.Selected.Message")); + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, + 1.0F); + + Bukkit.getServer().getScheduler() + .runTaskLater(skyblock, + () -> open(player), 1L); + + return; + } + + double cost = Double.valueOf(event1.getName()); + + soundManager.playSound(player, + CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F); + upgradeManager.getUpgrades( + com.songoda.skyblock.upgrade.Upgrade.Type.Members) + .get(tier).setCost(cost); + fileManager + .getConfig( + new File(skyblock.getDataFolder(), + "upgrades.yml")) + .getFileConfiguration() + .set("Upgrades.Members." + tier + ".Cost", + cost); + + Bukkit.getServer().getScheduler() + .runTaskLater(skyblock, + () -> open(player), 1L); + } + + event1.setWillClose(true); + event1.setWillDestroy(true); + } else { + event1.setWillClose(false); + event1.setWillDestroy(false); + } + }); + + ItemStack is14 = new ItemStack(Material.NAME_TAG); + ItemMeta im = is14.getItemMeta(); + im.setDisplayName(configLoad.getString( + "Menu.Admin.Upgrade.Members.Item.Word.Cost.Enter")); + is14.setItemMeta(im); + + gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is14); + gui.open(); + }, 1L); + + return; + } else { + event.setWillClose(false); + event.setWillDestroy(false); + + return; + } + } + + Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + } + } + }); + + nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Admin.Upgrade.Members.Item.Return.Displayname")), + null, null, null, null), 0); + nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Admin.Upgrade.Members.Item.Information.Displayname")), + configLoad.getStringList("Menu.Admin.Upgrade.Members.Item.Information.Lore"), null, null, null), + 1); + nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Admin.Upgrade.Members.Item.Barrier.Displayname")), + null, null, null, null), 2); + + List upgrades = upgradeManager + .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members); + + if (upgrades != null) { + for (int i = 0; i < 5; i++) { + if (upgrades.size() >= i + 1) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(i); + int tier = i + 1; + + if (upgrade != null) { + nInv.addItem(nInv.createItem(new ItemStack(Material.PAPER, tier), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Admin.Upgrade.Members.Item.Tier.Displayname") + .replace("%tier", "" + tier)), + configLoad.getStringList("Menu.Admin.Upgrade.Members.Item.Tier.Lore"), + new Placeholder[]{new Placeholder("%members", "" + upgrade.getValue()), + new Placeholder("%cost", + NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), i + 3); + } + } + } + } + + nInv.setTitle(ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Admin.Upgrade.Members.Title"))); + nInv.setRows(1); + Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); } } @@ -825,7 +1277,7 @@ public class Upgrade { public enum Type { - Upgrades, Size + Upgrades, Size, Members } } diff --git a/src/main/java/com/songoda/skyblock/upgrade/Upgrade.java b/src/main/java/com/songoda/skyblock/upgrade/Upgrade.java index 86053c92..8f951c07 100644 --- a/src/main/java/com/songoda/skyblock/upgrade/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/upgrade/Upgrade.java @@ -41,7 +41,7 @@ public class Upgrade { public enum Type { - Crop, Spawner, Fly, Drops, Size, Speed, Jump + Crop, Spawner, Fly, Drops, Size, Speed, Jump, Members } } diff --git a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java index c92b80db..88580882 100644 --- a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java +++ b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java @@ -54,6 +54,23 @@ public class UpgradeManager { upgradeStorage.put(Upgrade.Type.Size, upgrades); } + if (configLoad.getString("Upgrades.Members") != null) { + List upgrades = new ArrayList<>(); + + for (String tierList : configLoad.getConfigurationSection("Upgrades.Members").getKeys(false)) { + if (configLoad.getString("Upgrades.Members." + tierList + ".Value") != null) { + if (configLoad.getInt("Upgrades.Members." + tierList + ".Value") > 1000) { + continue; + } + } + + upgrades.add(new Upgrade(configLoad.getDouble("Upgrades.Members." + tierList + ".Cost"), + configLoad.getInt("Upgrades.Members." + tierList + ".Value"))); + } + + upgradeStorage.put(Upgrade.Type.Members, upgrades); + } + // Task for applying the speed & jump boost upgrades if the player is on an island that has them Bukkit.getScheduler().scheduleSyncRepeatingTask(SkyBlock.getInstance(), this::applyUpgrades, 5L, 20L); } @@ -85,6 +102,22 @@ public class UpgradeManager { configLoad.set("Upgrades.Size." + i + ".Cost", upgrade.getCost()); } + if (configLoad.getString("Upgrades.Members") != null) { + for (String tierList : configLoad.getConfigurationSection("Upgrades.Members").getKeys(false)) { + upgrades.add(new Upgrade(configLoad.getDouble("Upgrades.Members." + tierList + ".Cost"), + configLoad.getInt("Upgrades.Members." + tierList + ".Value"))); + } + } + + upgrades.add(new Upgrade(0, value)); + configLoad.set("Upgrades.Members", null); + + for (int i = 0; i < upgrades.size(); i++) { + Upgrade upgrade = upgrades.get(i); + configLoad.set("Upgrades.Members." + i + ".Value", upgrade.getValue()); + configLoad.set("Upgrades.Members." + i + ".Cost", upgrade.getCost()); + } + upgradeStorage.put(type, upgrades); try { @@ -111,6 +144,14 @@ public class UpgradeManager { configLoad.set("Upgrades.Size." + i + ".Cost", upgrade.getCost()); } + configLoad.set("Upgrades.Members", null); + + for (int i = 0; i < upgrades.size(); i++) { + Upgrade upgrade = upgrades.get(i); + configLoad.set("Upgrades.Members." + i + ".Value", upgrade.getValue()); + configLoad.set("Upgrades.Members." + i + ".Cost", upgrade.getCost()); + } + try { configLoad.save(config.getFile()); } catch (IOException e) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e68afb67..f87b8848 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -9,6 +9,7 @@ Sound: # When disabled all sounds will be disabled. Enable: true Island: + InitialMaxMembers: 3 Size: # [!] Do not go over 1000 for both of these options. # The size of an Island when created. diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index d4f45456..65a15e3f 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -273,6 +273,25 @@ Command: Message: '&bSkyBlock &8| &cError&8: &eYou must enter a numerical value.' Invalid: Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin setsize ' + SetMaxMembers: + Set: + Message: '&bSkyBlock &8| &aInfo&8: &eYou have set &d%player''s &eIsland max members amount to &d%maxMembers&e.' + Members: + Less: + Message: '&bSkyBlock &8| &cError&8: &eThe max members amount of the Island must be less than 100000.' + Greater: + Message: '&bSkyBlock &8| &cError&8: &eThe max members amount of the Island must be greater than 0.' + Info: + Message: '&f&oSets the max members amount of a player''s Island.' + Island: + Owner: + Message: '&bSkyBlock &8| &cError&8: &eThat player is not a Member of or does not own an Island.' + Data: + Message: '&bSkyBlock &8| &cError&8: &eThe Island data for that player''s Island does not exist.' + Numerical: + Message: '&bSkyBlock &8| &cError&8: &eYou must enter a numerical value.' + Invalid: + Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin setmaxmembers ' SetAlwaysLoaded: IsOn: Message: '&bSkyBlock &8| &aInfo&8: &eThis island will not unload.' @@ -1708,6 +1727,15 @@ Menu: - '&7Tiers&8: &f%tiers' - '' - '&eClick to manage tiers!' + Members: + Displayname: '&aBorder Size' + Lore: + - '&7Increases the max amount' + - '&7of Island members.' + - '' + - '&7Tiers&8: &f%tiers' + - '' + - '&eClick to manage tiers!' Fly: Displayname: '&aFlight' Lore: @@ -1784,6 +1812,35 @@ Menu: - '&eRight-Click to set cost!' Displayname: '&bTier #%tier' Title: '&8Upgrade Editor - Size' + Members: + Item: + Information: + Displayname: '&aInformation' + Lore: + - '&7Create tiers, and decide the' + - '&7cost and what upgrade Islands' + - '&7receive from them.' + - '' + - '&eClick to create a tier!' + Return: + Displayname: '&cReturn to Upgrade Editor' + Word: + Size: + Enter: Enter Members + Cost: + Enter: Enter Cost + Barrier: + Displayname: '&cMax members Tiers' + Tier: + Lore: + - '&7Max members&8: &f%maxMembers' + - '&7Cost&8: &f$%cost' + - '' + - '&eLeft-Click to set size!' + - '&eMiddle-Click to remove!' + - '&eRight-Click to set cost!' + Displayname: '&bTier #%tier' + Title: '&8Upgrade Editor - Members' Generator: Generator: Item: @@ -2067,7 +2124,7 @@ Menu: Statistics: Lore: - '&bIsland Members:' - - '&e%island_members/%island_capacity' + - '&e%island_members/%island_maxMembers' - '' - '&bMembers:' - '&e%members' @@ -2806,6 +2863,41 @@ Menu: - '' - '&cYou don''t have enough money!' Displayname: '&bBorder Size [Tier #%tier]' + Members: + Claimable: + Lore: + - '&7Increases the max members' + - '&7amount of your Island.' + - '' + - '&7Max members&8: &f%maxMembers' + - '&7Cost&8: &f$%cost' + - '' + - '&7Status&8: &6&lCLAIMABLE' + - '' + - '&eClick to unlock this upgrade!' + Claimed: + Lore: + - '&7Increases the max members' + - '&7amount of your Island.' + - '' + - '&7Max members&8: &f%maxMembers' + - '&7Cost&8: &f$%cost' + - '' + - '&7Status&8: &a&lCLAIMED' + - '' + - '&cYou have unlocked this upgrade!' + Unclaimable: + Lore: + - '&7Increases the max members' + - '&7amount of your Island.' + - '' + - '&7Max members&8: &f%maxMembers' + - '&7Cost&8: &f$%cost' + - '' + - '&7Status&8: &c&lLOCKED' + - '' + - '&cYou don''t have enough money!' + Displayname: '&bMax Members [Tier #%tier]' Word: Enable: Enable Disable: Disable @@ -3241,6 +3333,11 @@ Placeholder: Message: '&c0' Non-empty: Message: '&f%placeholder' + fabledskyblock_island_maxmembers: + Empty: + Message: '&c0' + Non-empty: + Message: '&f%placeholder' fabledskyblock_island_time: Non-empty: Message: '&f%placeholder' @@ -3432,6 +3529,8 @@ Island: Tier: Size: Message: '&bSkyBlock &8| &cError&8: &eThe size of the tier must be less than 1000.' + Members: + Message: '&bSkyBlock &8| &cError&8: &eThe size of the tier must be less than 100000.' Limit: Message: '&bSkyBlock &8| &cError&8: &eYou have reached the limit of tiers for this upgrade.' Selected: diff --git a/src/main/resources/upgrades.yml b/src/main/resources/upgrades.yml index ce956a05..5dae9ba8 100644 --- a/src/main/resources/upgrades.yml +++ b/src/main/resources/upgrades.yml @@ -30,6 +30,16 @@ Upgrades: 4: Value: 350 Cost: 500000 + Members: + 0: + Value: 5 + Cost: 10000 + 1: + Value: 7 + Cost: 20000 + 2: + Value: 10 + Cost: 30000 Spawner: Enable: true Cost: 100000 \ No newline at end of file From 0578c479bc3cac753a1100d3b69ff4c745b09072 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 17:55:05 +0200 Subject: [PATCH 002/366] Initial work to bank GUI --- .../songoda/skyblock/bank/BankManager.java | 5 +- .../java/com/songoda/skyblock/menus/Bank.java | 61 ++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 95693e7a..f1f95192 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -9,6 +9,8 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -38,7 +40,8 @@ public class BankManager { int size = transactions.size()>10 ? 10 : transactions.size(); for (int i = 0;i { + AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { + if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { + if (!(player.hasPermission("fabledskyblock.island.bank") // TODO check correct permissions - Fabrimat + || player.hasPermission("fabledskyblock.*"))) { + messageManager.sendMessage(player, "No permission"); // TODO language.yml - Fabrimat + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), + 1.0F, 1.0F); + } else if (!event1.getName().replace(" ", "") + .matches("^[a-zA-Z0-9|.]+$")) { + messageManager.sendMessage(player, "Invalid characters"); // TODO language.yml - Fabrimat + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), + 1.0F, 1.0F); + } else if (!event1.getName().matches("-?\\d+(?:\\.\\d+)?")) { + messageManager.sendMessage(player, "Only numbers allowed"); // TODO language.yml - Fabrimat + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), + 1.0F, 1.0F); + } else { + double amount; + + try { + amount = Double.parseDouble(event1.getName()); + } catch (NumberFormatException e1) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + return; + } + deposit(player, island, amount); + + player.closeInventory(); + + Bukkit.getServer().getScheduler() + .runTaskLater(skyblock, () -> open(player), 1L); + } + + event1.setWillClose(true); + event1.setWillDestroy(true); + } else { + event1.setWillClose(false); + event1.setWillDestroy(false); + } + }); + + ItemStack is = CompatibleMaterial.NAME_TAG.getItem(); + ItemMeta im = is.getItemMeta(); + im.setDisplayName("Amount"); // TODO language.yml - Fabrimat + is.setItemMeta(im); + + gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is); + gui.open(); + // --- + /*ChatPrompt.showPrompt(skyblock, player, (event) -> { if (event.getMessage().equals("")) return; @@ -86,7 +143,7 @@ public class Bank { return; } deposit(player, island, amount); - }); + });*/ } }); } From 4af09dd7a1d22d408045772a3a5f3be2a6bbdda5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 03:41:21 +0200 Subject: [PATCH 003/366] Fix for members can't withdraw or deposit from bank --- src/main/java/com/songoda/skyblock/menus/Bank.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/menus/Bank.java b/src/main/java/com/songoda/skyblock/menus/Bank.java index e21461cb..139f2ce6 100644 --- a/src/main/java/com/songoda/skyblock/menus/Bank.java +++ b/src/main/java/com/songoda/skyblock/menus/Bank.java @@ -64,7 +64,7 @@ public class Bank { executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Deposit.Displayname", CompatibleMaterial.DIRT), (inst, player, e) -> { inst.getSoundManager().playSound(player, CompatibleSound.ENTITY_BAT_TAKEOFF.getSound(), 1.0F, 1.0F); //Deposit money - Island island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); + Island island = islandManager.getIsland(player); if (island != null) { SelectInputMethod.getInstance().open(player, "Deposit", (action) -> { if (action == InputMethodSelectlistener.InputMethod.CANCELED) { @@ -96,18 +96,16 @@ public class Bank { executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Withdraw.Displayname", CompatibleMaterial.GLISTERING_MELON_SLICE), (inst, player, e) -> { inst.getSoundManager().playSound(player, CompatibleSound.ENTITY_BAT_TAKEOFF.getSound(), 1.0F, 1.0F); //Withdraw money - Island island = null; - island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); + Island island; + island = islandManager.getIsland(player); if (island != null) { - Island finalIsland = island; SelectInputMethod.getInstance().open(player, "Withdraw", (action) -> { if (action == InputMethodSelectlistener.InputMethod.CANCELED) { Bukkit.getScheduler().runTask(skyblock, () -> { this.open(player); }); - return; } else if (action == InputMethodSelectlistener.InputMethod.ALL) { - withdraw(player, finalIsland, finalIsland.getBankBalance()); + withdraw(player, island, island.getBankBalance()); } else { ChatPrompt.showPrompt(skyblock, player, (event) -> { if (event.getMessage().equals("")) @@ -119,7 +117,7 @@ public class Bank { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } - withdraw(player, finalIsland, amount); + withdraw(player, island, amount); }); } }); From 102e4d37b84c2db6208ddd700f651bec5310dc52 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 03:41:35 +0200 Subject: [PATCH 004/366] Shorter bank log --- src/main/java/com/songoda/skyblock/bank/BankManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 95693e7a..4e829937 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -9,6 +9,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -38,7 +39,8 @@ public class BankManager { int size = transactions.size()>10 ? 10 : transactions.size(); for (int i = 0;i Date: Thu, 18 Jun 2020 03:41:47 +0200 Subject: [PATCH 005/366] Defaulting subtract to 0 --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e02f6afb..86f46908 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -209,7 +209,7 @@ Island: # Island Level Points divided by value Division: 100 # Points to subtract to Island Level Points - Subtract: 1000 + Subtract: 0 Cooldown: # Time until Island level rescan expires Time: 60 From f73ac5d5ba1c4d8117e557c5c0e4c04f5b4ccf52 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 03:56:52 +0200 Subject: [PATCH 006/366] Fixed possible NullPointer on bank save --- src/main/java/com/songoda/skyblock/bank/BankManager.java | 6 +++++- .../java/com/songoda/skyblock/playerdata/PlayerData.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 4e829937..78073003 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -80,6 +80,10 @@ public class BankManager { } public List getTransactionList(Player player) { - return log.get(player.getUniqueId()); + return getTransactionList(player.getUniqueId()); + } + + public List getTransactionList(UUID uuid) { + return log.get(uuid); } } diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index d3401ac8..ed2d2a3c 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -255,7 +255,7 @@ public class PlayerData { } public void save() { - transactions = BankManager.getInstance().getTransactionList(getPlayer()); + transactions = BankManager.getInstance().getTransactionList(getPlayerUUID()); Config config = getConfig(); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Statistics.Island.Playtime", getPlaytime()); @@ -287,6 +287,10 @@ public class PlayerData { return Bukkit.getPlayer(uuid); } + public UUID getPlayerUUID() { + return uuid; + } + public List getTransactions() { return transactions; } From b58eef400d6aa987f999bd0545b8f08c90db43b7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 04:36:25 +0200 Subject: [PATCH 007/366] Fixed NullPointer in Explosion permission --- .../permission/permissions/listening/ExplosionsPermission.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java index 210c91f2..80e8e1b8 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java @@ -81,7 +81,7 @@ public class ExplosionsPermission extends ListeningPermission { @PermissionHandler public void onTNTInteract(PlayerInteractEvent event) { - if(event.getItem().getType().equals(CompatibleMaterial.FLINT_AND_STEEL.getMaterial()) + if(event.getItem() != null && event.getItem().getType().equals(CompatibleMaterial.FLINT_AND_STEEL.getMaterial()) && event.getClickedBlock().getType().equals(CompatibleMaterial.TNT.getBlockMaterial())){ cancelAndMessage(event, event.getPlayer(), plugin, plugin.getMessageManager()); } From 9d9fb48f0f567a13e257bf2e8ea9f3ea49b9b6fc Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 14:52:32 +0200 Subject: [PATCH 008/366] Fix coop settings not working --- src/main/java/com/songoda/skyblock/island/Island.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index bc72846e..901777f9 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -537,6 +537,9 @@ public class Island { } public IslandRole getRole(OfflinePlayer player) { + if(isCoopPlayer(player.getUniqueId())){ + return IslandRole.Coop; // TODO Rework Coop status - Fabrimat + } for (IslandRole role : IslandRole.values()) if (getRole(role).contains(player.getUniqueId())) return role; From 7c0460bd063a5b120cc6d22b07a7d79ef54e274c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 14:53:02 +0200 Subject: [PATCH 009/366] Check all the permissions before coming to conclusions --- .../com/songoda/skyblock/permission/PermissionManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 616e14d4..8e760007 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -158,7 +158,7 @@ public class PermissionManager { Method handler = wrapper.getHandler(); if (handler.getParameterTypes()[0] != cancellable.getClass()) continue; - if (cancellable.isCancelled()) return false; + // if (cancellable.isCancelled()) return false; if (cancellable instanceof Stoppable && ((Stoppable) cancellable).isStopped()) return true; BasicPermission permission = wrapper.getPermission(); @@ -172,7 +172,7 @@ public class PermissionManager { e.printStackTrace(); } } - return true; + return cancellable.isCancelled(); } public boolean hasPermission(Player player, Island island, BasicPermission permission, boolean reversePermission){ From c73612de876c6b09f043611a5f6e5be07521b8ac Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 14:53:18 +0200 Subject: [PATCH 010/366] Refactored Storage permission --- .../listening/StoragePermission.java | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java index 7c15fe75..454ed98e 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java @@ -7,6 +7,7 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.minecart.StorageMinecart; @@ -27,31 +28,44 @@ public class StoragePermission extends ListeningPermission { @PermissionHandler public void onInteract(PlayerInteractEvent event) { - if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) return; CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock()); Player player = event.getPlayer(); - if (material == CompatibleMaterial.CHEST || material == CompatibleMaterial.TRAPPED_CHEST - || (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && (material == CompatibleMaterial.SHULKER_BOX - || material == CompatibleMaterial.BLACK_SHULKER_BOX || material == CompatibleMaterial.BLUE_SHULKER_BOX - || material == CompatibleMaterial.BROWN_SHULKER_BOX || material == CompatibleMaterial.CYAN_SHULKER_BOX - || material == CompatibleMaterial.GRAY_SHULKER_BOX || material == CompatibleMaterial.GREEN_SHULKER_BOX - || material == CompatibleMaterial.LIGHT_BLUE_SHULKER_BOX || material == CompatibleMaterial.LIGHT_GRAY_SHULKER_BOX - || material == CompatibleMaterial.LIME_SHULKER_BOX || material == CompatibleMaterial.MAGENTA_SHULKER_BOX - || material == CompatibleMaterial.ORANGE_SHULKER_BOX || material == CompatibleMaterial.PINK_SHULKER_BOX - || material == CompatibleMaterial.PURPLE_SHULKER_BOX || material == CompatibleMaterial.RED_SHULKER_BOX - || material == CompatibleMaterial.WHITE_SHULKER_BOX || material == CompatibleMaterial.YELLOW_SHULKER_BOX)) - || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14) && material == CompatibleMaterial.BARREL) - cancelAndMessage(event, player, plugin, messageManager); + switch (material){ + case CHEST: + case TRAPPED_CHEST: + case DROPPER: + case DISPENSER: + case SHULKER_BOX: + case BLACK_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: + case LIME_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case PINK_SHULKER_BOX: + case RED_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case WHITE_SHULKER_BOX: + case BARREL: + cancelAndMessage(event, player, plugin, messageManager); + } } @PermissionHandler public void onInteractEntity(PlayerInteractEntityEvent event) { Player player = event.getPlayer(); - if (event.getRightClicked().getType() == EntityType.ITEM_FRAME + if (event.getRightClicked().getType().equals(EntityType.ITEM_FRAME) || event.getRightClicked() instanceof StorageMinecart) cancelAndMessage(event, player, plugin, messageManager); From fbc18f279c8c53141f0b28fae8b951c1ea803a73 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 16:16:55 +0200 Subject: [PATCH 011/366] Removed some entities from challenges --- src/main/resources/challenges.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index 0a23f691..f7b0e6c0 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -1683,14 +1683,11 @@ challenges: - 'NEAR:COW 1' - 'NEAR:RABBIT 1' - 'NEAR:WOLF 1' - - 'NEAR:DONKEY 1' - 'NEAR:HORSE 1' - - 'NEAR:LLAMA 1' - 'NEAR:OCELOT 1' - 'NEAR:MUSHROOM_COW 1' - 'NEAR:SHEEP 1' - 'NEAR:VILLAGER 1' - - 'NEAR:SKELETON_HORSE 1' reward: - 'CMD:eco give {player} 3000' - 'ITEM:diamond_block 32' @@ -1709,14 +1706,11 @@ challenges: - '&e - 1 Cow' - '&e - 1 Rabbit' - '&e - 1 Wolf' - - '&e - 1 Donkey' - '&e - 1 Horse' - - '&e - 1 Llama' - '&e - 1 Ocelot' - '&e - 1 Mooshroom cow' - '&e - 1 Sheep' - '&e - 1 Villager' - - '&e - 1 Skeleton Horse' - '&c&lRewards:' - '&e- 32 diamond blocks' - '&e- 3000 $' From 54aaed3fd68d22997adf006f8fd98a53472b7a7a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 16:17:42 +0200 Subject: [PATCH 012/366] Some extra checks in Mob hurting permission --- .../listening/MobHurtingPermission.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobHurtingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobHurtingPermission.java index 36a51d46..fbce594d 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobHurtingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobHurtingPermission.java @@ -24,18 +24,18 @@ public class MobHurtingPermission extends ListeningPermission { @PermissionHandler public void onVehicleDamage(VehicleDamageEvent event) { - - - Player player = (Player) event.getAttacker(); - cancelAndMessage(event, player, plugin, messageManager); + if(event.getAttacker() instanceof Player){ + Player player = (Player) event.getAttacker(); + cancelAndMessage(event, player, plugin, messageManager); + } } @PermissionHandler public void onVehicleDestroy(VehicleDestroyEvent event) { - - - Player player = (Player) event.getAttacker(); - cancelAndMessage(event, player, plugin, messageManager); + if(event.getAttacker() instanceof Player){ + Player player = (Player) event.getAttacker(); + cancelAndMessage(event, player, plugin, messageManager); + } } @PermissionHandler From d94d7923b8fd152ad48b633d31f15a28ce31777e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 16:17:55 +0200 Subject: [PATCH 013/366] Reworked pvp permission --- .../permissions/listening/PvpPermission.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java index ce5ecaaa..ed3da5d0 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java @@ -28,26 +28,27 @@ public class PvpPermission extends ListeningPermission { @PermissionHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - Entity entity = event.getEntity(); - - Player player; + Player attacker = null; if (event.getDamager() instanceof Player) - player = (Player) event.getDamager(); + attacker = (Player) event.getDamager(); else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) - player = (Player) ((Projectile) event.getDamager()).getShooter(); - else return; + attacker = (Player) ((Projectile) event.getDamager()).getShooter(); - FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); + if(attacker instanceof Player + && event.getEntity() instanceof Player){ + Player victim = (Player) event.getEntity(); - if (configLoad.getBoolean("Island.Settings.PvP.Enable")) { - event.setCancelled(true); - } else if (!configLoad.getBoolean("Island.PvP.Enable")) { - event.setCancelled(true); + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (configLoad.getBoolean("Island.Settings.PvP.Enable")) { + event.setCancelled(true); + } else if (!configLoad.getBoolean("Island.PvP.Enable")) { + event.setCancelled(true); + } + + cancelAndMessage(event, victim, plugin, messageManager); } - if (entity.getType() == EntityType.ARMOR_STAND || !(entity instanceof Monster)) return; - - cancelAndMessage(event, player, plugin, messageManager); } } From 3d0d8b602b6d05e45cc8ba90ba45c25a6294dd5d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 17:23:24 +0200 Subject: [PATCH 014/366] 2.3.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6471f5b3..49a819f8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2.16-LaborPatch-0.0.6 + 2.3.1 jar clean install From 74a9037f05d851fb0caa46a2d26616efe654f45e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 17:26:06 +0200 Subject: [PATCH 015/366] Fixed levelling admin gui not updating --- src/main/java/com/songoda/skyblock/menus/admin/Levelling.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java index dd69ea4c..ae8adaa8 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java @@ -332,6 +332,8 @@ public class Levelling implements Listener { Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + levellingManager.addWorth(materials, materialPoints); + Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { Config config1 = fileManager.getConfig(new File( From fbd41321fcab1fca60cb96b3eb5772d8b0cfa076 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 19:10:32 +0200 Subject: [PATCH 016/366] Reworked admin settings GUI and adapted to new system --- .../commands/admin/SettingsCommand.java | 12 +- .../skyblock/gui/GuiAdminPermissions.java | 126 ++++++++++++++++++ .../songoda/skyblock/gui/GuiPermissions.java | 10 +- .../skyblock/gui/GuiPermissionsSelector.java | 48 ++++--- .../skyblock/permission/BasicPermission.java | 6 +- 5 files changed, 176 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/gui/GuiAdminPermissions.java diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java index b08423ba..d19e3fd9 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java @@ -2,18 +2,28 @@ package com.songoda.skyblock.command.commands.admin; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.gui.GuiPermissionsSelector; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.menus.admin.Settings; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import java.io.File; + public class SettingsCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { SoundManager soundManager = skyblock.getSoundManager(); - Settings.getInstance().open(player, Settings.Type.Categories, null); + skyblock.getGuiManager().showGUI(player, new GuiPermissionsSelector(skyblock, null, null)); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } diff --git a/src/main/java/com/songoda/skyblock/gui/GuiAdminPermissions.java b/src/main/java/com/songoda/skyblock/gui/GuiAdminPermissions.java new file mode 100644 index 00000000..1089ee1a --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/GuiAdminPermissions.java @@ -0,0 +1,126 @@ +package com.songoda.skyblock.gui; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandPermission; +import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.permission.BasicPermission; +import com.songoda.skyblock.permission.PermissionManager; +import com.songoda.skyblock.permission.PermissionType; +import com.songoda.skyblock.visit.Visit; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class GuiAdminPermissions extends Gui { + + private final PermissionManager permissionManager; + private final IslandRole role; + private final FileConfiguration configLoad; + private final FileManager.Config settingsConfig; + private final FileConfiguration settingsConfigLoad; + private final Gui returnGui; + + public GuiAdminPermissions(SkyBlock plugin, IslandRole role, Gui returnGui) { + super(6, returnGui); + this.permissionManager = plugin.getPermissionManager(); + this.role = role; + this.returnGui = returnGui; + this.configLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + settingsConfig = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "settings.yml")); + settingsConfigLoad = settingsConfig.getFileConfiguration(); + setTitle(TextUtils.formatText(configLoad.getString("Menu.Settings." + role.name() + ".Title"))); + setDefaultItem(null); + paint(); + } + + public void paint() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 5, 9, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, + TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + guiManager.showGUI(event.player, returnGui); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, + TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + guiManager.showGUI(event.player, returnGui); + }); + + List permissions = permissionManager.getPermissions().stream() + .filter(p -> p.getType() == getType(role)) + .collect(Collectors.toList()); + double itemCount = permissions.size(); + this.pages = (int) Math.max(1, Math.ceil(itemCount / 36)); + + if (page != 1) + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Last.Displayname"))), + (event) -> { + page--; + paint(); + }); + + if (page != pages) + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); + + for (int i = 9; i < 45; i++) { + int current = ((page - 1) * 36) - 9; + if (current + i >= permissions.size()) { + setItem(i, null); + continue; + } + BasicPermission permission = permissions.get(current + i); + if (permission == null) continue; + + final String path = "Settings." + role.name() + "." + permission.getName(); + boolean setting = settingsConfigLoad.getBoolean(path); + setButton(i, permission.getItem(setting, role), (event) -> { + settingsConfigLoad.set(path, !setting); + try { + settingsConfigLoad.save(settingsConfig.getFile()); + } catch (IOException e) { + e.printStackTrace(); + } + paint(); + }); + } + } + + public PermissionType getType(IslandRole role) { + switch (role) { + default: + case Visitor: + case Member: + case Coop: + return PermissionType.GENERIC; + case Operator: + return PermissionType.OPERATOR; + case Owner: + return PermissionType.ISLAND; + } + } +} diff --git a/src/main/java/com/songoda/skyblock/gui/GuiPermissions.java b/src/main/java/com/songoda/skyblock/gui/GuiPermissions.java index 41394641..59711117 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/GuiPermissions.java @@ -24,7 +24,7 @@ import java.util.stream.Collectors; public class GuiPermissions extends Gui { - private SkyBlock plugin; + private final SkyBlock plugin; private final PermissionManager permissionManager; private final IslandRole role; private final Island island; @@ -63,17 +63,13 @@ public class GuiPermissions extends Gui { setButton(5, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Welcome.Displayname")), TextUtils.formatText(configLoad.getStringList("Menu.Settings.Visitor.Item.Welcome.Lore"))), - (event) -> { - guiManager.showGUI(event.player, new GuiWelcomeEditor(plugin, this, island)); - }); + (event) -> guiManager.showGUI(event.player, new GuiWelcomeEditor(plugin, this, island))); if (config.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) { setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Signature.Displayname")), TextUtils.formatText(configLoad.getStringList("Menu.Settings.Visitor.Item.Signature.Lore"))), - (event) -> { - guiManager.showGUI(event.player, new GuiSignatureEditor(plugin, this, island)); - }); + (event) -> guiManager.showGUI(event.player, new GuiSignatureEditor(plugin, this, island))); } Visit visit = island.getVisit(); diff --git a/src/main/java/com/songoda/skyblock/gui/GuiPermissionsSelector.java b/src/main/java/com/songoda/skyblock/gui/GuiPermissionsSelector.java index 7bc4abee..a722099e 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiPermissionsSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/GuiPermissionsSelector.java @@ -11,54 +11,68 @@ import com.songoda.skyblock.island.IslandRole; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.io.File; public class GuiPermissionsSelector extends Gui { - public GuiPermissionsSelector(SkyBlock plugin, Island island, Gui returnGui) { + public GuiPermissionsSelector(@Nonnull SkyBlock plugin, @Nullable Island island, @Nullable Gui returnGui) { super(1, returnGui); setDefaultItem(null); + String admin = island == null ? "Admin." : ""; + FileConfiguration configLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); setTitle(ChatColor.translateAlternateColorCodes('&', - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Title")))); + TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Title")))); setButton(2, GuiUtils.createButtonItem(CompatibleMaterial.OAK_SIGN, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Visitor.Displayname")), - TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Visitor.Lore"))), (event) -> - guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Visitor, this))); + TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Visitor.Displayname")), + TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Visitor.Lore"))), (event) -> + guiManager.showGUI(event.player, island == null ? + new GuiAdminPermissions(plugin, IslandRole.Visitor, this) : + new GuiPermissions(plugin, island, IslandRole.Visitor, this))); setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Member.Displayname")), - TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Member.Lore"))), (event) -> - guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Member, this))); + TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Member.Displayname")), + TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Member.Lore"))), (event) -> + guiManager.showGUI(event.player, island == null ? + new GuiAdminPermissions(plugin, IslandRole.Member, this) : + new GuiPermissions(plugin, island, IslandRole.Member, this))); setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Operator.Displayname")), - TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Operator.Lore"))), (event) -> - guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Operator, this))); + TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Operator.Displayname")), + TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Operator.Lore"))), (event) -> + guiManager.showGUI(event.player, island == null ? + new GuiAdminPermissions(plugin, IslandRole.Operator, this) : + new GuiPermissions(plugin, island, IslandRole.Operator, this))); boolean isCoop = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Coop.Enable"); setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Exit.Displayname"))), (event) -> { CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); event.player.closeInventory(); }); if (isCoop) setButton(6, GuiUtils.createButtonItem(CompatibleMaterial.NAME_TAG, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Coop.Displayname")), + TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Coop.Displayname")), TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Coop.Lore"))), (event) -> - guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Coop, this))); + guiManager.showGUI(event.player, island == null ? + new GuiAdminPermissions(plugin, IslandRole.Coop, this) : + new GuiPermissions(plugin, island, IslandRole.Coop, this))); setButton(isCoop ? 7 : 8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_SAPLING.getItem(), - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Owner.Displayname")), - TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Owner.Lore"))), (event) -> - guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Owner, this))); + TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Owner.Displayname")), + TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Owner.Lore"))), (event) -> + guiManager.showGUI(event.player, island == null ? + new GuiAdminPermissions(plugin, IslandRole.Owner, this) : + new GuiPermissions(plugin, island, IslandRole.Owner, this))); } } diff --git a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java index 8ecf2cb3..92f0e067 100644 --- a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java @@ -28,6 +28,10 @@ public abstract class BasicPermission { } public ItemStack getItem(Island island, IslandRole role) { + return getItem(island.hasPermission(role, this), role); + } + + public ItemStack getItem(boolean permissionEnabled, IslandRole role) { ItemStack is = icon.getItem(); FileManager.Config config = SkyBlock.getInstance().getFileManager() .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")); @@ -50,7 +54,7 @@ public abstract class BasicPermission { for (String itemLoreList : configLoad .getStringList("Menu.Settings." + roleName + ".Item.Setting.Status." - + (island.hasPermission(role, this) ? "Enabled" : "Disabled") + ".Lore")) + + (permissionEnabled ? "Enabled" : "Disabled") + ".Lore")) itemLore.add(TextUtils.formatText(itemLoreList)); im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); From 24f722d408349bf9e6b659d91e16a0320e191780 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 20:02:56 +0200 Subject: [PATCH 017/366] Fixed white settings name --- src/main/resources/language.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 58f0d6a9..8e09ddd5 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1145,6 +1145,18 @@ Menu: Displayname: '&aDoor Use' Jukebox: Displayname: '&aJukebox Use' + PvP: + Displayname: '&aPvP' + Noteblock: + Displayname: '&aNoteblock use' + Minecart: + Displayname: '&aMinecart' + Damage: + Displayname: '&aDamage' + Boat: + Displayname: '&aBoat' + Trample: + Displayname: '&aTrample' Bucket: Displayname: '&aBucket Use' SpawnEgg: @@ -1502,6 +1514,18 @@ Menu: - '&7Status&8: &cfalse' Milking: Displayname: '&aMilking' + PvP: + Displayname: '&aPvP' + Noteblock: + Displayname: '&aNoteblock use' + Minecart: + Displayname: '&aMinecart' + Damage: + Displayname: '&aDamage' + Boat: + Displayname: '&aBoat' + Trample: + Displayname: '&aTrample' Anvil: Displayname: '&aAnvil Use' Portal: From bb62bc56176ea600f2429cfdcc37b7258066ac36 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 18 Jun 2020 20:04:17 +0200 Subject: [PATCH 018/366] Simplified setting icon creation --- .../skyblock/permission/BasicPermission.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java index 92f0e067..bfb179bc 100644 --- a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java @@ -6,6 +6,7 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandRole; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; @@ -48,18 +49,19 @@ public abstract class BasicPermission { || role == IslandRole.Coop) roleName = "Default"; - String nameFinal = configLoad.getString("Menu.Settings." + roleName + ".Item.Setting." + name + ".Displayname"); + String nameFinal = TextUtils.formatText(configLoad.getString("Menu.Settings." + roleName + ".Item.Setting." + name + ".Displayname", name)); - im.setDisplayName(TextUtils.formatText(nameFinal == null ? name : nameFinal)); + if(im != null){ + im.setDisplayName(nameFinal); + for (String itemLoreList : configLoad + .getStringList("Menu.Settings." + roleName + ".Item.Setting.Status." + + (permissionEnabled ? "Enabled" : "Disabled") + ".Lore")) + itemLore.add(TextUtils.formatText(itemLoreList)); - for (String itemLoreList : configLoad - .getStringList("Menu.Settings." + roleName + ".Item.Setting.Status." - + (permissionEnabled ? "Enabled" : "Disabled") + ".Lore")) - itemLore.add(TextUtils.formatText(itemLoreList)); - - im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - im.setLore(itemLore); - is.setItemMeta(im); + im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + im.setLore(itemLore); + is.setItemMeta(im); + } return is; } From 9fbbca4a134881e00a25698f1ac52c3870625691 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 00:11:53 +0200 Subject: [PATCH 019/366] Fixed Portals --- .../com/songoda/skyblock/island/Island.java | 17 +++++++----- .../songoda/skyblock/listeners/Portal.java | 26 ++++++++----------- .../permission/PermissionManager.java | 7 +++-- .../listening/PortalPermission.java | 19 +++++++++++--- 4 files changed, 43 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 901777f9..38495a97 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -26,6 +26,7 @@ import org.bukkit.WeatherType; import org.bukkit.block.Biome; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import java.io.File; import java.io.IOException; @@ -864,7 +865,7 @@ public class Island { getLevel().save(); } - public boolean isRegionUnlocked(Player player, String type) { + public boolean isRegionUnlocked(Player player, IslandWorld type) { FileManager fileManager = skyblock.getFileManager(); SoundManager soundManager = skyblock.getSoundManager(); MessageManager messageManager = skyblock.getMessageManager(); @@ -874,22 +875,26 @@ public class Island { .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoadIslandData = islandData.getFileConfiguration(); - double price = configLoad.getDouble("Island.World." + type + ".UnlockPrice"); + double price = configLoad.getDouble("Island.World." + type.name() + ".UnlockPrice"); - boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type); + boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type.name()); if (price == -1) { - configLoadIslandData.set("Unlocked." + type, true); + configLoadIslandData.set("Unlocked." + type.name(), true); unlocked = true; } if (!unlocked) { messageManager.sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration() - .getString("Island.Unlock." + type + ".Message").replace( + .getString("Island.Unlock." + type.name() + ".Message").replace( "%cost%", NumberUtil.formatNumberByDecimal(price))); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - player.setVelocity(player.getLocation().getDirection().multiply(-.50)); + if(type.equals(IslandWorld.End)){ + player.setVelocity(player.getLocation().getDirection().multiply(-.50).setY(.6f)); + } else if(type.equals(IslandWorld.Nether)) { + player.setVelocity(player.getLocation().getDirection().multiply(-.50)); + } } return unlocked; } diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 145852a3..2b76866f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -81,12 +81,6 @@ public class Portal implements Listener { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat - // Check permissions. - if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent, - player, island) || playerEnterPortalEvent.isCancelled()) - return; - IslandEnvironment spawnEnvironment; switch (island.getRole(player)) { case Operator: @@ -123,23 +117,25 @@ public class Portal implements Listener { if (tick == null) return; + PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat + // Check permissions. + if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent, + player, island)) + return; + IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld()); IslandWorld toWorld = IslandWorld.Normal; - if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.NETHER_PORTAL)) + if (block.getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) { toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal; - else if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.END_PORTAL)) + } else if (block.getType().equals(CompatibleMaterial.END_PORTAL.getMaterial())) { toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal; + } switch (toWorld) { - case Nether: - if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) { - teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld); - } - break; - case End: - if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) { + case Nether: + if (configLoad.getBoolean("Island.World." + toWorld.name() + ".Enable") && island.isRegionUnlocked(player, toWorld)) { teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld); } break; diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 8e760007..27ab7761 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -12,6 +12,7 @@ import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.player.PlayerMoveEvent; import java.io.File; import java.lang.reflect.InvocationTargetException; @@ -158,11 +159,13 @@ public class PermissionManager { Method handler = wrapper.getHandler(); if (handler.getParameterTypes()[0] != cancellable.getClass()) continue; - // if (cancellable.isCancelled()) return false; + if (cancellable.isCancelled()) return false; if (cancellable instanceof Stoppable && ((Stoppable) cancellable).isStopped()) return true; BasicPermission permission = wrapper.getPermission(); + //if(cancellable instanceof PlayerMoveEvent) Bukkit.broadcastMessage("A " + permission.getName()); + if (hasPermission(player, island, permission, reversePermission)) continue; @@ -172,7 +175,7 @@ public class PermissionManager { e.printStackTrace(); } } - return cancellable.isCancelled(); + return true; } public boolean hasPermission(Player player, Island island, BasicPermission permission, boolean reversePermission){ diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index f339ab3a..9ff90cff 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -35,11 +35,24 @@ public class PortalPermission extends ListeningPermission { cancelAndMessage(event, player, plugin, messageManager); Bukkit.getScheduler().runTask(plugin, () -> { - player.teleport(getToLocation(event.getLocation(), player)); + //player.teleport(getToLocation(event.getLocation(), player)); }); } } + @PermissionHandler + public void onMove(PlayerMoveEvent event) { + if(event.getTo() != null){ + CompatibleMaterial toMaterial = CompatibleMaterial.getMaterial(event.getTo().getBlock().getType()); + + if (toMaterial == CompatibleMaterial.NETHER_PORTAL || toMaterial == CompatibleMaterial.END_PORTAL) { + //event.setTo(LocationUtil.getRandomLocation(event.getFrom().getWorld(), 5000, 5000, true, true)); + cancelAndMessage(event, event.getPlayer(), plugin, messageManager); + } + } + } + + @PermissionHandler public void onTeleport(PlayerTeleportEvent event) { if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL) @@ -47,12 +60,12 @@ public class PortalPermission extends ListeningPermission { || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL) || (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_GATEWAY))){ - event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer())); + /*event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer())); Location to = getToLocation(event.getFrom(), event.getPlayer()); Bukkit.getScheduler().runTask(plugin, () -> { event.getPlayer().teleport(to); }); - event.setTo(to); + event.setTo(to);*/ cancelAndMessage(event, event.getPlayer(), plugin, messageManager); } From 2fef576a48df309e0a94e56f9039b15cf2bef31e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 00:12:06 +0200 Subject: [PATCH 020/366] Fixed errors when getting safe location --- .../skyblock/utils/world/LocationUtil.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) 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 cf961fd2..c2a4429f 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -18,6 +18,8 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -38,29 +40,32 @@ public final class LocationUtil { } } - public static Location getSafeLocation(Location loc){ + public static @Nullable 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); + Location locChecked = null; + if(loc != null && loc.getWorld() != null){ + 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) { - locChecked = locChecked.add(0d,1d,0d); - } else { - locChecked = null; + 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){ + public static @Nonnull Location getDefinitiveLocation(Location loc){ Location locWorking = loc.clone(); for(int i=locWorking.getBlockY(); i>=0; i--){ if(!locWorking.getBlock().isEmpty()){ From 62c819e6111b15fd84affd7b6203ea6d71e48f1f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 03:07:26 +0200 Subject: [PATCH 021/366] Residence plugin support for fly --- pom.xml | 6 ++++++ .../songoda/skyblock/island/IslandManager.java | 15 +++++++++++++++ src/main/resources/plugin.yml | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 49a819f8..0bcf11c7 100644 --- a/pom.xml +++ b/pom.xml @@ -190,5 +190,11 @@ LATEST compile + + com.Zrips + Residence + provided + 4.9.0.6 + diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 0db97ead..0bf9404b 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1,5 +1,9 @@ package com.songoda.skyblock.island; +import com.bekvon.bukkit.residence.Residence; +import com.bekvon.bukkit.residence.api.ResidenceApi; +import com.bekvon.bukkit.residence.containers.Flags; +import com.bekvon.bukkit.residence.protection.ClaimedResidence; import com.google.common.base.Preconditions; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; @@ -47,6 +51,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import java.io.File; import java.io.IOException; @@ -1380,6 +1385,16 @@ public class IslandManager { if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR || player.hasPermission("essentials.fly") || player.hasPermission("cmi.command.fly")) return; + // Residence support + if (Bukkit.getServer().getPluginManager().getPlugin("Residence") != null) { + ClaimedResidence res = Residence.getInstance().getResidenceManagerAPI().getByLoc(player.getLocation()); + if(res != null){ + if(res.getPermissions().has(Flags.fly, false)){ + return; + } + } + } + Island island = getIslandAtLocation(player.getLocation()); UpgradeManager upgradeManager = skyblock.getUpgradeManager(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c1218e25..2932d356 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,7 +5,7 @@ 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] +softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence] loadbefore: [Multiverse-Core, ProtocolLib] commands: island: From 68f11d3e2b27a762aa81e1c45b86f22c4beeb6b9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 03:07:46 +0200 Subject: [PATCH 022/366] Fixed bug that tp you in the real nether/end when endering portal --- .../com/songoda/skyblock/listeners/Teleport.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index 1c6b4c11..b8263ca1 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.listeners; +import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.api.event.player.PlayerIslandEnterEvent; @@ -11,7 +12,6 @@ import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; @@ -20,6 +20,7 @@ import com.songoda.skyblock.world.WorldManager; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.OfflinePlayer; +import org.bukkit.World; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -56,6 +57,17 @@ public class Teleport implements Listener { Bukkit.getScheduler().runTaskLater(skyblock, () -> islandManager.updateFlight(player), 1L); islandManager.loadPlayer(player); + + // Fix for bug that tp you in the real Nether/End when entering in a portal in an island + if (worldManager.isIslandWorld(event.getFrom().getWorld()) + && !worldManager.isIslandWorld(event.getTo().getWorld()) + && (event.getFrom().getBlock().getType().equals(CompatibleMaterial.END_PORTAL.getMaterial()) + || event.getFrom().getBlock().getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) && (event.getTo().getWorld() != null + && event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER) + || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END))) { + event.setCancelled(true); + } + if (worldManager.isIslandWorld(player.getWorld())) { com.songoda.skyblock.island.Island island = islandManager.getIslandAtLocation(event.getTo()); From 601acb2b728f6ad7fe96084a58a97932a7bf690c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 05:03:32 +0200 Subject: [PATCH 023/366] Make more method synchronized in order to try avoiding IO issues --- .../java/com/songoda/skyblock/island/Island.java | 2 +- .../songoda/skyblock/island/IslandManager.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 38495a97..b83c1f52 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -812,7 +812,7 @@ public class Island { this.deleted = deleted; } - public void save() { + public synchronized void save() { FileManager fileManager = skyblock.getFileManager(); Config config = fileManager diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 0bf9404b..ebf350af 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -102,7 +102,7 @@ public class IslandManager { } } - public void saveNextAvailableLocation(IslandWorld world) { + public synchronized void saveNextAvailableLocation(IslandWorld world) { FileManager fileManager = skyblock.getFileManager(); Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "worlds.yml")); @@ -124,7 +124,7 @@ public class IslandManager { } } - public void setNextAvailableLocation(IslandWorld world, org.bukkit.Location location) { + public synchronized void setNextAvailableLocation(IslandWorld world, org.bukkit.Location location) { for (IslandPosition islandPositionList : islandPositions) { if (islandPositionList.getWorld() == world) { islandPositionList.setX(location.getX()); @@ -134,7 +134,7 @@ public class IslandManager { } - public org.bukkit.Location prepareNextAvailableLocation(IslandWorld world) { + public synchronized org.bukkit.Location prepareNextAvailableLocation(IslandWorld world) { for (IslandPosition islandPositionList : islandPositions) { if (islandPositionList.getWorld() == world) { @@ -196,7 +196,7 @@ public class IslandManager { return null; } - public boolean createIsland(Player player, Structure structure) { + public synchronized boolean createIsland(Player player, Structure structure) { ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); VisitManager visitManager = skyblock.getVisitManager(); FileManager fileManager = skyblock.getFileManager(); @@ -296,7 +296,7 @@ public class IslandManager { return true; } - public boolean previewIsland(Player player, Structure structure) { + public synchronized boolean previewIsland(Player player, Structure structure) { FileManager fileManager = skyblock.getFileManager(); PlayerData data = skyblock.getPlayerDataManager().getPlayerData(player); @@ -407,7 +407,7 @@ public class IslandManager { return true; } - public void giveOwnership(Island island, org.bukkit.OfflinePlayer player) { + public synchronized void giveOwnership(Island island, org.bukkit.OfflinePlayer player) { PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); CooldownManager cooldownManager = skyblock.getCooldownManager(); FileManager fileManager = skyblock.getFileManager(); @@ -529,7 +529,7 @@ public class IslandManager { } } - public boolean deleteIsland(Island island, boolean force) { + public synchronized boolean deleteIsland(Island island, boolean force) { ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); CooldownManager cooldownManager = skyblock.getCooldownManager(); @@ -657,7 +657,7 @@ public class IslandManager { return true; } - public void deleteIslandData(UUID uuid) { + public synchronized void deleteIslandData(UUID uuid) { FileManager fileManager = skyblock.getFileManager(); fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml")); fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/ban-data", uuid.toString() + ".yml")); From cb586ee840c6a511d4f140db0deedc5b1eddaae3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 05:10:45 +0200 Subject: [PATCH 024/366] 2.3.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0bcf11c7..0839c7df 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.1 + 2.3.2 jar clean install From 2ac1224b6f6ef374d420eacf19cbcfea2f2430d2 Mon Sep 17 00:00:00 2001 From: Alexey Date: Fri, 19 Jun 2020 07:03:19 +0000 Subject: [PATCH 025/366] Update pom.xml --- pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0839c7df..fd0e1754 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,12 @@ skyblock 2.3.2 jar + + + UTF-8 + UTF-8 + < + clean install FabledSkyblock-${project.version} @@ -41,7 +47,7 @@ maven-compiler-plugin - 3.8.0 + 3.8.1 1.8 1.8 From 8a601a605cb4111d0078ce80dc48d91e27335468 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 15:51:57 +0200 Subject: [PATCH 026/366] Removed useless null --- src/main/java/com/songoda/skyblock/listeners/Spawner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Spawner.java b/src/main/java/com/songoda/skyblock/listeners/Spawner.java index ef2f6338..0c934716 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Spawner.java +++ b/src/main/java/com/songoda/skyblock/listeners/Spawner.java @@ -46,7 +46,7 @@ public class Spawner implements Listener { spawner.setMaxSpawnDelay(400); } else { try { - Object MobSpawner = null; + Object MobSpawner; try { Field TileEntityMobSpawnerField = spawner.getClass().getDeclaredField("spawner"); From a97d951b7f3fd223e38b23c710a55633dca5f226 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 16:09:47 +0200 Subject: [PATCH 027/366] Fixed checks in challenge management --- .../skyblock/challenge/challenge/Challenge.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 d7deaf71..28ff0685 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.regex.Pattern; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -18,7 +20,6 @@ import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import com.songoda.skyblock.api.SkyBlockAPI; -import com.songoda.skyblock.api.island.Island; public class Challenge { private ChallengeCategory category; @@ -240,11 +241,12 @@ public class Challenge { public boolean has(Player p, Object obj) { // Check if the level of player's island is greater or equals to the required // level - Island is = SkyBlockAPI.getIslandManager().getIsland(p); + Island is = SkyBlock.getInstance().getIslandManager().getIsland(p); // Player doesn't have an island - if (is == null) - return false; - return is.getLevel().getLevel() >= (Integer) obj; + if (is != null && obj instanceof Number) { + return is.getLevel().getLevel() >= (Long) obj; + } + return false; } @Override From 00e5ff18ec1834fe9cb56207466bddf832a7ee02 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 16:17:55 +0200 Subject: [PATCH 028/366] Fix for proxy command not working with offline players --- .../skyblock/command/commands/admin/ProxyCommand.java | 4 +++- .../java/com/songoda/skyblock/island/IslandManager.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java index 1400d0b4..d97b773e 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java @@ -8,6 +8,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -39,9 +40,10 @@ public class ProxyCommand extends SubCommand { if (args.length == 1) { OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]); + UUID islandOwnerUUID = targetPlayerOffline.getOwner(); - if (islandManager.containsIsland(islandOwnerUUID)) { + if (islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)) != null) { if (islandManager.isPlayerProxyingAnotherPlayer(((Player)sender).getUniqueId())) { messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Proxy.IsOffPlayer.Message") diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index ebf350af..52836fcb 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1191,8 +1191,8 @@ public class IslandManager { return islandStorage.get(uuid); } - if (offlinePlayer.isOnline()) { - Player player = offlinePlayer.getPlayer(); + Player player = offlinePlayer.getPlayer(); + if (offlinePlayer.isOnline() && player != null) { if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); @@ -1207,6 +1207,8 @@ public class IslandManager { if (offlinePlayerData.getOwner() != null && islandStorage.containsKey(offlinePlayer.getUniqueId())) { return islandStorage.get(offlinePlayerData.getOwner()); } + + return loadIsland(offlinePlayer); // TODO That could be done first, needs testing - Fabrimat } return null; From 7fd6f967dca4eb94c61128903833f229db9cca93 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 16:49:29 +0200 Subject: [PATCH 029/366] Optimize and fix pvp permission message --- .../permissions/listening/PvpPermission.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java index ed3da5d0..334162e5 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java @@ -8,7 +8,8 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.*; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import java.io.File; @@ -29,25 +30,22 @@ public class PvpPermission extends ListeningPermission { @PermissionHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Player attacker = null; - if (event.getDamager() instanceof Player) + if (event.getDamager() instanceof Player) { attacker = (Player) event.getDamager(); - else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) + } else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) { attacker = (Player) ((Projectile) event.getDamager()).getShooter(); + } - if(attacker instanceof Player - && event.getEntity() instanceof Player){ - Player victim = (Player) event.getEntity(); + if(attacker != null && event.getEntity() instanceof Player){ FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (configLoad.getBoolean("Island.Settings.PvP.Enable")) { - event.setCancelled(true); - } else if (!configLoad.getBoolean("Island.PvP.Enable")) { + if (configLoad.getBoolean("Island.Settings.PvP.Enable") || !configLoad.getBoolean("Island.PvP.Enable")) { event.setCancelled(true); } - cancelAndMessage(event, victim, plugin, messageManager); + cancelAndMessage(event, attacker, plugin, messageManager); } } From e64b3542523f9686ce191d5121537f0eb28904c9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 16:50:07 +0200 Subject: [PATCH 030/366] Removed pvp default value from owner --- src/main/resources/settings.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 63e4ccbd..5b408de9 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -161,7 +161,6 @@ Settings: Owner: NaturalMobSpawning: true MobGriefing: false - PvP: false Explosions: false FireSpread: true LeafDecay: true From 2c4bb357da75d49d4e3482ee126b97cbbd3d2b69 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 22:29:55 +0200 Subject: [PATCH 031/366] Fixed portals --- .../songoda/skyblock/listeners/Portal.java | 41 +++++++++++-------- .../listening/PortalPermission.java | 3 -- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 2b76866f..d7001f1a 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -119,9 +119,8 @@ public class Portal implements Listener { PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat // Check permissions. - if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent, - player, island)) - return; + boolean perms = !skyblock.getPermissionManager().processPermission(playerEnterPortalEvent, + player, island); IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld()); IslandWorld toWorld = IslandWorld.Normal; @@ -132,21 +131,29 @@ public class Portal implements Listener { toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal; } - switch (toWorld) { - case End: - case Nether: - if (configLoad.getBoolean("Island.World." + toWorld.name() + ".Enable") && island.isRegionUnlocked(player, toWorld)) { - teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld); - } - break; + if(!perms){ + switch (toWorld) { + case End: + case Nether: + if (configLoad.getBoolean("Island.World." + toWorld.name() + ".Enable") && island.isRegionUnlocked(player, toWorld)) { + teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld); + } + break; - default: - 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); - break; + default: + 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); + break; + } + } else { + if(toWorld.equals(IslandWorld.End)){ + player.setVelocity(player.getLocation().getDirection().multiply(-.50).setY(.6f)); + } else if(toWorld.equals(IslandWorld.Nether)) { + player.setVelocity(player.getLocation().getDirection().multiply(-.50)); + } } } diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index 9ff90cff..fbd4ef43 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -34,9 +34,6 @@ public class PortalPermission extends ListeningPermission { Player player = (Player) event.getEntity(); cancelAndMessage(event, player, plugin, messageManager); - Bukkit.getScheduler().runTask(plugin, () -> { - //player.teleport(getToLocation(event.getLocation(), player)); - }); } } From e9cbfdac925c6207b545cb923a9a1d0b9e50249a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 22:46:51 +0200 Subject: [PATCH 032/366] Fix for is kick offline members --- .../skyblock/command/commands/island/KickCommand.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 cc83190a..ee2be148 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,8 +72,7 @@ public class KickCommand extends SubCommand { targetPlayerName = targetPlayer.getName(); } - assert targetPlayer != null; - if((targetPlayer.hasPermission("fabledskyblock.bypass.kick") || targetPlayer.isOp()) && islandVisitors.contains(targetPlayer.getUniqueId())){ + if(targetPlayer != null && (targetPlayer.hasPermission("fabledskyblock.bypass.kick") || targetPlayer.isOp()) && islandVisitors.contains(targetPlayer.getUniqueId())){ messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (targetPlayerUUID.equals(player.getUniqueId())) { @@ -85,7 +84,7 @@ public class KickCommand extends SubCommand { } else if (island.getOwnerUUID().equals(targetPlayerUUID)) { messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) { + } else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID)) { if (island.isCoopPlayer(targetPlayerUUID)) { messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); From 341edb3c3b24e06a62974abae3a205495dbde0e6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 22:47:40 +0200 Subject: [PATCH 033/366] Fixed loading islands for offline members --- .../songoda/skyblock/api/island/Island.java | 3 ++- .../command/commands/admin/DeleteCommand.java | 3 ++- .../commands/admin/SetBiomeCommand.java | 3 ++- .../commands/island/AcceptCommand.java | 4 +-- .../skyblock/island/IslandManager.java | 27 +++++++++---------- .../com/songoda/skyblock/listeners/Join.java | 3 ++- .../com/songoda/skyblock/listeners/Move.java | 3 ++- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/api/island/Island.java b/src/main/java/com/songoda/skyblock/api/island/Island.java index ee95ae3d..2173931c 100644 --- a/src/main/java/com/songoda/skyblock/api/island/Island.java +++ b/src/main/java/com/songoda/skyblock/api/island/Island.java @@ -459,7 +459,8 @@ public class Island { */ public void load() { if (this.handle == null) { - this.handle = SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player); + SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player); + this.handle = SkyBlockAPI.getImplementation().getIslandManager().getIsland(player); } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java index 9488733b..da182ad6 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java @@ -68,7 +68,8 @@ public class DeleteCommand extends SubCommand { configLoad.getString("Command.Island.Admin.Delete.Owner.Message")); soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { - Island island = islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID)); + islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID)); + Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID)); Location spawnLocation = LocationUtil.getSpawnLocation(); if (spawnLocation != null && islandManager.isLocationAtIsland(island, spawnLocation)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java index e97e8ed1..3ac41cc8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java @@ -79,7 +79,8 @@ public class SetBiomeCommand extends SubCommand { biomeManager.setBiome(island, biome.getBiome()); island.setBiome(biome.getBiome()); } else { - Island island = islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); + islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); + Island island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); if (island == null) { messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.SetBiome.Island.Data.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java index 11b4c2c7..8cf32a29 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java @@ -62,8 +62,8 @@ public class AcceptCommand extends SubCommand { island = islandManager .getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID())); } else { - island = islandManager - .loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID())); + islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID())); + island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID())); unloadIsland = true; } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 52836fcb..f0238949 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -671,7 +671,7 @@ public class IslandManager { } } - public Island loadIsland(org.bukkit.OfflinePlayer player) { + public void loadIsland(org.bukkit.OfflinePlayer player) { VisitManager visitManager = skyblock.getVisitManager(); FileManager fileManager = skyblock.getFileManager(); BanManager banManager = skyblock.getBanManager(); @@ -686,7 +686,7 @@ public class IslandManager { deleteIslandData(player.getUniqueId()); configLoad.set("Island.Owner", null); - return null; + return; } islandOwnerUUID = player.getUniqueId(); @@ -698,7 +698,8 @@ public class IslandManager { if (islandOwnerUUID != null) { if (containsIsland(islandOwnerUUID)) { - return getIsland(player); + //return getIsland(player); + return; } else { config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml")); @@ -706,7 +707,7 @@ public class IslandManager { deleteIslandData(islandOwnerUUID); configLoad.set("Island.Owner", null); - return null; + return; } Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); @@ -731,11 +732,9 @@ public class IslandManager { Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper()))); - return island; + return; } } - - return null; } /** @@ -786,11 +785,11 @@ public class IslandManager { oldSystemIslands.put(IslandWorld.End, endZ); } - public Island loadIslandAtLocation(Location location) { + public void loadIslandAtLocation(Location location) { FileManager fileManager = skyblock.getFileManager(); File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); - if (!configFile.exists()) return null; + if (!configFile.exists()) return; for (File fileList : configFile.listFiles()) { if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) { @@ -807,7 +806,8 @@ public class IslandManager { if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) { UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", "")); - return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); + // return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); + return; } } catch (Exception e) { e.printStackTrace(); @@ -815,7 +815,7 @@ public class IslandManager { } } - return null; + return; } public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) { @@ -1203,12 +1203,11 @@ public class IslandManager { } } else { OfflinePlayer offlinePlayerData = new OfflinePlayer(offlinePlayer.getUniqueId()); + loadIsland(offlinePlayer); if (offlinePlayerData.getOwner() != null && islandStorage.containsKey(offlinePlayer.getUniqueId())) { return islandStorage.get(offlinePlayerData.getOwner()); } - - return loadIsland(offlinePlayer); // TODO That could be done first, needs testing - Fabrimat } return null; @@ -1391,7 +1390,7 @@ public class IslandManager { if (Bukkit.getServer().getPluginManager().getPlugin("Residence") != null) { ClaimedResidence res = Residence.getInstance().getResidenceManagerAPI().getByLoc(player.getLocation()); if(res != null){ - if(res.getPermissions().has(Flags.fly, false)){ + if (res.getPermissions().has(Flags.fly, false) || res.getPermissions().has(Flags.nofly, false)) { return; } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index 9777b402..0b3883dd 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -50,7 +50,8 @@ public class Join implements Listener { userCacheManager.saveAsync(); try { - Island island = islandManager.loadIsland(player); + islandManager.loadIsland(player); + Island island = islandManager.getIsland(player); boolean teleportedToIsland = false; Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index e3ef3789..6ba945aa 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -169,7 +169,8 @@ public class Move implements Listener { } // Load the island they are now on if one exists - Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation()); + islandManager.loadIslandAtLocation(player.getLocation()); + Island loadedIsland = islandManager.getIslandAtLocation(player.getLocation()); if (loadedIsland != null) { if (player.hasPermission("fabledskyblock.bypass")) { playerData.setIsland(loadedIsland.getOwnerUUID()); From 66e3dfbc01e849ff0b8938926d315c383e78694d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 22:48:11 +0200 Subject: [PATCH 034/366] Fix for Residence compatibility --- .../java/com/songoda/skyblock/listeners/Teleport.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index b8263ca1..81c52552 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -54,17 +54,20 @@ public class Teleport implements Listener { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - Bukkit.getScheduler().runTaskLater(skyblock, () -> islandManager.updateFlight(player), 1L); + if(worldManager.isIslandWorld(event.getFrom().getWorld()) + || (event.getTo() != null && worldManager.isIslandWorld(event.getTo().getWorld()))) { + Bukkit.getScheduler().runTaskLater(skyblock, () -> islandManager.updateFlight(player), 1L); + } islandManager.loadPlayer(player); // Fix for bug that tp you in the real Nether/End when entering in a portal in an island - if (worldManager.isIslandWorld(event.getFrom().getWorld()) + if (event.getTo() != null && (worldManager.isIslandWorld(event.getFrom().getWorld()) && !worldManager.isIslandWorld(event.getTo().getWorld()) && (event.getFrom().getBlock().getType().equals(CompatibleMaterial.END_PORTAL.getMaterial()) || event.getFrom().getBlock().getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) && (event.getTo().getWorld() != null && event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER) - || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END))) { + || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END)))) { event.setCancelled(true); } From 969306bf6bf3b87c4eb4ae183c24c4eeeedc2b01 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 22:48:26 +0200 Subject: [PATCH 035/366] Added Damage setting to settings.yml --- src/main/resources/settings.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 5b408de9..63f8fe53 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -48,6 +48,7 @@ Settings: ExperienceOrbPickup: false Trapdoor: false Noteblock: false + Damage: true Member: Destroy: true Place: true @@ -97,6 +98,7 @@ Settings: ExperienceOrbPickup: true Trapdoor: true Noteblock: true + Damage: true Operator: Invite: true Kick: true @@ -158,6 +160,7 @@ Settings: Hopper: true EntityPlacement: true ExperienceOrbPickup: true + Damage: true Owner: NaturalMobSpawning: true MobGriefing: false @@ -165,5 +168,4 @@ Settings: FireSpread: true LeafDecay: true KeepItemsOnDeath: true - Damage: true Hunger: true \ No newline at end of file From 824145276e7cf8f43c2743936ce3d13c17ac5a50 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 22:49:09 +0200 Subject: [PATCH 036/366] Fix for portals --- .../com/songoda/skyblock/permission/PermissionManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 27ab7761..64dcca9c 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -164,8 +164,6 @@ public class PermissionManager { BasicPermission permission = wrapper.getPermission(); - //if(cancellable instanceof PlayerMoveEvent) Bukkit.broadcastMessage("A " + permission.getName()); - if (hasPermission(player, island, permission, reversePermission)) continue; @@ -175,7 +173,7 @@ public class PermissionManager { e.printStackTrace(); } } - return true; + return !cancellable.isCancelled(); } public boolean hasPermission(Player player, Island island, BasicPermission permission, boolean reversePermission){ From dfdf0ae259461c9c4ff2f6d6bf5d8b3dd4d6eb79 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 23:01:36 +0200 Subject: [PATCH 037/366] Removed old admin Settings file --- .../commands/admin/SettingsCommand.java | 10 - .../skyblock/menus/admin/Settings.java | 686 ------------------ 2 files changed, 696 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/menus/admin/Settings.java diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java index d19e3fd9..7e05dfdb 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java @@ -2,21 +2,11 @@ package com.songoda.skyblock.command.commands.admin; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; -import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.gui.GuiPermissionsSelector; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.menus.admin.Settings; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import java.io.File; - public class SettingsCommand extends SubCommand { @Override diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Settings.java b/src/main/java/com/songoda/skyblock/menus/admin/Settings.java deleted file mode 100644 index 4704431b..00000000 --- a/src/main/java/com/songoda/skyblock/menus/admin/Settings.java +++ /dev/null @@ -1,686 +0,0 @@ -package com.songoda.skyblock.menus.admin; - -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.item.nInventoryUtil; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class Settings { - - private static Settings instance; - - public static Settings getInstance() { - if (instance == null) { - instance = new Settings(); - } - - return instance; - } - - public void open(Player player, Settings.Type menuType, IslandRole role) { - SkyBlock skyblock = SkyBlock.getInstance(); - - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); - - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); - Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = languageConfig.getFileConfiguration(); - - if (menuType == Settings.Type.Categories) { - nInventoryUtil nInv = new nInventoryUtil(player, event -> { - if (!(player.hasPermission("fabledskyblock.admin.settings") || player.hasPermission("fabledskyblock.admin.*") - || player.hasPermission("fabledskyblock.*"))) { - messageManager.sendMessage(player, - configLoad.getString("Island.Admin.Settings.Permission.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - - return; - } - - ItemStack is = event.getItem(); - - if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F); - } else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName() - .equals(ChatColor.translateAlternateColorCodes('&', configLoad - .getString("Menu.Admin.Settings.Categories.Item.Visitor.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Visitor), 1L); - } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Categories.Item.Member.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Member), 1L); - } else if ((is.getType() == Material.ITEM_FRAME) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName() - .equals(ChatColor.translateAlternateColorCodes('&', configLoad - .getString("Menu.Admin.Settings.Categories.Item.Operator.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Operator), 1L); - } else if ((is.getType() == Material.NAME_TAG) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Categories.Item.Coop.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Coop), 1L); - } else if ((is.getType() == CompatibleMaterial.OAK_SAPLING.getMaterial()) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Owner), 1L); - } - }); - - nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial()), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Visitor.Displayname"), - configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Visitor.Lore"), null, null, null), 2); - nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Member.Displayname"), - configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Member.Lore"), null, null, null), 3); - nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Operator.Displayname"), - configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Operator.Lore"), null, null, null), - 4); - - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Coop.Enable")) { - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"), null, null, null, - null), 0); - nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Coop.Displayname"), - configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Coop.Lore"), null, null, null), - 6); - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"), - configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Owner.Lore"), null, null, null), - 7); - } else { - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"), null, null, null, - null), 0, 8); - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(), - configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"), - configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Owner.Lore"), null, null, null), - 6); - } - - nInv.setTitle(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Categories.Title"))); - nInv.setRows(1); - - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); - } else if (menuType == Settings.Type.Role) { - nInventoryUtil nInv = new nInventoryUtil(player, event -> { - if (!(player.hasPermission("fabledskyblock.admin.settings") || player.hasPermission("fabledskyblock.admin.*") - || player.hasPermission("fabledskyblock.*"))) { - messageManager.sendMessage(player, - configLoad.getString("Island.Admin.Settings.Permission.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - - return; - } - - ItemStack is = event.getItem(); - - if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta()) && (is - .getItemMeta().getDisplayName() - .equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Visitor.Item.Return.Displayname"))) - || is.getItemMeta().getDisplayName() - .equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Member.Item.Return.Displayname"))) - || is.getItemMeta().getDisplayName() - .equals(ChatColor.translateAlternateColorCodes('&', - configLoad - .getString("Menu.Admin.Settings.Operator.Item.Return.Displayname"))) - || is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings.Owner.Item.Return.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Categories, null), 1L); - } else if (is.hasItemMeta()) { - String roleName = getRoleName(role); - - FileConfiguration settingsConfigLoad = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "settings.yml")).getFileConfiguration(); - - for (String settingList : settingsConfigLoad.getConfigurationSection("Settings." + role.name()) - .getKeys(false)) { - if (is.getItemMeta().getDisplayName() - .equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings." + roleName + ".Item.Setting." - + settingList + ".Displayname")))) { - if (settingsConfigLoad.getBoolean("Settings." + role.name() + "." + settingList)) { - settingsConfigLoad.set("Settings." + role.name() + "." + settingList, false); - } else { - settingsConfigLoad.set("Settings." + role.name() + "." + settingList, true); - } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { - try { - Config config = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "settings.yml")); - config.getFileConfiguration().save(config.getFile()); - } catch (IOException e) { - e.printStackTrace(); - } - }); - - break; - } - } - - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, role), 1L); - } - }); - - if (role == IslandRole.Visitor - || role == IslandRole.Member - || role == IslandRole.Coop) { - nInv.addItemStack(createItem(role, "Destroy", new ItemStack(Material.DIAMOND_PICKAXE)), 9); - nInv.addItemStack(createItem(role, "Place", new ItemStack(Material.GRASS)), 10); - nInv.addItemStack(createItem(role, "Anvil", new ItemStack(Material.ANVIL)), 11); - nInv.addItemStack(createItem(role, "ArmorStandUse", new ItemStack(Material.ARMOR_STAND)), 12); - nInv.addItemStack(createItem(role, "Beacon", new ItemStack(Material.BEACON)), 13); - nInv.addItemStack(createItem(role, "Bed", CompatibleMaterial.WHITE_BED.getItem()), 14); - nInv.addItemStack(createItem(role, "AnimalBreeding", new ItemStack(Material.WHEAT)), 15); - nInv.addItemStack( - createItem(role, "Brewing", new ItemStack(CompatibleMaterial.BREWING_STAND.getMaterial())), - 16); - nInv.addItemStack(createItem(role, "Bucket", new ItemStack(Material.BUCKET)), 17); - nInv.addItemStack(createItem(role, "WaterCollection", new ItemStack(Material.POTION)), 18); - nInv.addItemStack(createItem(role, "Storage", new ItemStack(Material.CHEST)), 19); - nInv.addItemStack(createItem(role, "Workbench", CompatibleMaterial.CRAFTING_TABLE.getItem()), 20); - nInv.addItemStack(createItem(role, "Crop", CompatibleMaterial.WHEAT_SEEDS.getItem()), 21); - nInv.addItemStack(createItem(role, "Door", CompatibleMaterial.OAK_DOOR.getItem()), 22); - nInv.addItemStack(createItem(role, "Gate", CompatibleMaterial.OAK_FENCE_GATE.getItem()), 23); - nInv.addItemStack(createItem(role, "Projectile", new ItemStack(Material.ARROW)), 24); - nInv.addItemStack(createItem(role, "Enchant", CompatibleMaterial.ENCHANTING_TABLE.getItem()), 25); - nInv.addItemStack(createItem(role, "Fire", new ItemStack(Material.FLINT_AND_STEEL)), 26); - nInv.addItemStack(createItem(role, "Furnace", new ItemStack(Material.FURNACE)), 27); - nInv.addItemStack(createItem(role, "HorseInventory", CompatibleMaterial.CHEST_MINECART.getItem()), 28); - nInv.addItemStack(createItem(role, "MobRiding", new ItemStack(Material.SADDLE)), 29); - nInv.addItemStack(createItem(role, "MonsterHurting", CompatibleMaterial.BONE.getItem()), 30); - nInv.addItemStack(createItem(role, "MobHurting", CompatibleMaterial.WOODEN_SWORD.getItem()), 31); - nInv.addItemStack(createItem(role, "MobTaming", CompatibleMaterial.POPPY.getItem()), 32); - nInv.addItemStack(createItem(role, "Leash", CompatibleMaterial.LEAD.getItem()), 33); - nInv.addItemStack(createItem(role, "LeverButton", new ItemStack(Material.LEVER)), 34); - nInv.addItemStack(createItem(role, "Milking", new ItemStack(Material.MILK_BUCKET)), 35); - nInv.addItemStack(createItem(role, "Jukebox", new ItemStack(Material.JUKEBOX)), 36); - nInv.addItemStack(createItem(role, "PressurePlate", CompatibleMaterial.OAK_PRESSURE_PLATE.getItem()), 37); - nInv.addItemStack(createItem(role, "Redstone", new ItemStack(Material.REDSTONE)), 38); - nInv.addItemStack(createItem(role, "Shearing", new ItemStack(Material.SHEARS)), 39); - nInv.addItemStack(createItem(role, "Trading", new ItemStack(Material.EMERALD)), 40); - nInv.addItemStack(createItem(role, "ItemDrop", new ItemStack(Material.PUMPKIN_SEEDS)), 41); - nInv.addItemStack(createItem(role, "ItemPickup", new ItemStack(Material.MELON_SEEDS)), 42); - nInv.addItemStack(createItem(role, "Fishing", new ItemStack(Material.FISHING_ROD)), 43); - nInv.addItemStack(createItem(role, "DropperDispenser", new ItemStack(Material.DISPENSER)), 44); - nInv.addItemStack(createItem(role, "SpawnEgg", new ItemStack(Material.EGG)), 45); - nInv.addItemStack(createItem(role, "HangingDestroy", new ItemStack(Material.ITEM_FRAME)), 46); - nInv.addItemStack(createItem(role, "Cake", new ItemStack(Material.CAKE)), 47); - nInv.addItemStack(createItem(role, "DragonEggUse", new ItemStack(Material.DRAGON_EGG)), 48); - nInv.addItemStack(createItem(role, "MinecartBoat", new ItemStack(Material.MINECART)), 49); - nInv.addItemStack(createItem(role, "Portal", new ItemStack(Material.ENDER_PEARL)), 50); - nInv.addItemStack(createItem(role, "Hopper", new ItemStack(Material.HOPPER)), 51); - nInv.addItemStack(createItem(role, "EntityPlacement", new ItemStack(Material.ARMOR_STAND)), 52); - nInv.addItemStack(createItem(role, "ExperienceOrbPickup", CompatibleMaterial.EXPERIENCE_BOTTLE.getItem()), 53); - - nInv.setRows(6); - } else if (role == IslandRole.Operator) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Banning")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Coop.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 9); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 10); - nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 11); - nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 12); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 13); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 14); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 15); - nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 16); - nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 17); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 21); - nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 22); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24); - } else { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 9); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 10); - nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 11); - nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 12); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 13); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 14); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 15); - nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 16); - nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 17); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 21); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24); - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11); - nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 12); - nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 13); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 14); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 15); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 16); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 21); - nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 22); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24); - } else { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11); - nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 12); - nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 13); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 14); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 15); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 16); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 21); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24); - } - } - - nInv.setRows(3); - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Coop.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 12); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 13); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 14); - nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 15); - nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 16); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 21); - nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 22); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24); - } else { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 12); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 13); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 14); - nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 15); - nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 16); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 21); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24); - } - - nInv.setRows(3); - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 12); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 13); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 14); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 15); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 16); - nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 21); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 22); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 23); - - nInv.setRows(3); - } else { - nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 9); - nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 10); - nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 11); - nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 12); - nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 13); - nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 14); - nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)), - 15); - nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 16); - nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 17); - - nInv.setRows(2); - } - } - } - } else if (role == IslandRole.Owner) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.PvP.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 10); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 10); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 17); - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 10); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16); - } - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 10); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16); - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 14); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 15); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 16); - } - } - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 10); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 11); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 12); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16); - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack( - createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16); - } - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 15); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16); - } - } else { - if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 10); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 11); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16); - } else { - nInv.addItemStack( - createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), - 11); - nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()), - 12); - nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13); - nInv.addItemStack( - createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14); - nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15); - } - } - } - } - - nInv.setRows(2); - } - - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), - configLoad.getString("Menu.Admin.Settings." + role.name() + ".Item.Return.Displayname"), null, null, - null, null), 0, 8); - nInv.setTitle(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings." + role.name() + ".Title"))); - - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); - } - } - - private ItemStack createItem(IslandRole role, String setting, ItemStack is) { - SkyBlock skyblock = SkyBlock.getInstance(); - - FileManager fileManager = skyblock.getFileManager(); - - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - List itemLore = new ArrayList<>(); - - ItemMeta im = is.getItemMeta(); - - String roleName = role.name(); - - if (role == IslandRole.Visitor - || role == IslandRole.Member - || role == IslandRole.Coop) { - roleName = "Default"; - } - - im.setDisplayName(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Admin.Settings." + roleName + ".Item.Setting." + setting + ".Displayname"))); - - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "settings.yml")).getFileConfiguration() - .getBoolean("Settings." + role.name() + "." + setting)) { - for (String itemLoreList : configLoad - .getStringList("Menu.Admin.Settings." + roleName + ".Item.Setting.Status.Enabled.Lore")) { - itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList)); - } - } else { - for (String itemLoreList : configLoad - .getStringList("Menu.Admin.Settings." + roleName + ".Item.Setting.Status.Disabled.Lore")) { - itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList)); - } - } - - im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - im.setLore(itemLore); - is.setItemMeta(im); - - return is; - } - - private String getRoleName(IslandRole role) { - if (role == IslandRole.Visitor - || role == IslandRole.Member - || role == IslandRole.Coop) { - return "Default"; - } - - return role.name(); - } - - public enum Type { - - Categories, Panel, Role - - } -} From 6b6386864f36072b6b3d4309bab1e37961c65b07 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 23:31:29 +0200 Subject: [PATCH 038/366] Let settings auto generate with respect for other plugins --- .../songoda/skyblock/config/FileManager.java | 2 +- .../permission/PermissionManager.java | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java index f83418a6..07432f50 100644 --- a/src/main/java/com/songoda/skyblock/config/FileManager.java +++ b/src/main/java/com/songoda/skyblock/config/FileManager.java @@ -98,7 +98,7 @@ public class FileManager { } if (configFile.exists()) { - if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("settings.yml") || fileName.equals("worlds.yml")) { + if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("worlds.yml")) { FileChecker fileChecker; if (fileName.equals("config.yml")) { diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 64dcca9c..9bb7d17d 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -15,6 +15,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.player.PlayerMoveEvent; import java.io.File; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; @@ -114,7 +115,43 @@ public class PermissionManager { })).collect(Collectors.toList()); } + private void updateSettingsConfig(BasicPermission permission){ + FileManager.Config settingsConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "settings.yml")); + FileConfiguration settingsConfigLoad = settingsConfig.getFileConfiguration(); + + switch (permission.getType()){ + case GENERIC: + if(settingsConfigLoad.getString("Settings.Visitor." + permission.getName()) == null){ + settingsConfigLoad.set("Settings.Visitor." + permission.getName(), true); + } + if(settingsConfigLoad.getString("Settings.Member." + permission.getName()) == null){ + settingsConfigLoad.set("Settings.Member." + permission.getName(), true); + } + if(settingsConfigLoad.getString("Settings.Coop." + permission.getName()) == null){ + settingsConfigLoad.set("Settings.Coop." + permission.getName(), true); + } + break; + case OPERATOR: + if(settingsConfigLoad.getString("Settings.Operator." + permission.getName()) == null){ + settingsConfigLoad.set("Settings.Operator." + permission.getName(), true); + } + break; + case ISLAND: + if(settingsConfigLoad.getString("Settings.Owner." + permission.getName()) == null){ + settingsConfigLoad.set("Settings.Owner." + permission.getName(), true); + } + break; + } + try { + settingsConfigLoad.save(settingsConfig.getFile()); + } catch (IOException e) { + e.printStackTrace(); + } + } + public boolean registerPermission(BasicPermission permission) { + updateSettingsConfig(permission); + registeredPermissions.put(permission.getName().toUpperCase(), permission); Set methods; try { From c3fc22917788b0ce97529e0b83081f7c52e2e084 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 19 Jun 2020 23:32:02 +0200 Subject: [PATCH 039/366] Removed Hunger from island default settings --- src/main/resources/settings.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 63f8fe53..cbaed5f7 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -167,5 +167,4 @@ Settings: Explosions: false FireSpread: true LeafDecay: true - KeepItemsOnDeath: true - Hunger: true \ No newline at end of file + KeepItemsOnDeath: true \ No newline at end of file From d40ac674b7e81297510ccdaf1984c554a6ad2ab7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 00:38:20 +0200 Subject: [PATCH 040/366] Simplify and fix problem from formatted placeholder in Scoreboard --- .../songoda/skyblock/scoreboard/Scoreboard.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java index f233a755..8b5af07a 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java @@ -1,10 +1,6 @@ package com.songoda.skyblock.scoreboard; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -118,9 +114,9 @@ public class Scoreboard { if (displayLine.length() >= 16) { String prefixLine = displayLine.substring(0, Math.min(displayLine.length(), 16)); - String suffixLine = displayLine.substring(16, Math.min(displayLine.length(), displayLine.length())); + String suffixLine = displayLine.substring(16); - if (prefixLine.substring(prefixLine.length() - 1).equals("&")) { + if (prefixLine.endsWith("&")) { prefixLine = ChatColor.translateAlternateColorCodes('&', prefixLine.substring(0, prefixLine.length() - 1)); suffixLine = ChatColor.translateAlternateColorCodes('&', "&" + suffixLine); } else { @@ -175,7 +171,8 @@ public class Scoreboard { IslandManager islandManager = skyblock.getIslandManager(); - displayLine = displayLine.replace("%players_online", "" + Bukkit.getServer().getOnlinePlayers().size()).replace("%players_max", "" + Bukkit.getServer().getMaxPlayers()); + displayLine = displayLine.replace("%players_online", String.valueOf(Bukkit.getServer().getOnlinePlayers().size())); + displayLine = displayLine.replace("%players_max", String.valueOf(Bukkit.getServer().getMaxPlayers())); Island island = islandManager.getIsland(player); @@ -212,9 +209,9 @@ public class Scoreboard { PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); if (placeholderManager.isPlaceholderAPIEnabled()) { - displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine.replace("&", "clr")).replace("clr", "&"); + displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine); } - return displayLine; + return displayLine.replace("§", "&"); // Returning unformatted line to avoid issues in next step } } From b46473e9fddcc6f161b033c70269413d709f6d8c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 00:48:27 +0200 Subject: [PATCH 041/366] Heavier checks for portals teleporting to real Nether/End --- .../com/songoda/skyblock/listeners/Teleport.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index 81c52552..5b39d75f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -61,13 +61,23 @@ public class Teleport implements Listener { islandManager.loadPlayer(player); - // Fix for bug that tp you in the real Nether/End when entering in a portal in an island + // Fix for bug that tp you in the real Nether/End when entering in a portal in an island // TODO Simplify if (event.getTo() != null && (worldManager.isIslandWorld(event.getFrom().getWorld()) && !worldManager.isIslandWorld(event.getTo().getWorld()) && (event.getFrom().getBlock().getType().equals(CompatibleMaterial.END_PORTAL.getMaterial()) - || event.getFrom().getBlock().getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) && (event.getTo().getWorld() != null + || event.getFrom().getBlock().getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) + && (event.getTo().getWorld() != null && event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER) - || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END)))) { + || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END))) + || event.getTo() != null + && (worldManager.isIslandWorld(event.getFrom().getWorld()) + && !worldManager.isIslandWorld(event.getTo().getWorld()) + && (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) + || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL) + || event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)) + && (event.getTo().getWorld() != null + && event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER) + || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END)))) { event.setCancelled(true); } From d8e38a25500c5bb6d87acfc63ec61cd3c9babbf9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 01:42:00 +0200 Subject: [PATCH 042/366] Protect visitors Spawn point --- src/main/java/com/songoda/skyblock/listeners/Block.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index cb737dd9..451846df 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -129,7 +129,8 @@ public class Block implements Listener { IslandWorld world = worldManager.getIslandWorld(block.getWorld()); if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D)) - || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone())) { + || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone()) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0.0D, 1.0D, 0.0D)) + || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone())) { if (configLoad.getBoolean("Island.Spawn.Protection")) { event.setCancelled(true); skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message")); From 92ea9f4404d104f0bc1a74ec1bf2c9e03fe8e6c3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 01:42:10 +0200 Subject: [PATCH 043/366] Fix conversion error in challenges --- .../com/songoda/skyblock/challenge/challenge/Challenge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 28ff0685..6a3c26b7 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -244,7 +244,7 @@ public class Challenge { Island is = SkyBlock.getInstance().getIslandManager().getIsland(p); // Player doesn't have an island if (is != null && obj instanceof Number) { - return is.getLevel().getLevel() >= (Long) obj; + return is.getLevel().getLevel() >= ((Number) obj).longValue(); } return false; } From fc8a95d1c1a0d6f9ae2a756f45366ff9bcdc2dde Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 03:39:25 +0200 Subject: [PATCH 044/366] Fixed ArmorStand and ItemFrame that can be destroyed --- .../songoda/skyblock/listeners/Entity.java | 8 +++++ .../listening/DestroyPermission.java | 30 ++++++++++++------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index ad47df64..4083abf2 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -16,6 +16,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.*; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -111,6 +112,13 @@ public class Entity implements Listener { skyblock.getPermissionManager() .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true); + } else if((event.getDamager() instanceof org.bukkit.entity.Projectile + && ((Projectile) event.getDamager()).getShooter() instanceof Player) + && (event.getEntity().getType().equals(EntityType.ARMOR_STAND) + || event.getEntity().getType().equals(EntityType.ITEM_FRAME))){ + Player player = (Player) ((Projectile) event.getDamager()).getShooter(); + skyblock.getPermissionManager() + .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); } else { // Make it work with all the entities, not just TNT org.bukkit.entity.Entity entity = event.getEntity(); diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java index 9dd2f7f8..b6f1439e 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java @@ -6,9 +6,8 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; +import org.bukkit.Bukkit; +import org.bukkit.entity.*; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -27,8 +26,6 @@ public class DestroyPermission extends ListeningPermission { @PermissionHandler public void onInteract(PlayerInteractEvent event) { - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return; @@ -42,13 +39,24 @@ public class DestroyPermission extends ListeningPermission { @PermissionHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if (!(event.getDamager() instanceof Player)) return; - Player player = (Player)event.getDamager(); - Entity entity = event.getEntity(); + Player player = null; + if (event.getDamager() instanceof Player) { + player = (Player) event.getDamager(); + } + if(event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player){ + player = (Player) ((Projectile) event.getDamager()).getShooter(); + } + if(player != null){ + Entity entity = event.getEntity(); - if (entity.getType() != EntityType.ARMOR_STAND) return; - - cancelAndMessage(event, player, plugin, messageManager); + switch (entity.getType()){ + case ARMOR_STAND: + case PAINTING: + case ITEM_FRAME: + cancelAndMessage(event, player, plugin, messageManager); + break; + } + } } @PermissionHandler From 0496fe629db0e4ffeda044580215390e5fad372f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 03:39:55 +0200 Subject: [PATCH 045/366] Little optimization in island spawn checking --- src/main/java/com/songoda/skyblock/listeners/Block.java | 5 ++--- src/main/java/com/songoda/skyblock/listeners/Entity.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 451846df..ce16ea0d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -128,9 +128,8 @@ public class Block implements Listener { IslandWorld world = worldManager.getIslandWorld(block.getWorld()); - if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D)) - || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone()) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0.0D, 1.0D, 0.0D)) - || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone())) { + if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D)) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0.0D, 1.0D, 0.0D)) + || LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) { if (configLoad.getBoolean("Island.Spawn.Protection")) { event.setCancelled(true); skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message")); diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 4083abf2..342b2b87 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -304,7 +304,7 @@ public class Entity implements Listener { } if ((event.getEntityType() == EntityType.FALLING_BLOCK) - && LocationUtil.isLocationLocation(event.getBlock().getLocation(), island.getLocation(world, IslandEnvironment.Main).clone()) + && LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && configLoad.getBoolean("Island.Spawn.Protection")) { FallingBlock fallingBlock = (FallingBlock) event.getEntity(); if (fallingBlock.getDropItem()) { From 8be6bdfe7e718a362050a676febd2dd1202dc038 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 03:40:18 +0200 Subject: [PATCH 046/366] New method take() for Stackable --- .../java/com/songoda/skyblock/stackable/Stackable.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/stackable/Stackable.java b/src/main/java/com/songoda/skyblock/stackable/Stackable.java index 54db7f92..948b1665 100644 --- a/src/main/java/com/songoda/skyblock/stackable/Stackable.java +++ b/src/main/java/com/songoda/skyblock/stackable/Stackable.java @@ -110,6 +110,13 @@ public class Stackable { this.save(); } + public void take(int n) { + this.size-=n; + this.updateDisplay(); + SkyBlock.getInstance().getSoundManager().playSound(this.location, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); + this.save(); + } + public boolean isMaxSize(){ return size > maxSize; } From 9ae191c4c4d5833eac9cad5d6a559d5ec6d43534 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 05:00:58 +0200 Subject: [PATCH 047/366] Protect Stackables from explosions --- .../songoda/skyblock/listeners/Entity.java | 115 +++++++++++------- 1 file changed, 74 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 342b2b87..1a0a954d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -6,6 +6,7 @@ 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; +import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.upgrade.Upgrade; import com.songoda.skyblock.utils.version.NMSUtil; @@ -14,6 +15,7 @@ import com.songoda.skyblock.world.WorldManager; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.*; import org.bukkit.entity.Projectile; @@ -343,21 +345,8 @@ public class Entity implements Listener { .getBoolean("Island.Block.Level.Enable")) return; - CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(block.getType()); - - if (materials != null) { - IslandLevel level = island.getLevel(); - - if (level.hasMaterial(materials.name())) { - long materialAmount = level.getMaterialAmount(materials.name()); - - if (materialAmount - 1 <= 0) { - level.removeMaterial(materials.name()); - } else { - level.setMaterialAmount(materials.name(), materialAmount - 1); - } - } - } + removeBlockFromLevel(island, block); + CompatibleMaterial materials; if (event.getTo() != null && event.getTo() != Material.AIR) { materials = CompatibleMaterial.getBlockMaterial(event.getTo()); @@ -377,7 +366,7 @@ public class Entity implements Listener { } - @EventHandler + @EventHandler(priority = EventPriority.LOW) public void onEntityExplode(EntityExplodeEvent event) { org.bukkit.entity.Entity entity = event.getEntity(); @@ -387,47 +376,91 @@ public class Entity implements Listener { if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) { // Check permissions. Island island = islandManager.getIslandAtLocation(entity.getLocation()); - skyblock.getPermissionManager().processPermission(event, null, island); if (!event.isCancelled()) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Block.Level.Enable")) { - for (org.bukkit.block.Block blockList : event.blockList()) { - @SuppressWarnings("deprecation") - CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(blockList.getType()); - if (materials != null) { - IslandLevel level = island.getLevel(); + StackableManager stackableManager = skyblock.getStackableManager(); - if (level.hasMaterial(materials.name())) { - long materialAmount = level.getMaterialAmount(materials.name()); + boolean removed; + Iterator it = event.blockList().iterator(); + while (it.hasNext()){ + removed = false; + org.bukkit.block.Block block = it.next(); + if (SkyBlock.getInstance().getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Spawn.Protection")) { + IslandWorld world = worldManager.getIslandWorld(event.getEntity().getWorld()); + if (LocationUtil.isLocationLocation(block.getLocation(), + island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))) { + it.remove(); + removed = true; + } + } - if (materialAmount - 1 <= 0) { - level.removeMaterial(materials.name()); - } else { - level.setMaterialAmount(materials.name(), materialAmount - 1); - } + Location blockLocation = block.getLocation(); + + if (stackableManager != null && stackableManager.isStacked(blockLocation)) { + Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block)); + if (stackable != null) { + CompatibleMaterial material = CompatibleMaterial.getMaterial(block); + byte data = block.getData(); + + int removedAmount = (int) (Math.random() * Math.min(64, stackable.getSize()-1)); + stackable.take(removedAmount); + Bukkit.getScheduler().runTask(skyblock, () -> { + block.getWorld().dropItemNaturally(blockLocation.clone().add(.5, 1, .5), + new ItemStack(material.getMaterial(), (int) (Math.random() * removedAmount), data)); + }); + + if (stackable.getSize() <= 1) { + stackableManager.removeStack(stackable); + } + + Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (configLoad.getBoolean("Island.Block.Level.Enable")) { + removeBlockFromLevel(island, block); + } + + it.remove(); + if(!removed){ + removed = true; } } } - } - - if (SkyBlock.getInstance().getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Spawn.Protection")) { - IslandWorld world = worldManager.getIslandWorld(event.getEntity().getWorld()); - for (org.bukkit.block.Block block : event.blockList()) { - if (LocationUtil.isLocationLocation(block.getLocation(), - island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))) { - event.blockList().remove(block); - break; + if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Block.Level.Enable")) { + if(!removed){ + removeBlockFromLevel(island, block); } + } } } } } + private void removeBlockFromLevel(Island island, CompatibleMaterial material){ + if (material != null) { + IslandLevel level = island.getLevel(); + + if (level.hasMaterial(material.name())) { + long materialAmount = level.getMaterialAmount(material.name()); + + if (materialAmount - 1 <= 0) { + level.removeMaterial(material.name()); + } else { + level.setMaterialAmount(material.name(), materialAmount - 1); + } + } + } + } + + private void removeBlockFromLevel(Island island, Block block) { + removeBlockFromLevel(island, CompatibleMaterial.getBlockMaterial(block.getType())); + } + @EventHandler(priority = EventPriority.MONITOR) public void onEntityDeath(EntityDeathEvent event) { LivingEntity livingEntity = event.getEntity(); From a6c1601836acf559de4025e73aaec32ff2b5c57f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 05:01:20 +0200 Subject: [PATCH 048/366] 2.3.3-DEV --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0839c7df..b90c4dd9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.2 + 2.3.3-DEV jar clean install From 3c2efb620561b1e47ad39c4623e3e4a6cfd9feee Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 14:52:19 +0200 Subject: [PATCH 049/366] Fix for asynchronous chunk load --- src/main/java/com/songoda/skyblock/listeners/Move.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 6ba945aa..ff9f5c44 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -240,7 +240,9 @@ public class Move implements Listener { final Player player = e.getPlayer(); final WorldManager worldManager = skyblock.getWorldManager(); if(e.getTo() != null && e.getTo().getWorld() != null){ - e.getTo().getWorld().loadChunk(e.getTo().getChunk()); + if(!e.isAsynchronous()){ + e.getTo().getWorld().loadChunk(e.getTo().getChunk()); // Is that needed? + } if(worldManager.isIslandWorld(e.getTo().getWorld()) && (!e.getTo().getWorld().equals(e.getFrom().getWorld()) || e.getTo().distance(e.getFrom()) > 1.0d)){ // We should not care of self block tp if(skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null){ From 5526fbc3c5391bb75bb9e13a5e1452f58d7e4b25 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 16:09:35 +0200 Subject: [PATCH 050/366] Rewriting bank GUI with Songoda library --- .../java/com/songoda/skyblock/SkyBlock.java | 4 + .../songoda/skyblock/bank/BankManager.java | 16 ++- .../commands/admin/SettingsCommand.java | 2 +- .../commands/island/SettingsCommand.java | 5 +- .../songoda/skyblock/gui/bank/GuiBank.java | 78 +++++++++++++ .../skyblock/gui/bank/GuiBankTransaction.java | 107 ++++++++++++++++++ .../GuiAdminPermissions.java | 2 +- .../gui/{ => permissions}/GuiPermissions.java | 4 +- .../GuiPermissionsSelector.java | 2 +- 9 files changed, 211 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java create mode 100644 src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java rename src/main/java/com/songoda/skyblock/gui/{ => permissions}/GuiAdminPermissions.java (99%) rename src/main/java/com/songoda/skyblock/gui/{ => permissions}/GuiPermissions.java (98%) rename src/main/java/com/songoda/skyblock/gui/{ => permissions}/GuiPermissionsSelector.java (99%) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 3d2771f4..a0bd5649 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -276,6 +276,10 @@ public class SkyBlock extends SongodaPlugin { return banManager; } + public BankManager getBankManager() { + return bankManager; + } + public IslandManager getIslandManager() { return islandManager; } diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index ed04a101..03468d07 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -33,7 +33,7 @@ public class BankManager { loadTransactions(); } - public List getTransactions(Player player) { + /*public List getTransactions(Player player) { if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) { List lore = new ArrayList<>(); List transactions = log.get(player.getUniqueId()); @@ -49,6 +49,20 @@ public class BankManager { lore.add(lang.getString("Menu.Bank.Item.Log.Empty")); return lore; } + }*/ + + public List getTransactions(Player player) { + return getTransactions(player.getUniqueId()); + } + + public List getTransactions(UUID uuid) { + if (log.containsKey(uuid) + && log.get(uuid) != null + && !log.get(uuid).isEmpty()) { + return new ArrayList<>(log.get(uuid)); + }else { + return new ArrayList<>(); + } } public void addTransaction(Player p, Transaction transaction) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java index 7e05dfdb..7db1efa6 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java @@ -2,7 +2,7 @@ package com.songoda.skyblock.command.commands.admin; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; -import com.songoda.skyblock.gui.GuiPermissionsSelector; +import com.songoda.skyblock.gui.permissions.GuiPermissionsSelector; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java index 16f98a9f..52ddba14 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java @@ -3,14 +3,11 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.gui.GuiPermissions; -import com.songoda.skyblock.gui.GuiPermissionsSelector; +import com.songoda.skyblock.gui.permissions.GuiPermissionsSelector; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.menus.Settings; import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.command.ConsoleCommandSender; diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java new file mode 100644 index 00000000..ac097e65 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java @@ -0,0 +1,78 @@ +package com.songoda.skyblock.gui.bank; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.gui.GuiSignatureEditor; +import com.songoda.skyblock.gui.GuiWelcomeEditor; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandPermission; +import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.permission.BasicPermission; +import com.songoda.skyblock.permission.PermissionManager; +import com.songoda.skyblock.visit.Visit; +import org.bukkit.configuration.file.FileConfiguration; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class GuiBank extends Gui { + private final SkyBlock plugin; + private final PermissionManager permissionManager; + private final Island island; + private final FileConfiguration languageLoad; + private final FileManager.Config config; + private final Gui returnGui; + + public GuiBank(SkyBlock plugin, Island island, Gui returnGui) { + super(6, returnGui); + this.plugin = plugin; + this.permissionManager = plugin.getPermissionManager(); + this.island = island; + this.returnGui = returnGui; + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Settings.Title"))); // TODO Title + setDefaultItem(null); + paint(); + } + + public void paint() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 1, 8, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + guiManager.showGUI(event.player, returnGui); + }); + + setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK, // Transaction log + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this)); + }); + + setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.RED_DYE, // Deposit + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + guiManager.showGUI(event.player, returnGui); + }); + + setItem(13, GuiUtils.createButtonItem(CompatibleMaterial.GOLD_INGOT, // Balance + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname")))); + + setButton(16, GuiUtils.createButtonItem(CompatibleMaterial.GREEN_DYE, // WithDraw + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + guiManager.showGUI(event.player, returnGui); + }); + } +} diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java new file mode 100644 index 00000000..a8c8d218 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java @@ -0,0 +1,107 @@ +package com.songoda.skyblock.gui.bank; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.bank.BankManager; +import com.songoda.skyblock.bank.Transaction; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.island.Island; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.inventory.ItemStack; + +import java.io.File; +import java.util.List; + +public class GuiBankTransaction extends Gui { + private final SkyBlock plugin; + private final BankManager bankManager; + private final FileConfiguration languageLoad; + private final FileManager.Config config; + private final Gui returnGui; + private final int transactions; + private final List transactionList; + + public GuiBankTransaction(SkyBlock plugin, Island island, Gui returnGui) { + super(returnGui); + this.plugin = plugin; + this.bankManager = plugin.getBankManager(); + this.transactionList = bankManager.getTransactions(island.getOwnerUUID()); + this.transactions = this.transactionList.size(); + this.returnGui = returnGui; + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + + if(transactions == 0){ + setRows(2); + } else if(transactions > 4*9){ + setRows(6); + } else { + setRows(transactions%9+1); + } + + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Settings.Title"))); // TODO Title + setDefaultItem(null); + paint(); + } + + public void paint() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 1, 8, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + guiManager.showGUI(event.player, returnGui); + }); + + setItem(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, // Info + TextUtils.formatText(languageLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname")))); + + this.pages = (int) Math.max(1, Math.ceil((double) transactions / 36d)); + + if (page != 1) + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Last.Displayname"))), + (event) -> { + page--; + paint(); + }); + + if (page != pages) + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); + + for (int i = 9; i < 45; i++) { // TODO dynamic dimension! + int current = ((page - 1) * 36) - 9; + if (current + i >= transactions) { + setItem(i, null); + continue; + } + Transaction transaction = transactionList.get(current + i); + if (transaction == null) continue; + + ItemStack is = null; + switch(transaction.action){ + case WITHDRAW: + is = CompatibleMaterial.GREEN_DYE.getItem(); + break; + case DEPOSIT: + is = CompatibleMaterial.RED_DYE.getItem(); + break; + } + + // TODO set item meta + setItem(i, is); + } + } +} diff --git a/src/main/java/com/songoda/skyblock/gui/GuiAdminPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java similarity index 99% rename from src/main/java/com/songoda/skyblock/gui/GuiAdminPermissions.java rename to src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java index 1089ee1a..a2e8800b 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiAdminPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.gui; +package com.songoda.skyblock.gui.permissions; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; diff --git a/src/main/java/com/songoda/skyblock/gui/GuiPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java similarity index 98% rename from src/main/java/com/songoda/skyblock/gui/GuiPermissions.java rename to src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java index 59711117..cdef8d6d 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.gui; +package com.songoda.skyblock.gui.permissions; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; @@ -7,6 +7,8 @@ import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.gui.GuiSignatureEditor; +import com.songoda.skyblock.gui.GuiWelcomeEditor; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandPermission; import com.songoda.skyblock.island.IslandRole; diff --git a/src/main/java/com/songoda/skyblock/gui/GuiPermissionsSelector.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java similarity index 99% rename from src/main/java/com/songoda/skyblock/gui/GuiPermissionsSelector.java rename to src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java index a722099e..790a5fb1 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiPermissionsSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.gui; +package com.songoda.skyblock.gui.permissions; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; From 6800bc6b471ba5e4b51405873d7afcf198a5bf93 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 21:38:11 +0200 Subject: [PATCH 051/366] New Bank GUI --- .../songoda/skyblock/bank/BankManager.java | 91 ++++- .../songoda/skyblock/bank/Transaction.java | 14 +- .../java/com/songoda/skyblock/bank/Type.java | 6 - .../command/commands/admin/AdminBank.java | 59 ++-- .../command/commands/island/BankCommand.java | 18 +- .../songoda/skyblock/gui/bank/GuiBank.java | 166 ++++++++- .../skyblock/gui/bank/GuiBankTransaction.java | 146 +++++--- .../java/com/songoda/skyblock/menus/Bank.java | 326 ------------------ .../skyblock/playerdata/PlayerData.java | 14 +- src/main/resources/language.yml | 40 ++- 10 files changed, 443 insertions(+), 437 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/bank/Type.java delete mode 100644 src/main/java/com/songoda/skyblock/menus/Bank.java diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 03468d07..466c1f65 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -1,9 +1,14 @@ package com.songoda.skyblock.bank; +import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -11,17 +16,14 @@ import org.bukkit.entity.Player; import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; +import java.util.*; public class BankManager { private static BankManager instance; public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;} - private HashMap> log; + private final HashMap> log; public FileConfiguration lang; @@ -101,4 +103,83 @@ public class BankManager { public List getTransactionList(UUID uuid) { return log.get(uuid); } + + public BankResponse deposit(Player player, Island island, double amt, boolean admin) { + SkyBlock skyblock = SkyBlock.getInstance(); + FileManager fileManager = skyblock.getFileManager(); + + // Make sure the amount is positive + if (amt <= 0) { + return BankResponse.NEGATIVE_AMOUNT; + } + + // If decimals aren't allowed, check for them + if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { + int intAmt = (int) amt; + if (intAmt != amt) { + return BankResponse.DECIMALS_NOT_ALLOWED; + } + } + + if(!admin) { + if (!EconomyManager.hasBalance(player, amt)) { + return BankResponse.NOT_ENOUGH_MONEY; + } + + EconomyManager.withdrawBalance(player, amt); + } + + island.addToBank(amt); + Transaction t = new Transaction(); + t.player = player; + t.amount = (float) amt; + t.timestamp = Calendar.getInstance().getTime(); + t.action = Transaction.Type.DEPOSIT; + t.visibility = admin ? Transaction.Visibility.ADMIN : Transaction.Visibility.USER; + this.addTransaction(player, t); + return BankResponse.SUCCESS; + } + + public BankResponse withdraw(Player player, Island island, double amt, boolean admin) { + SkyBlock skyblock = SkyBlock.getInstance(); + FileManager fileManager = skyblock.getFileManager(); + + // Make sure the amount is positive + if (amt <= 0) { + return BankResponse.NEGATIVE_AMOUNT; + } + + // If decimals aren't allowed, check for them + if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { + int intAmt = (int) amt; + if (intAmt != amt) { + return BankResponse.DECIMALS_NOT_ALLOWED; + } + } + + if(!admin){ + if (amt > island.getBankBalance()) { + return BankResponse.NOT_ENOUGH_MONEY; + } + + EconomyManager.deposit(player, amt); + } + + island.removeFromBank(amt); + Transaction t = new Transaction(); + t.player = player; + t.amount = (float) amt; + t.timestamp = Calendar.getInstance().getTime(); + t.action = Transaction.Type.WITHDRAW; + t.visibility = admin ? Transaction.Visibility.ADMIN : Transaction.Visibility.USER; + this.addTransaction(player, t); + return BankResponse.SUCCESS; + } + + public enum BankResponse{ + NOT_ENOUGH_MONEY, + DECIMALS_NOT_ALLOWED, + NEGATIVE_AMOUNT, + SUCCESS + } } diff --git a/src/main/java/com/songoda/skyblock/bank/Transaction.java b/src/main/java/com/songoda/skyblock/bank/Transaction.java index dc865e44..72e75673 100644 --- a/src/main/java/com/songoda/skyblock/bank/Transaction.java +++ b/src/main/java/com/songoda/skyblock/bank/Transaction.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.bank; +import com.songoda.skyblock.menus.Ownership; import org.bukkit.OfflinePlayer; import java.util.Date; @@ -7,7 +8,18 @@ import java.util.Date; public class Transaction { public OfflinePlayer player; - public float ammount; + public float amount; public Date timestamp; public Type action; + public Visibility visibility; + + public enum Type { + WITHDRAW, + DEPOSIT + } + + public enum Visibility { + ADMIN, + USER + } } \ No newline at end of file diff --git a/src/main/java/com/songoda/skyblock/bank/Type.java b/src/main/java/com/songoda/skyblock/bank/Type.java deleted file mode 100644 index c927ddd9..00000000 --- a/src/main/java/com/songoda/skyblock/bank/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.songoda.skyblock.bank; - -public enum Type { - WITHDRAW, - DEPOSIT -} diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index 14d51502..9448f591 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -4,10 +4,13 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.gui.bank.GuiBank; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; 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 org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -15,15 +18,16 @@ import org.bukkit.entity.Player; import java.io.File; import java.util.Objects; +import java.util.UUID; public class AdminBank extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { + PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); FileManager fileManager = skyblock.getFileManager(); FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); @@ -33,28 +37,21 @@ public class AdminBank extends SubCommand { if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + CompatibleSound.BLOCK_ANVIL_LAND.play(player); return; } if (args.length < 1) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.Short01.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); return; } - if (island == null && args.length <2) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.NullIsland.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - - switch (args[0]) { + switch (args[0].toLowerCase()) { case "balance": if (args.length <2) { - messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Admin.Bank.Balance.Message")).replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); }else { - messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Admin.Bank.Balance.Message")).replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID()))))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID()))))); } return; case "deposit": @@ -62,7 +59,7 @@ public class AdminBank extends SubCommand { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(args[1])).getUniqueId())).addToBank(Double.parseDouble(args[2])); messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); }else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message")); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } return; case "withdraw": @@ -70,12 +67,33 @@ public class AdminBank extends SubCommand { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2])); messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); }else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message")); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } return; + case "open": + if(args.length == 2){ + Player targetPlayer = Bukkit.getServer().getPlayer(args[1]); + UUID islandOwnerUUID; + + if (targetPlayer == null) { + OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[1]); + islandOwnerUUID = targetPlayerOffline.getOwner(); + } else { + islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner(); + } + + island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); + } + if (island != null){ + skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(player); + } + break; default: - configLoad.getString("Command.Island.admin.Bank.Unexpected.Message"); - return; + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(player); } } @@ -101,7 +119,7 @@ public class AdminBank extends SubCommand { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2])); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); }else { - messageManager.sendMessage(sender, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message")); + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } return; case "withdraw": @@ -109,12 +127,11 @@ public class AdminBank extends SubCommand { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2])); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); }else { - messageManager.sendMessage(sender, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message")); + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } return; default: - configLoad.getString("Command.Island.admin.Bank.Unexpected.Message"); - return; + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java index 5b548613..aaa86a8a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java @@ -1,17 +1,14 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.gui.bank.GuiBank; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.menus.Bank; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -23,8 +20,8 @@ public class BankCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); SoundManager soundManager = skyblock.getSoundManager(); + IslandManager islandManager = skyblock.getIslandManager(); FileManager fileManager = skyblock.getFileManager(); Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); @@ -36,7 +33,16 @@ public class BankCommand extends SubCommand { return; } - Bank.getInstance().open(player); + Island island; + island = islandManager.getIsland(player); + + if (island == null) { + skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); + skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Bank.Unknown")); + return; + } + + skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, false)); } @Override diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java index ac097e65..78eba8bd 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java @@ -2,77 +2,205 @@ package com.songoda.skyblock.gui.bank; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.AnvilGui; import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiManager; import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.gui.GuiSignatureEditor; import com.songoda.skyblock.gui.GuiWelcomeEditor; import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandMessage; import com.songoda.skyblock.island.IslandPermission; import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.BasicPermission; import com.songoda.skyblock.permission.PermissionManager; +import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.visit.Visit; import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; public class GuiBank extends Gui { private final SkyBlock plugin; + private final BankManager bankManager; private final PermissionManager permissionManager; private final Island island; private final FileConfiguration languageLoad; - private final FileManager.Config config; + private final FileConfiguration config; private final Gui returnGui; + private final boolean admin; - public GuiBank(SkyBlock plugin, Island island, Gui returnGui) { - super(6, returnGui); - this.plugin = plugin; + public GuiBank(SkyBlock plugin, Island island, Gui returnGui, boolean admin) { + super(2, returnGui); + this.plugin = plugin;; + this.bankManager = plugin.getBankManager(); this.permissionManager = plugin.getPermissionManager(); this.island = island; this.returnGui = returnGui; + this.admin = admin; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); - this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); - setTitle(TextUtils.formatText(languageLoad.getString("Menu.Settings.Title"))); // TODO Title - setDefaultItem(null); + this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setTitle(TextUtils.formatText("Bank")); paint(); } + @Override + public void onOpen(GuiManager manager, Player player) { + updateItem(13, // Balance + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Displayname")), + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Lore") + .replace("%balance", String.valueOf(island.getBankBalance())))); + super.onOpen(manager, player); + } + public void paint() { if (inventory != null) inventory.clear(); + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); setActionForRange(0, 0, 1, 8, null); setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); - guiManager.showGUI(event.player, returnGui); + event.player.closeInventory(); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); }); setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK, // Transaction log - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { - guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this)); + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> { + guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin)); }); setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.RED_DYE, // Deposit - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); - guiManager.showGUI(event.player, returnGui); - }); + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Deposit.Displayname"))), (event -> { + AnvilGui gui = new AnvilGui(event.player, this); + gui.setAction((e -> { + MessageManager messageManager = plugin.getMessageManager(); + + double amount; + try { + amount = Double.parseDouble(gui.getInputText().trim()); + } catch (NumberFormatException e1) { + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + return; + } + BankManager.BankResponse response = bankManager.deposit(e.player, island, amount, admin); + + switch(response){ + case NOT_ENOUGH_MONEY: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case DECIMALS_NOT_ALLOWED: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case NEGATIVE_AMOUNT: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case SUCCESS: + CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player); + messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank.Deposit.Message")).replace( + "%amount%", NumberUtil.formatNumberByDecimal(amount))); + break; + } + + e.player.closeInventory(); + // paint(); + guiManager.showGUI(event.player, this); + })); + + ItemStack input = CompatibleMaterial.PAPER.getItem(); + ItemMeta im = input.getItemMeta(); + if(im != null){ + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount"))); + input.setItemMeta(im); + } + + gui.setInput(input); + gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Deposit"))); + guiManager.showGUI(event.player, gui); + })); setItem(13, GuiUtils.createButtonItem(CompatibleMaterial.GOLD_INGOT, // Balance - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname")))); + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Displayname")), + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Lore") + .replace("%balance", String.valueOf(island.getBankBalance()))))); setButton(16, GuiUtils.createButtonItem(CompatibleMaterial.GREEN_DYE, // WithDraw - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); - guiManager.showGUI(event.player, returnGui); + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Withdraw.Displayname"))), (event) -> { + AnvilGui gui = new AnvilGui(event.player, this); + gui.setAction((e -> { + MessageManager messageManager = plugin.getMessageManager(); + + double amount; + try { + amount = Double.parseDouble(gui.getInputText().trim()); + } catch (NumberFormatException e1) { + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + return; + } + + BankManager.BankResponse response = bankManager.withdraw(e.player, island, amount, admin); + + switch(response){ + case NOT_ENOUGH_MONEY: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case DECIMALS_NOT_ALLOWED: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case NEGATIVE_AMOUNT: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case SUCCESS: + CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player); + messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank.Withdraw.Message")).replace( + "%amount%", NumberUtil.formatNumberByDecimal(amount))); + break; + } + + e.player.closeInventory(); + // paint(); + guiManager.showGUI(event.player, this); + })); + + ItemStack input = CompatibleMaterial.PAPER.getItem(); + ItemMeta im = input.getItemMeta(); + if(im != null){ + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount"))); + input.setItemMeta(im); + } + + gui.setInput(input); + gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Withdraw"))); + guiManager.showGUI(event.player, gui); }); } } diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java index a8c8d218..4c72cac6 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java @@ -12,8 +12,11 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.List; public class GuiBankTransaction extends Gui { @@ -24,14 +27,16 @@ public class GuiBankTransaction extends Gui { private final Gui returnGui; private final int transactions; private final List transactionList; + private final boolean admin; - public GuiBankTransaction(SkyBlock plugin, Island island, Gui returnGui) { + public GuiBankTransaction(SkyBlock plugin, Island island, Gui returnGui, boolean admin) { super(returnGui); this.plugin = plugin; this.bankManager = plugin.getBankManager(); this.transactionList = bankManager.getTransactions(island.getOwnerUUID()); this.transactions = this.transactionList.size(); this.returnGui = returnGui; + this.admin = admin; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); @@ -41,10 +46,10 @@ public class GuiBankTransaction extends Gui { } else if(transactions > 4*9){ setRows(6); } else { - setRows(transactions%9+1); + setRows((int) (Math.ceil((double) transactions / 9d)+1)); } - setTitle(TextUtils.formatText(languageLoad.getString("Menu.Settings.Title"))); // TODO Title + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Title"))); setDefaultItem(null); paint(); } @@ -55,53 +60,114 @@ public class GuiBankTransaction extends Gui { setActionForRange(0, 0, 1, 8, null); setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + guiManager.showGUI(event.player, returnGui); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); guiManager.showGUI(event.player, returnGui); }); setItem(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, // Info - TextUtils.formatText(languageLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname")))); + TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Info.Displayname")), + TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Info.Lore") + .replace("%totalTransactions", String.valueOf(transactions))))); - this.pages = (int) Math.max(1, Math.ceil((double) transactions / 36d)); + if(transactions > 0){ + this.pages = (int) Math.max(1, Math.ceil((double) transactions / 36d)); - if (page != 1) - setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Last.Displayname"))), - (event) -> { - page--; - paint(); - }); + if (page != 1) + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))), + (event) -> { + page--; + paint(); + }); - if (page != pages) - setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Next.Displayname"))), - (event) -> { - page++; - paint(); - }); + if (page != pages) + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); - for (int i = 9; i < 45; i++) { // TODO dynamic dimension! - int current = ((page - 1) * 36) - 9; - if (current + i >= transactions) { - setItem(i, null); - continue; + for (int i = 9; i < ((getRows()-1)*9)+9; i++) { // TODO check dynamic dimension! + int current = ((page - 1) * 36) - 9; + if (current + i >= transactions) { + setItem(i, null); + continue; + } + Transaction transaction = transactionList.get(current + i); + if (transaction == null) continue; + + ItemStack is = null; + ItemMeta im; + String name = ""; + SimpleDateFormat formatDate = new SimpleDateFormat(languageLoad.getString("Menu.Bank.Item.Transactions.DateTimeFormat", "dd/MM/yyyy HH:mm:ss")); + switch(transaction.action){ + case WITHDRAW: + is = CompatibleMaterial.RED_DYE.getItem(); + im = is.getItemMeta(); + if(im != null){ + + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.DisplayName") + .replace("%dateTime", formatDate.format(transaction.timestamp)))); + List lore = new ArrayList<>(); + switch (transaction.visibility){ + case ADMIN: + name = languageLoad.getString("Menu.Bank.Word.Admin"); + if(admin){ + name += " " + transaction.player.getName(); + } + break; + case USER: + name = transaction.player.getName(); + break; + } + lore.add(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.Format") + .replace("%playerName", name) + .replace("%amount", String.valueOf(transaction.amount)))); + im.setLore(lore); + is.setItemMeta(im); + } + break; + case DEPOSIT: + is = CompatibleMaterial.GREEN_DYE.getItem(); + im = is.getItemMeta(); + if(im != null){ + + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Deposit.DisplayName") + .replace("%dateTime", formatDate.format(transaction.timestamp)))); + List lore = new ArrayList<>(); + switch (transaction.visibility){ + case ADMIN: + name = languageLoad.getString("Menu.Bank.Word.Admin"); + if(admin){ + name += transaction.player.getName(); + } + break; + case USER: + name = transaction.player.getName(); + break; + } + lore.add(TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Deposit.Format") + .replace("%playerName", name) + .replace("%amount", String.valueOf(transaction.amount)))); + im.setLore(lore); + is.setItemMeta(im); + } + break; + } + + setItem(i, is); } - Transaction transaction = transactionList.get(current + i); - if (transaction == null) continue; - - ItemStack is = null; - switch(transaction.action){ - case WITHDRAW: - is = CompatibleMaterial.GREEN_DYE.getItem(); - break; - case DEPOSIT: - is = CompatibleMaterial.RED_DYE.getItem(); - break; - } - - // TODO set item meta - setItem(i, is); + } else { + setItem(31, CompatibleMaterial.BARRIER.getItem()); } + } } diff --git a/src/main/java/com/songoda/skyblock/menus/Bank.java b/src/main/java/com/songoda/skyblock/menus/Bank.java deleted file mode 100644 index fbf989e9..00000000 --- a/src/main/java/com/songoda/skyblock/menus/Bank.java +++ /dev/null @@ -1,326 +0,0 @@ -package com.songoda.skyblock.menus; - -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.gui.AnvilGui; -import com.songoda.core.hooks.EconomyManager; -import com.songoda.core.input.ChatPrompt; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.bank.BankManager; -import com.songoda.skyblock.bank.Transaction; -import com.songoda.skyblock.bank.Type; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.generator.GeneratorMaterial; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.AbstractAnvilGUI; -import com.songoda.skyblock.utils.NumberUtil; -import com.songoda.skyblock.utils.item.MenuClickRegistry; -import com.songoda.skyblock.utils.item.nInventoryUtil; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.io.File; -import java.io.IOException; -import java.util.Calendar; -import java.util.Objects; - -public class Bank { - - private static Bank instance; - - private BankManager bankManager; - - private IslandManager islandManager; - - public static Bank getInstance() { - return instance == null ? instance = new Bank() : instance; - } - - public Bank() { - SkyBlock skyblock = SkyBlock.getInstance(); - MessageManager messageManager = skyblock.getMessageManager(); - islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); - - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - bankManager = BankManager.getInstance(); - MenuClickRegistry.getInstance().register((executors) -> { - - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Exit.Displayname", CompatibleMaterial.OAK_FENCE_GATE), (inst, player, e) -> { - inst.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); - - e.setWillClose(true); - e.setWillDestroy(false); - }); - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Barrier.Displayname", CompatibleMaterial.BLACK_STAINED_GLASS_PANE), (inst, player, e) -> { - inst.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); - - e.setWillClose(false); - e.setWillDestroy(false); - }); - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Deposit.Displayname", CompatibleMaterial.DIRT), (inst, player, e) -> { - inst.getSoundManager().playSound(player, CompatibleSound.ENTITY_BAT_TAKEOFF.getSound(), 1.0F, 1.0F); - //Deposit money - Island island = islandManager.getIsland(player); - if (island != null) { - SelectInputMethod.getInstance().open(player, "Deposit", (action) -> { - if (action == InputMethodSelectlistener.InputMethod.CANCELED) { - Bukkit.getScheduler().runTask(skyblock, () -> - this.open(player)); - } else if (action == InputMethodSelectlistener.InputMethod.ALL) { - deposit(player, island, EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId()))); - } else { - AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { - if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { - if (!(player.hasPermission("fabledskyblock.island.bank") // TODO check correct permissions - Fabrimat - || player.hasPermission("fabledskyblock.*"))) { - messageManager.sendMessage(player, "No permission"); // TODO language.yml - Fabrimat - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), - 1.0F, 1.0F); - } else if (!event1.getName().replace(" ", "") - .matches("^[a-zA-Z0-9|.]+$")) { - messageManager.sendMessage(player, "Invalid characters"); // TODO language.yml - Fabrimat - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), - 1.0F, 1.0F); - } else if (!event1.getName().matches("-?\\d+(?:\\.\\d+)?")) { - messageManager.sendMessage(player, "Only numbers allowed"); // TODO language.yml - Fabrimat - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), - 1.0F, 1.0F); - } else { - double amount; - - try { - amount = Double.parseDouble(event1.getName()); - } catch (NumberFormatException e1) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - deposit(player, island, amount); - - player.closeInventory(); - - Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, () -> open(player), 1L); - } - - event1.setWillClose(true); - event1.setWillDestroy(true); - } else { - event1.setWillClose(false); - event1.setWillDestroy(false); - } - }); - - ItemStack is = CompatibleMaterial.NAME_TAG.getItem(); - ItemMeta im = is.getItemMeta(); - im.setDisplayName("Amount"); // TODO language.yml - Fabrimat - is.setItemMeta(im); - - gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is); - gui.open(); - // --- - /*ChatPrompt.showPrompt(skyblock, player, (event) -> { - if (event.getMessage().equals("")) - return; - - double amount; - try { - amount = Double.parseDouble(event.getMessage()); - } catch (NumberFormatException e1) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - deposit(player, island, amount); - });*/ - } - }); - } - e.setWillClose(true); - e.setCancelled(false); - }); - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Withdraw.Displayname", CompatibleMaterial.GLISTERING_MELON_SLICE), (inst, player, e) -> { - inst.getSoundManager().playSound(player, CompatibleSound.ENTITY_BAT_TAKEOFF.getSound(), 1.0F, 1.0F); - //Withdraw money - Island island; - island = islandManager.getIsland(player); - if (island != null) { - SelectInputMethod.getInstance().open(player, "Withdraw", (action) -> { - if (action == InputMethodSelectlistener.InputMethod.CANCELED) { - Bukkit.getScheduler().runTask(skyblock, () -> { - this.open(player); - }); - } else if (action == InputMethodSelectlistener.InputMethod.ALL) { - withdraw(player, island, island.getBankBalance()); - } else { - ChatPrompt.showPrompt(skyblock, player, (event) -> { - if (event.getMessage().equals("")) - return; - double amount = 0; - try { - amount = Double.parseDouble(event.getMessage()); - } catch (NumberFormatException e1) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } - withdraw(player, island, amount); - }); - } - }); - } - e.setWillClose(true); - e.setCancelled(false); - }); - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Log.Displayname", CompatibleMaterial.BOOK), (inst, player, e) -> { - inst.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); - e.setWillClose(false); - e.setWillDestroy(false); - }); - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Balance.Displayname", CompatibleMaterial.STICK), (inst, player, e) -> { - e.setWillClose(false); - e.setWillDestroy(false); - }); - }); - } - - public void open(Player player) { - Island island; - island = islandManager.getIsland(player); - - - SkyBlock skyblock = SkyBlock.getInstance(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - nInventoryUtil nInv = new nInventoryUtil(player, event -> MenuClickRegistry.getInstance().dispatch(player, event)); - - if (island == null) { - skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); - skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Bank.Unknown")); - return; - } - - // Glass panes barriers - nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.Bank.Item.Barrier.Displayname"), null, null, null, null), 0, 2, 5, 8, - 1, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 17); - - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Bank.Item.Exit.Displayname"), - configLoad.getStringList("Menu.Bank.Item.Exit.Lore"), null, null, null), 0, 8); - - nInv.addItem(nInv.createItem(CompatibleMaterial.BOOK.getItem(), configLoad.getString("Menu.Bank.Item.Log.Displayname"), - bankManager.getTransactions(player), null, null, null), 4); - - nInv.addItem(nInv.createItem(CompatibleMaterial.DIRT.getItem(), configLoad.getString("Menu.Bank.Item.Deposit.Displayname"), - configLoad.getStringList("Menu.Bank.Item.Deposit.Lore"), null, null, null), 10); - - nInv.addItem(nInv.createItem(CompatibleMaterial.GLISTERING_MELON_SLICE.getItem(), configLoad.getString("Menu.Bank.Item.Withdraw.Displayname"), - configLoad.getStringList("Menu.Bank.Item.Withdraw.Lore"), null, null, null), 16); - - nInv.addItem(nInv.createItem(CompatibleMaterial.STICK.getItem(), configLoad.getString("Menu.Bank.Item.Balance.Displayname"), - BankManager.getInstance().getBalanceLore(player), null, null, null), 13); - - - nInv.setTitle(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(configLoad.getString("Menu.Bank.Title")))); - nInv.setRows(2); - - Bukkit.getServer().getScheduler().runTask(skyblock, nInv::open); - } - - private void deposit(Player player, Island island, double amt) { - SkyBlock skyblock = SkyBlock.getInstance(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); - - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - // Make sure the amount is positive - if (amt <= 0) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short5.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - - // If decimals aren't allowed, check for them - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { - int intAmt = (int) amt; - if (intAmt != amt) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short6.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - } - - if (!EconomyManager.hasBalance(player, amt)) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - - EconomyManager.withdrawBalance(player, amt); - island.addToBank(amt); - Transaction t = new Transaction(); - t.player = player; - t.ammount = (float) amt; - t.timestamp = Calendar.getInstance().getTime(); - t.action = Type.DEPOSIT; - bankManager.addTransaction(player, t); - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Deposit.Message").replace( - "%amount%", NumberUtil.formatNumberByDecimal(amt))); - } - - private void withdraw(Player player, Island island, double amt) { - SkyBlock skyblock = SkyBlock.getInstance(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); - - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - // Make sure the amount is positive - if (amt <= 0) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short5.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - - // If decimals aren't allowed, check for them - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { - int intAmt = (int) amt; - if (intAmt != amt) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short6.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; - } - } - - if (amt > island.getBankBalance()) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short2.Message")); - return; - } - - EconomyManager.deposit(player, amt); - island.removeFromBank(amt); - Transaction t = new Transaction(); - t.player = player; - t.ammount = (float) amt; - t.timestamp = Calendar.getInstance().getTime(); - t.action = Type.WITHDRAW; - bankManager.addTransaction(player, t); - messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Bank.Withdraw.Message")).replace( - "%amount%", NumberUtil.formatNumberByDecimal(amt))); - } -} diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index ed2d2a3c..43868005 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -3,7 +3,6 @@ package com.songoda.skyblock.playerdata; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.bank.Transaction; -import com.songoda.skyblock.bank.Type; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.confirmation.Confirmation; import com.songoda.skyblock.menus.MenuType; @@ -59,12 +58,18 @@ public class PlayerData { FileConfiguration configLoad = getConfig().getFileConfiguration(); for (int i = 0;i< configLoad.getInt("Bank.Transactions.Size");i++) { Transaction t = new Transaction(); - t.action = Type.valueOf(configLoad.getString("Bank.Transactions."+i+".Action")); - t.ammount = Float.parseFloat(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Amount"))); + t.action = Transaction.Type.valueOf(configLoad.getString("Bank.Transactions."+i+".Action")); + t.amount = Float.parseFloat(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Amount"))); t.player = Bukkit.getOfflinePlayer(UUID.fromString(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Player")))); Date d = new Date(); d.setTime(configLoad.getLong("Bank.Transactions."+i+".Date")); t.timestamp = d; + String visibility = configLoad.getString("Bank.Transactions."+i+".Visibility"); + if(visibility != null){ + t.visibility = Transaction.Visibility.valueOf(visibility); + } else { + t.visibility = Transaction.Visibility.USER; // Defaulting this as it's a new field + } transactions.add(t); } } @@ -264,9 +269,10 @@ public class PlayerData { for (int i = 0; i < transactions.size(); i++) { Transaction t = transactions.get(i); configLoad.set("Bank.Transactions." + i + ".Action", t.action.name()); - configLoad.set("Bank.Transactions." + i + ".Amount", t.ammount); + configLoad.set("Bank.Transactions." + i + ".Amount", t.amount); configLoad.set("Bank.Transactions." + i + ".Player", t.player.getUniqueId().toString()); configLoad.set("Bank.Transactions." + i + ".Date", t.timestamp.getTime()); + configLoad.set("Bank.Transactions." + i + ".Visibility", t.visibility.name()); } }else { configLoad.set("Bank.Transactions.Size", 0); diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 8e09ddd5..817db373 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -3198,21 +3198,43 @@ Menu: Title: 'Bank' Item: Exit: - Displayname: 'Exit' - Lore: 'Exits the Menu' + Displayname: '&cExit' + Lore: '&7Exits the Menu' Barrier: Displayname: '&cBank' Log: - Displayname: 'Transaction Log' - Empty: 'Looks like you haven''t got transactions' + Displayname: '&fTransaction Log' + Empty: '&7Looks like you haven''t got transactions' Deposit: - Displayname: 'Deposit' - Lore: 'Click to deposit your money. Everything or a custom ammount.' + Displayname: '&fDeposit' + Lore: '&7Click to deposit your money. Everything or a custom amount.' Withdraw: - Displayname: 'Withdraw' - Lore: 'Click to withdraw your money. Everything or a custom ammount.' + Displayname: '&fWithdraw' + Lore: '&7Click to withdraw your money. Everything or a custom amount.' Balance: - Displayname: 'Balance' + Displayname: '&fBalance' + Lore: '&7Bank balance: &6$%balance' + Next: + Displayname: '&aNext Page' + Last: + Displayname: '&aPrevious Page' + Transactions: + Info: + Displayname: '&fInfo' + Lore: '&7Total transactions: %totalTransactions' + Title: 'Transactions' + Withdraw: + DisplayName: '&c%dateTime' + Format: '&7 %playerName withdrawn %amount' + Deposit: + DisplayName: '&a%dateTime' + Format: '&7 %playerName deposited %amount' + Admin: '&cAdmin&7' + DateTimeFormat: 'dd/MM/yyyy HH:mm:ss' + Words: + Withdraw: 'Withdraw' + Deposit: 'Deposit' + Amount: 'Amount' Input: Title: 'Select amount.' Item: From 246ab7dd0c326141cd83f40512967493ee296ab5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 23:42:27 +0200 Subject: [PATCH 052/366] Max Members upgrade --- pom.xml | 2 +- .../skyblock/command/CommandManager.java | 3 +- .../command/commands/admin/SetMaxMembers.java | 147 ++++++++++++++++++ .../com/songoda/skyblock/island/Island.java | 2 +- .../songoda/skyblock/menus/Information.java | 2 +- .../songoda/skyblock/menus/admin/Upgrade.java | 2 +- .../skyblock/upgrade/UpgradeManager.java | 2 +- src/main/resources/config.yml | 2 +- src/main/resources/language.yml | 4 +- 9 files changed, 157 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java diff --git a/pom.xml b/pom.xml index b90c4dd9..a53bd0c3 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.3-DEV + 2.3.3-DEV2 jar clean install diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index 7b8c53ef..5b844db1 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -114,7 +114,8 @@ public class CommandManager implements CommandExecutor, TabCompleter { new StructureCommand(), new com.songoda.skyblock.command.commands.admin.UpgradeCommand(), new StackableCommand(), - new AdminBank() + new AdminBank(), + new SetMaxMembers() ); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java new file mode 100644 index 00000000..238e7ed5 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java @@ -0,0 +1,147 @@ +package com.songoda.skyblock.command.commands.admin; + +import com.songoda.core.compatibility.CompatibleSound; +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.message.MessageManager; +import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.skyblock.utils.player.OfflinePlayer; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; +import java.io.IOException; +import java.util.UUID; + +public class SetMaxMembers extends SubCommand { + + @Override + public void onCommandByPlayer(Player player, String[] args) { + onCommand(player, args); + } + + @Override + public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { + onCommand(sender, args); + } + + public void onCommand(CommandSender sender, String[] args) { + PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + MessageManager messageManager = skyblock.getMessageManager(); + IslandManager islandManager = skyblock.getIslandManager(); + SoundManager soundManager = skyblock.getSoundManager(); + FileManager fileManager = skyblock.getFileManager(); + + Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (args.length == 2) { + if (args[1].matches("[0-9]+")) { + Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); + UUID islandOwnerUUID; + String targetPlayerName; + + if (targetPlayer == null) { + OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]); + islandOwnerUUID = targetPlayerOffline.getOwner(); + targetPlayerName = targetPlayerOffline.getName(); + } else { + islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner(); + targetPlayerName = targetPlayer.getName(); + } + + int maxMembers = Integer.valueOf(args[1]); + + if (islandOwnerUUID == null) { + messageManager.sendMessage(sender, + configLoad.getString("Command.Island.Admin.SetMaxMembers.Island.Owner.Message")); + soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + } else if (maxMembers <= 0) { + messageManager.sendMessage(sender, + configLoad.getString("Command.Island.Admin.SetMaxMembers.Members.Greater.Message")); + soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + } else if (maxMembers > 100000) { + messageManager.sendMessage(sender, + configLoad.getString("Command.Island.Admin.SetMaxMembers.Members.Less.Message")); + soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + } else { + if (islandManager.containsIsland(islandOwnerUUID)) { + Island island = islandManager + .getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); + island.setMaxMembers(maxMembers); + + if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.WorldBorder.Enable") + && island.isBorder()) { + islandManager.updateBorder(island); + } + } else { + File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data", + islandOwnerUUID.toString() + ".yml"); + + if (!fileManager.isFileExist(islandDataFile)) { + messageManager.sendMessage(sender, + configLoad.getString("Command.Island.Admin.SetMaxMembers.Island.Data.Message")); + soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + + return; + } + + FileConfiguration islandDataConfigLoad = YamlConfiguration + .loadConfiguration(islandDataFile); + islandDataConfigLoad.set("MaxMembers", maxMembers); + + try { + islandDataConfigLoad.save(islandDataFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + + messageManager.sendMessage(sender, + configLoad.getString("Command.Island.Admin.SetMaxMembers.Set.Message") + .replace("%player", targetPlayerName) + .replace("%maxMembers", NumberUtil.formatNumberByDecimal(maxMembers))); + soundManager.playSound(sender, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); + } + } else { + messageManager.sendMessage(sender, + configLoad.getString("Command.Island.Admin.SetMaxMembers.Numerical.Message")); + soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } + } else { + messageManager.sendMessage(sender, + configLoad.getString("Command.Island.Admin.SetMaxMembers.Invalid.Message")); + soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } + } + + @Override + public String getName() { + return "setmaxmembers"; + } + + @Override + public String getInfoMessagePath() { + return "Command.Island.Admin.SetMaxMembers.Info.Message"; + } + + @Override + public String[] getAliases() { + return new String[0]; + } + + @Override + public String[] getArguments() { + return new String[0]; + } +} diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 5e3b9895..2340d574 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -60,7 +60,7 @@ public class Island { this.size = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() .getInt("Island.Size.Minimum"); this.maxMembers = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() - .getInt("Island.InitialMaxMembers", 3); + .getInt("Island.Member.Capacity", 3); if (this.size > 1000) { this.size = 50; diff --git a/src/main/java/com/songoda/skyblock/menus/Information.java b/src/main/java/com/songoda/skyblock/menus/Information.java index e100aaa6..102ec961 100644 --- a/src/main/java/com/songoda/skyblock/menus/Information.java +++ b/src/main/java/com/songoda/skyblock/menus/Information.java @@ -346,7 +346,7 @@ public class Information { new Placeholder[]{ new Placeholder("%island_members", "" + (islandMembers.size() + islandOperators.size() + 1)), - new Placeholder("%island_maxMembers", // %island_capacity + new Placeholder("%island_capacity", // %island_capacity "" + island.getMaxMembers()), new Placeholder("%members", "" + islandMembers.size()), new Placeholder("%operators", "" + islandOperators.size())}, diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java index d0602168..8e45690e 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java @@ -1219,7 +1219,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Members.Item.Tier.Displayname") .replace("%tier", "" + tier)), configLoad.getStringList("Menu.Admin.Upgrade.Members.Item.Tier.Lore"), - new Placeholder[]{new Placeholder("%members", "" + upgrade.getValue()), + new Placeholder[]{new Placeholder("%maxMembers", "" + upgrade.getValue()), new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, null, null), i + 3); diff --git a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java index 88580882..9a0f5814 100644 --- a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java +++ b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java @@ -26,7 +26,7 @@ public class UpgradeManager { FileConfiguration configLoad = config.getFileConfiguration(); for (Upgrade.Type typeList : Upgrade.Type.values()) { - if (typeList != Upgrade.Type.Size) { + if (typeList != Upgrade.Type.Size && typeList != Upgrade.Type.Members) { List upgrades = new ArrayList<>(); Upgrade upgrade = new Upgrade(configLoad.getDouble("Upgrades." + typeList.name() + ".Cost")); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9deeb552..60818c68 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -9,7 +9,6 @@ Sound: # When disabled all sounds will be disabled. Enable: true Island: - InitialMaxMembers: 3 Size: # [!] Do not go over 1000 for both of these options. # The size of an Island when created. @@ -91,6 +90,7 @@ Island: Height: 60 Member: # Max amount of players allowed to be in a team. + # Can be increased with Upgrades Capacity: 12 Chat: # If island chat should be output to console diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index facd7e89..055f79ea 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1756,7 +1756,7 @@ Menu: - '' - '&eClick to manage tiers!' Members: - Displayname: '&aBorder Size' + Displayname: '&aMax Members' Lore: - '&7Increases the max amount' - '&7of Island members.' @@ -1864,7 +1864,7 @@ Menu: - '&7Max members&8: &f%maxMembers' - '&7Cost&8: &f$%cost' - '' - - '&eLeft-Click to set size!' + - '&eLeft-Click to set value!' - '&eMiddle-Click to remove!' - '&eRight-Click to set cost!' Displayname: '&bTier #%tier' From 03b5c5194e32d9af30b1c5ba2fc46dc57d524021 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 01:11:26 +0200 Subject: [PATCH 053/366] Starting rewriting menus --- .../com/songoda/skyblock/gui/GuiBans.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/gui/GuiBans.java diff --git a/src/main/java/com/songoda/skyblock/gui/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/GuiBans.java new file mode 100644 index 00000000..fb0798fb --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/GuiBans.java @@ -0,0 +1,54 @@ +package com.songoda.skyblock.gui; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.ban.BanManager; +import com.songoda.skyblock.island.Island; +import org.bukkit.configuration.file.FileConfiguration; + +import java.io.File; + +public class GuiBans extends Gui { + private final SkyBlock plugin; + private final BanManager banManager; + private final Island island; + private final FileConfiguration languageLoad; + private final boolean admin; + + public GuiBans(SkyBlock plugin, Island island, Gui returnGui, boolean admin) { + super(returnGui); + this.plugin = plugin;; + this.banManager = plugin.getBanManager(); + this.island = island; + this.admin = admin; + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setTitle(TextUtils.formatText("Bans")); + paint(); + } + + public void paint() { + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + for(int i=9; i<18; i++){ + setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + } + + + } +} From a24b246945cd53ae63dd9f47086876562ae86371 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 01:13:22 +0200 Subject: [PATCH 054/366] Optimize and fix errors in bank gui --- .../com/songoda/skyblock/gui/bank/GuiBank.java | 15 ++++----------- .../skyblock/gui/bank/GuiBankTransaction.java | 4 ++-- src/main/resources/language.yml | 4 ++-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java index 78eba8bd..c8bb0602 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java @@ -27,6 +27,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import javax.annotation.Nonnull; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -36,31 +37,25 @@ import java.util.stream.Collectors; public class GuiBank extends Gui { private final SkyBlock plugin; private final BankManager bankManager; - private final PermissionManager permissionManager; private final Island island; private final FileConfiguration languageLoad; - private final FileConfiguration config; - private final Gui returnGui; private final boolean admin; public GuiBank(SkyBlock plugin, Island island, Gui returnGui, boolean admin) { super(2, returnGui); this.plugin = plugin;; this.bankManager = plugin.getBankManager(); - this.permissionManager = plugin.getPermissionManager(); this.island = island; - this.returnGui = returnGui; this.admin = admin; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); - this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); - setTitle(TextUtils.formatText("Bank")); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Title"))); paint(); } @Override - public void onOpen(GuiManager manager, Player player) { + public void onOpen(@Nonnull GuiManager manager, @Nonnull Player player) { updateItem(13, // Balance TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Displayname")), TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Lore") @@ -87,9 +82,7 @@ public class GuiBank extends Gui { }); setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK, // Transaction log - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> { - guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin)); - }); + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin))); setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.RED_DYE, // Deposit TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Deposit.Displayname"))), (event -> { diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java index 4c72cac6..d0f22614 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java @@ -114,7 +114,7 @@ public class GuiBankTransaction extends Gui { im = is.getItemMeta(); if(im != null){ - im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.DisplayName") + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.Displayname") .replace("%dateTime", formatDate.format(transaction.timestamp)))); List lore = new ArrayList<>(); switch (transaction.visibility){ @@ -140,7 +140,7 @@ public class GuiBankTransaction extends Gui { im = is.getItemMeta(); if(im != null){ - im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Deposit.DisplayName") + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Deposit.Displayname") .replace("%dateTime", formatDate.format(transaction.timestamp)))); List lore = new ArrayList<>(); switch (transaction.visibility){ diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 055f79ea..8cd9fbac 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -3316,10 +3316,10 @@ Menu: Lore: '&7Total transactions: %totalTransactions' Title: 'Transactions' Withdraw: - DisplayName: '&c%dateTime' + Displayname: '&c%dateTime' Format: '&7 %playerName withdrawn %amount' Deposit: - DisplayName: '&a%dateTime' + Displayname: '&a%dateTime' Format: '&7 %playerName deposited %amount' Admin: '&cAdmin&7' DateTimeFormat: 'dd/MM/yyyy HH:mm:ss' From b293238064f70c043b9611859baaf0d1bf543f58 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 01:13:27 +0200 Subject: [PATCH 055/366] Added a comment --- src/main/java/com/songoda/skyblock/menus/MenuType.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/songoda/skyblock/menus/MenuType.java b/src/main/java/com/songoda/skyblock/menus/MenuType.java index 730e7b1c..ad436e27 100644 --- a/src/main/java/com/songoda/skyblock/menus/MenuType.java +++ b/src/main/java/com/songoda/skyblock/menus/MenuType.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.menus; +// Needed for pages public enum MenuType { ADMIN_LEVELLING, ADMIN_CREATOR, From a09720befe8c57a46caf0a019366ccb7261b44bc Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 01:39:56 +0200 Subject: [PATCH 056/366] Finished GuiBans --- .../com/songoda/skyblock/gui/GuiBans.java | 71 +++++++++++++++++-- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/GuiBans.java index fb0798fb..3b12a0e0 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/GuiBans.java @@ -8,23 +8,35 @@ import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.ban.BanManager; import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.utils.item.SkullUtil; +import com.songoda.skyblock.utils.player.OfflinePlayer; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; public class GuiBans extends Gui { private final SkyBlock plugin; private final BanManager banManager; + private final PlayerDataManager playerDataManager; private final Island island; private final FileConfiguration languageLoad; - private final boolean admin; - public GuiBans(SkyBlock plugin, Island island, Gui returnGui, boolean admin) { + public GuiBans(SkyBlock plugin, Island island, Gui returnGui) { super(returnGui); - this.plugin = plugin;; + this.plugin = plugin; + this.playerDataManager = plugin.getPlayerDataManager(); + ; this.banManager = plugin.getBanManager(); this.island = island; - this.admin = admin; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); @@ -34,13 +46,13 @@ public class GuiBans extends Gui { public void paint() { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); event.player.closeInventory(); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); event.player.closeInventory(); }); @@ -49,6 +61,53 @@ public class GuiBans extends Gui { setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); } + List bans = new ArrayList<>(island.getBan().getBans()); + if(bans.size() == 0){ + setItem(31, CompatibleMaterial.BARRIER.getItem()); + } else { + for (int i = 9; i < ((getRows()-2)*9)+18; i++) { // TODO check dynamic dimension! + int current = ((page - 1) * 36) - 18; + if (current + i >= bans.size()) { + setItem(i, null); + continue; + } + UUID uuid = bans.get(current + i); + if (uuid == null) continue; + + String targetPlayerName; + String[] targetPlayerTexture; + + Player targetPlayer = Bukkit.getServer().getPlayer(uuid); + + if (targetPlayer == null) { + OfflinePlayer offlinePlayer = new OfflinePlayer(uuid); + targetPlayerName = offlinePlayer.getName(); + targetPlayerTexture = offlinePlayer.getTexture(); + } else { + targetPlayerName = targetPlayer.getName(); + + if (playerDataManager.hasPlayerData(targetPlayer)) { + targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture(); + } else { + targetPlayerTexture = new String[]{null, null}; + } + } + + ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]); + ItemMeta im = is.getItemMeta(); + if(im != null){ + im.setDisplayName(languageLoad.getString("Menu.Bans.Item.Ban.Displayname") + .replace("%player", targetPlayerName == null ? "" : targetPlayerName)); + im.setLore(languageLoad.getStringList("Menu.Bans.Item.Ban.Lore")); + is.setItemMeta(im); + } + + setButton(i, is, e -> { + String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); // TODO Check if it actually works + Bukkit.getServer().dispatchCommand(e.player, "island unban " + playerName); + }); + } + } } } From 33f7b6842f9cd7e5053e42183997c20c5783cc06 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 01:41:21 +0200 Subject: [PATCH 057/366] Moved GuiBans to wip package --- src/main/java/com/songoda/skyblock/gui/{ => wip}/GuiBans.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/songoda/skyblock/gui/{ => wip}/GuiBans.java (99%) diff --git a/src/main/java/com/songoda/skyblock/gui/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java similarity index 99% rename from src/main/java/com/songoda/skyblock/gui/GuiBans.java rename to src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index 3b12a0e0..bb4a3652 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.gui; +package com.songoda.skyblock.gui.wip; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; From 445aaef37c2d5391a50feb44c48a8c37401a631a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 01:48:35 +0200 Subject: [PATCH 058/366] Fixed messages addresses --- .../skyblock/gui/bank/GuiBankTransaction.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java index d0f22614..e0a5f463 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java @@ -114,12 +114,12 @@ public class GuiBankTransaction extends Gui { im = is.getItemMeta(); if(im != null){ - im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.Displayname") + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Withdraw.Displayname") .replace("%dateTime", formatDate.format(transaction.timestamp)))); List lore = new ArrayList<>(); switch (transaction.visibility){ case ADMIN: - name = languageLoad.getString("Menu.Bank.Word.Admin"); + name = languageLoad.getString("Menu.Bank.Transactions.Admin"); if(admin){ name += " " + transaction.player.getName(); } @@ -128,7 +128,10 @@ public class GuiBankTransaction extends Gui { name = transaction.player.getName(); break; } - lore.add(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.Format") + if(name == null){ + name = "null"; + } + lore.add(TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Withdraw.Format") .replace("%playerName", name) .replace("%amount", String.valueOf(transaction.amount)))); im.setLore(lore); @@ -140,8 +143,9 @@ public class GuiBankTransaction extends Gui { im = is.getItemMeta(); if(im != null){ - im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Deposit.Displayname") - .replace("%dateTime", formatDate.format(transaction.timestamp)))); + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Deposit.Displayname") + .replace("%dateTime", + formatDate.format(transaction.timestamp)))); List lore = new ArrayList<>(); switch (transaction.visibility){ case ADMIN: From debd41caf48c232f567a93c4da1c0d92a6b346a5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 03:22:11 +0200 Subject: [PATCH 059/366] Readded bank selector GUI --- .../songoda/skyblock/gui/bank/GuiBank.java | 114 +--------- .../skyblock/gui/bank/GuiBankSelector.java | 199 ++++++++++++++++++ src/main/resources/language.yml | 11 +- 3 files changed, 211 insertions(+), 113 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java index c8bb0602..56ce9111 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java @@ -82,118 +82,20 @@ public class GuiBank extends Gui { }); setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK, // Transaction log - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin))); + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> + guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin))); - setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.RED_DYE, // Deposit - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Deposit.Displayname"))), (event -> { - AnvilGui gui = new AnvilGui(event.player, this); - gui.setAction((e -> { - MessageManager messageManager = plugin.getMessageManager(); - - double amount; - try { - amount = Double.parseDouble(gui.getInputText().trim()); - } catch (NumberFormatException e1) { - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - return; - } - BankManager.BankResponse response = bankManager.deposit(e.player, island, amount, admin); - - switch(response){ - case NOT_ENOUGH_MONEY: - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - break; - case DECIMALS_NOT_ALLOWED: - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - break; - case NEGATIVE_AMOUNT: - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - break; - case SUCCESS: - CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player); - messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank.Deposit.Message")).replace( - "%amount%", NumberUtil.formatNumberByDecimal(amount))); - break; - } - - e.player.closeInventory(); - // paint(); - guiManager.showGUI(event.player, this); - })); - - ItemStack input = CompatibleMaterial.PAPER.getItem(); - ItemMeta im = input.getItemMeta(); - if(im != null){ - im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount"))); - input.setItemMeta(im); - } - - gui.setInput(input); - gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Deposit"))); - guiManager.showGUI(event.player, gui); - })); + setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.GREEN_DYE, // Deposit + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Deposit.Displayname"))), (event) -> + guiManager.showGUI(event.player, new GuiBankSelector(plugin, island, this, GuiBankSelector.Type.DEPOSIT, admin))); setItem(13, GuiUtils.createButtonItem(CompatibleMaterial.GOLD_INGOT, // Balance TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Displayname")), TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Lore") .replace("%balance", String.valueOf(island.getBankBalance()))))); - setButton(16, GuiUtils.createButtonItem(CompatibleMaterial.GREEN_DYE, // WithDraw - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Withdraw.Displayname"))), (event) -> { - AnvilGui gui = new AnvilGui(event.player, this); - gui.setAction((e -> { - MessageManager messageManager = plugin.getMessageManager(); - - double amount; - try { - amount = Double.parseDouble(gui.getInputText().trim()); - } catch (NumberFormatException e1) { - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - return; - } - - BankManager.BankResponse response = bankManager.withdraw(e.player, island, amount, admin); - - switch(response){ - case NOT_ENOUGH_MONEY: - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - break; - case DECIMALS_NOT_ALLOWED: - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - break; - case NEGATIVE_AMOUNT: - messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); - break; - case SUCCESS: - CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player); - messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank.Withdraw.Message")).replace( - "%amount%", NumberUtil.formatNumberByDecimal(amount))); - break; - } - - e.player.closeInventory(); - // paint(); - guiManager.showGUI(event.player, this); - })); - - ItemStack input = CompatibleMaterial.PAPER.getItem(); - ItemMeta im = input.getItemMeta(); - if(im != null){ - im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount"))); - input.setItemMeta(im); - } - - gui.setInput(input); - gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Withdraw"))); - guiManager.showGUI(event.player, gui); - }); + setButton(16, GuiUtils.createButtonItem(CompatibleMaterial.RED_DYE, // Withdraw + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Withdraw.Displayname"))), (event) -> + guiManager.showGUI(event.player, new GuiBankSelector(plugin, island, this, GuiBankSelector.Type.WITHDRAW, admin))); } } diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java new file mode 100644 index 00000000..a92e18d3 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -0,0 +1,199 @@ +package com.songoda.skyblock.gui.bank; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.AnvilGui; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.bank.BankManager; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.utils.NumberUtil; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.io.File; +import java.util.Objects; + +public class GuiBankSelector extends Gui { + private final SkyBlock plugin; + private final BankManager bankManager; + private final Island island; + private final FileConfiguration languageLoad; + private final Type type; + private final Gui returnGui; + private final boolean admin; + + public enum Type { + DEPOSIT, + WITHDRAW + } + + public GuiBankSelector(SkyBlock plugin, Island island, Gui returnGui, Type type, boolean admin) { + super(1, returnGui); + this.plugin = plugin; + this.type = type; + this.bankManager = plugin.getBankManager(); + this.island = island; + this.returnGui = returnGui; + this.admin = admin; + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Input.Title"))); + paint(); + } + + public void paint() { + if (inventory != null) + inventory.clear(); + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setActionForRange(0, 0, 1, 8, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Input.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Input.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + String action = ""; + switch(type){ + case DEPOSIT: + action = "Deposit"; + break; + case WITHDRAW: + action = "Withdraw"; + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + final String finalAction = action; + + setButton(2, GuiUtils.createButtonItem(CompatibleMaterial.GOLD_BLOCK, // All + TextUtils.formatText(languageLoad.getString("Menu.Input.Item.All.Displayname")), + TextUtils.formatText(languageLoad.getString("Menu.Input.Item.All.Lore") + .replace("%action%", languageLoad.getString("Menu.Bank.Words." + action)))), (event -> { + MessageManager messageManager = plugin.getMessageManager(); + BankManager.BankResponse response; + double amount; + + switch(type){ + case DEPOSIT: + amount = EconomyManager.getBalance(event.player); + response = bankManager.deposit(event.player, island, amount, admin); + break; + case WITHDRAW: + amount = island.getBankBalance(); + response = bankManager.withdraw(event.player, island, amount, admin); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + + switch(response){ + case NOT_ENOUGH_MONEY: + messageManager.sendMessage(event.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(event.player); + break; + case DECIMALS_NOT_ALLOWED: + messageManager.sendMessage(event.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(event.player); + break; + case NEGATIVE_AMOUNT: + messageManager.sendMessage(event.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(event.player); + break; + case SUCCESS: + CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(event.player); + messageManager.sendMessage(event.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank." + finalAction + ".Message")).replace( + "%amount%", NumberUtil.formatNumberByDecimal(amount))); + + break; + } + guiManager.showGUI(event.player, returnGui); + })); + + setButton(6, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, // Custom + TextUtils.formatText(languageLoad.getString("Menu.Input.Item.Custom.Displayname")), + TextUtils.formatText(languageLoad.getString("Menu.Input.Item.Custom.Lore") + .replace("%action%", languageLoad.getString("Menu.Bank.Words." + action)))), (event) -> { + AnvilGui gui = new AnvilGui(event.player, returnGui); + gui.setAction((e -> { + MessageManager messageManager = plugin.getMessageManager(); + + double amount; + try { + amount = Double.parseDouble(gui.getInputText().trim()); + } catch (NumberFormatException e1) { + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + return; + } + + BankManager.BankResponse response; + + switch(type){ + case DEPOSIT: + response = bankManager.deposit(event.player, island, amount, admin); + break; + case WITHDRAW: + response = bankManager.withdraw(event.player, island, amount, admin); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + + switch(response){ + case NOT_ENOUGH_MONEY: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case DECIMALS_NOT_ALLOWED: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case NEGATIVE_AMOUNT: + messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); + CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + break; + case SUCCESS: + CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player); + messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank." + finalAction + ".Message")).replace( + "%amount%", NumberUtil.formatNumberByDecimal(amount))); + break; + } + + e.player.closeInventory(); + guiManager.showGUI(event.player, returnGui); + })); + + ItemStack input = CompatibleMaterial.PAPER.getItem(); + ItemMeta im = input.getItemMeta(); + if(im != null){ + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount"))); + input.setItemMeta(im); + } + + gui.setInput(input); + switch(type){ + case DEPOSIT: + gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Deposit"))); + break; + case WITHDRAW: + gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Withdraw"))); + break; + } + guiManager.showGUI(event.player, gui); + }); + } +} diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 8cd9fbac..fee7823e 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -3331,17 +3331,14 @@ Menu: Title: 'Select amount.' Item: All: - Displayname: 'All' + Displayname: '&fAll' Lore: '%action% all available.' Custom: - Displayname: 'Custom' + Displayname: '&fCustom' Lore: '%action% a custom amount.' - Barrier: - Displayname: ' ' - Lore: ' ' Exit: - Displayname: 'Exit' - Lore: "Closes the menu." + Displayname: '&cExit' + Lore: '&7Exits the Menu' Placeholder: fabledskyblock_leaderboard_votes: Empty: From edc101ee779ac29d7a80a7b0f5bb8a4ee2bd07c2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 03:28:05 +0200 Subject: [PATCH 060/366] Removed unused classes --- .../java/com/songoda/skyblock/SkyBlock.java | 4 +- .../island/disabled/RollbackCommand.java | 67 ------ .../com/songoda/skyblock/menus/Rollback.java | 206 ------------------ .../skyblock/menus/SelectInputMethod.java | 96 -------- 4 files changed, 1 insertion(+), 372 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/command/commands/island/disabled/RollbackCommand.java delete mode 100644 src/main/java/com/songoda/skyblock/menus/Rollback.java delete mode 100644 src/main/java/com/songoda/skyblock/menus/SelectInputMethod.java diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index a0bd5649..5f86e20b 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -27,7 +27,6 @@ import com.songoda.skyblock.levelling.rework.IslandLevelManager; import com.songoda.skyblock.limit.LimitationInstanceHandler; import com.songoda.skyblock.listeners.*; import com.songoda.skyblock.localization.LocalizationManager; -import com.songoda.skyblock.menus.Rollback; import com.songoda.skyblock.menus.admin.Creator; import com.songoda.skyblock.menus.admin.Generator; import com.songoda.skyblock.menus.admin.Levelling; @@ -190,8 +189,7 @@ public class SkyBlock extends SongodaPlugin { if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this); if (pluginManager.isPluginEnabled("UltimateStacker")) pluginManager.registerEvents(new UltimateStacker(this), this); - - pluginManager.registerEvents(new Rollback(), this); + pluginManager.registerEvents(new Levelling(), this); pluginManager.registerEvents(new Generator(), this); pluginManager.registerEvents(new Creator(), this); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/disabled/RollbackCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/disabled/RollbackCommand.java deleted file mode 100644 index 4252cb46..00000000 --- a/src/main/java/com/songoda/skyblock/command/commands/island/disabled/RollbackCommand.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.songoda.skyblock.command.commands.island.disabled; - -import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.skyblock.command.SubCommand; -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.menus.Rollback; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.sound.SoundManager; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - -import java.io.File; - -public class RollbackCommand extends SubCommand { - - @Override - public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - Island island = islandManager.getIsland(player); - - if (island == null) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Rollback.Owner.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { - Rollback.getInstance().open(player); - soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); - } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Rollback.Role.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } - } - - @Override - public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { - sender.sendMessage("SkyBlock | Error: You must be a player to perform that command."); - } - - @Override - public String getName() { - return "rollback"; - } - - @Override - public String getInfoMessagePath() { - return "Command.Island.Rollback.Info.Message"; - } - - @Override - public String[] getAliases() { - return new String[0]; - } - - @Override - public String[] getArguments() { - return new String[0]; - } -} diff --git a/src/main/java/com/songoda/skyblock/menus/Rollback.java b/src/main/java/com/songoda/skyblock/menus/Rollback.java deleted file mode 100644 index d6cafeb9..00000000 --- a/src/main/java/com/songoda/skyblock/menus/Rollback.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.songoda.skyblock.menus; - -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.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.sound.SoundManager; - -import com.songoda.skyblock.utils.version.NMSUtil; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -public class Rollback implements Listener { - - private static Rollback instance; - - public static Rollback getInstance() { - if (instance == null) { - instance = new Rollback(); - } - - return instance; - } - - public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); - - Config languageConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = languageConfig.getFileConfiguration(); - - Inventory inv = Bukkit.createInventory(null, InventoryType.HOPPER, - ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Rollback.Title"))); - - ItemStack is; - ItemMeta im; - - List itemLore = new ArrayList<>(); - - is = CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(); - im = is.getItemMeta(); - im.setDisplayName(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Barrier.Displayname"))); - is.setItemMeta(im); - inv.setItem(1, is); - - is = new ItemStack(CompatibleMaterial.WRITABLE_BOOK.getMaterial()); - im = is.getItemMeta(); - im.setDisplayName(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Save.Displayname"))); - - for (String itemLoreList : configLoad.getStringList("Menu.Rollback.Item.Save.Lore")) { - itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList)); - } - - im.setLore(itemLore); - is.setItemMeta(im); - inv.setItem(2, is); - itemLore.clear(); - - is = new ItemStack(Material.ENCHANTED_BOOK); - im = is.getItemMeta(); - im.setDisplayName(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Load.Displayname"))); - - for (String itemLoreList : configLoad.getStringList("Menu.Rollback.Item.Load.Lore")) { - itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList)); - } - - im.setLore(itemLore); - is.setItemMeta(im); - inv.setItem(3, is); - itemLore.clear(); - - is = new ItemStack(Material.HOPPER); - im = is.getItemMeta(); - im.setDisplayName(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Reset.Displayname"))); - - for (String itemLoreList : configLoad.getStringList("Menu.Rollback.Item.Reset.Lore")) { - itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList)); - } - - im.setLore(itemLore); - is.setItemMeta(im); - inv.setItem(4, is); - itemLore.clear(); - - player.openInventory(inv); - } - - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - Player player = (Player) event.getWhoClicked(); - ItemStack is = event.getCurrentItem(); - - if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { - SkyBlock skyblock = SkyBlock.getInstance(); - - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - String inventoryName = ""; - if (NMSUtil.getVersionNumber() > 13) { - inventoryName = event.getView().getTitle(); - } else { - try { - inventoryName = (String) Inventory.class.getMethod("getName").invoke(event.getInventory()); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Rollback.Title")))) { - event.setCancelled(true); - - Island island = islandManager.getIsland(player); - - if (island == null) { - messageManager.sendMessage(player, - config.getFileConfiguration().getString("Command.Island.Rollback.Owner.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - player.closeInventory(); - - return; - } else if (!island.hasRole(IslandRole.Owner, player.getUniqueId())) { - messageManager.sendMessage(player, - config.getFileConfiguration().getString("Command.Island.Rollback.Role.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - player.closeInventory(); - - return; - } - - if ((event.getCurrentItem().getType() == Material.NAME_TAG) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Info.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, 1.0F); - } else if ((event.getCurrentItem().getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial()) - && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Barrier.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); - } else if ((event.getCurrentItem().getType() == CompatibleMaterial.WRITABLE_BOOK.getMaterial()) - && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Save.Displayname"))))) { - /* - * new BukkitRunnable() { public void run() { for (Location.World worldList : - * Location.World.values()) { Location islandLocation = - * island.getLocation(worldList, Location.Environment.Island); - * - * try { Schematic.getInstance().save(new File(new - * File(skyblock.getDataFolder().toString() + "/rollback-data/" + - * island.getOwnerUUID().toString()), worldList.name() + ".schematic"), new - * Location(islandLocation.getWorld(), islandLocation.getBlockX() + 85, - * islandLocation.getBlockY(), islandLocation.getBlockZ() + 85), new - * Location(islandLocation.getWorld(), islandLocation.getBlockX() - 85, - * islandLocation.getBlockY(), islandLocation.getBlockZ() - 85)); } catch - * (Exception e) { e.printStackTrace(); } } } }.runTaskAsynchronously(skyblock); - */ - - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F); - } else if ((event.getCurrentItem().getType() == Material.ENCHANTED_BOOK) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Rollback.Item.Load.Displayname"))))) { - /* - * new BukkitRunnable() { public void run() { for (Location.World worldList : - * Location.World.values()) { Location islandLocation = - * island.getLocation(worldList, Location.Environment.Island); - * - * try { Schematic.getInstance().paste(new File(new - * File(skyblock.getDataFolder().toString() + "/rollback-data/" + - * island.getOwnerUUID().toString()), "Normal.schematic"), new - * Location(islandLocation.getWorld(), islandLocation.getBlockX() - 85, 0, - * islandLocation.getBlockZ() - 85), true); } catch (Exception e) { - * e.printStackTrace(); } } } }.runTaskAsynchronously(skyblock); - */ - - soundManager.playSound(player, CompatibleSound.BLOCK_PISTON_EXTEND.getSound(), 1.0F, 1.0F); - } - } - } - } -} diff --git a/src/main/java/com/songoda/skyblock/menus/SelectInputMethod.java b/src/main/java/com/songoda/skyblock/menus/SelectInputMethod.java deleted file mode 100644 index e36c8df7..00000000 --- a/src/main/java/com/songoda/skyblock/menus/SelectInputMethod.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.songoda.skyblock.menus; - -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.utils.item.MenuClickRegistry; -import com.songoda.skyblock.utils.item.nInventoryUtil; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - -import java.io.File; -import java.util.HashMap; -import java.util.UUID; - -/** - * Used to select an input method using a gui. - */ -public class SelectInputMethod { - - private static SelectInputMethod instance; - - public static SelectInputMethod getInstance() {return instance == null ? instance = new SelectInputMethod() : instance;} - - private HashMap listeners; - - public SelectInputMethod() { - listeners = new HashMap<>(); - MenuClickRegistry.getInstance().register((executors -> { - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Input.Item.All.Displayname", CompatibleMaterial.IRON_BLOCK), (ints,player,e) -> { - listeners.get(player.getUniqueId()).choose(InputMethodSelectlistener.InputMethod.ALL); - Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> { - listeners.remove(player); - }); - e.setWillClose(true); - e.setWillDestroy(true); - }); - })); - - MenuClickRegistry.getInstance().register((executors -> { - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Input.Item.Custom.Displayname", CompatibleMaterial.OAK_SIGN), (ints,player,e) -> { - listeners.get(player.getUniqueId()).choose(InputMethodSelectlistener.InputMethod.CUSTOM); - Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> { - listeners.remove(player); - }); - e.setWillClose(true); - e.setWillDestroy(true); - }); - })); - - MenuClickRegistry.getInstance().register((executors -> { - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Input.Item.Exit.Displayname", CompatibleMaterial.OAK_FENCE_GATE), (ints,player,e) -> { - listeners.get(player.getUniqueId()).choose(InputMethodSelectlistener.InputMethod.CANCELED); - Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> { - listeners.remove(player); - }); - e.setWillClose(true); - e.setWillDestroy(true); - }); - })); - - MenuClickRegistry.getInstance().register((executors -> { - executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Input.Item.Barrier.Displayname", CompatibleMaterial.BLACK_STAINED_GLASS_PANE), (ints,player,e) -> { - e.setWillClose(false); - e.setWillDestroy(false); - }); - })); - } - - public void open(Player player, String action, InputMethodSelectlistener listener) { - SkyBlock skyblock = SkyBlock.getInstance(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - nInventoryUtil nInv = new nInventoryUtil(player, event -> MenuClickRegistry.getInstance().dispatch(player, event)); - - listeners.put(player.getUniqueId(), listener); - - nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.Input.Item.Barrier.Displayname"), - configLoad.getStringList("Menu.Input.Item.Barrier.Lore"), null, null, null), 0,1,3,5,7,8); - - nInv.addItem(nInv.createItem(CompatibleMaterial.IRON_BLOCK.getItem(), configLoad.getString("Menu.Input.Item.All.Displayname"), - configLoad.getStringList("Menu.Input.Item.All.Lore"), null, null, null), 2); - - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Input.Item.Exit.Displayname"), - configLoad.getStringList("Menu.Input.Item.Exit.Lore"), null, null, null), 4); - - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SIGN.getItem(), configLoad.getString("Menu.Input.Item.Custom.Displayname"), - configLoad.getStringList("Menu.Input.Item.Custom.Lore"), null, null, null), 6); - - nInv.setRows(1); - - nInv.setTitle(configLoad.getString("Menu.Input.Title")); - - Bukkit.getScheduler().runTask(skyblock,nInv::open); - } -} From 48ef9e922dbf25c570540629da185a232ff85c0d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 04:31:02 +0200 Subject: [PATCH 061/366] Removed README --- README.md | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 4ffbd242..00000000 --- a/README.md +++ /dev/null @@ -1,49 +0,0 @@ -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 option to have Members, Operators and Owners all responding to Members settings as a temporary fix to Operators and Owners settings not being editable via GUI -- Added 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 permissions to bypass kick and ban -- 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 -- Fixed mob grief setting -- Fixed explosion setting -- Fixed damage setting -- Fixed use portal setting -- Fixed bank that couldn't be opened from Members -- Fixed message telling that island disappeared on login -- Fixed GUI menus that had used the same page variable -- Fixed stackable bypassing break setting -- Now you can use `/is chat ` to send messages to island chat -- Now Challenges can be per-island too -- Now hunger setting works as intended -- 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. - From 41d850cdc1bd7e7e64c90378af88700e0480f598 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 04:31:11 +0200 Subject: [PATCH 062/366] Working on new menus --- .../skyblock/gui/bank/GuiBankSelector.java | 2 +- .../com/songoda/skyblock/gui/wip/GuiBans.java | 6 +- .../songoda/skyblock/gui/wip/GuiBiome.java | 124 ++++++++++++++++++ src/main/resources/menus.yml | 114 ++++++++++++++++ 4 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java create mode 100644 src/main/resources/menus.yml diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index a92e18d3..28503c85 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -66,7 +66,7 @@ public class GuiBankSelector extends Gui { event.player.closeInventory(); }); - String action = ""; + String action; switch(type){ case DEPOSIT: action = "Deposit"; diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index bb4a3652..6c0616f1 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -39,12 +39,16 @@ public class GuiBans extends Gui { this.island = island; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); - setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setDefaultItem(null); setTitle(TextUtils.formatText("Bans")); paint(); } public void paint() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 1, 8, null); + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java new file mode 100644 index 00000000..41ac7ab3 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java @@ -0,0 +1,124 @@ +package com.songoda.skyblock.gui.wip; + +import com.songoda.core.compatibility.CompatibleBiome; +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.AnvilGui; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.bank.BankManager; +import com.songoda.skyblock.bank.Transaction; +import com.songoda.skyblock.gui.bank.GuiBankSelector; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandWorld; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.utils.NumberUtil; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class GuiBiome extends Gui { + private final SkyBlock plugin; + private final Island island; + private final FileConfiguration languageLoad; + private final FileConfiguration config; + private final Gui returnGui; + private final Player player; + private final IslandWorld world; + private final boolean admin; + + public GuiBiome(SkyBlock plugin, Player player, Island island, IslandWorld world, Gui returnGui, boolean admin) { + super(returnGui); + this.plugin = plugin; + this.island = island; + this.world = world; + this.player = player; + this.returnGui = returnGui; + this.admin = admin; + this.config = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + setDefaultItem(null); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Input.Title"))); + paint(); + } + + public void paint() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 1, 8, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { + CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + event.player.closeInventory(); + }); + + for(int i=9; i<18; i++){ + setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + } + + List biomes = new ArrayList<>(); + for(CompatibleBiome biome : CompatibleBiome.getCompatibleBiomes()) { + if(biome.isCompatible() + && player.hasPermission("fabledskyblock.biome." + biome.name().toLowerCase()) + && config.getBoolean("Island.Biome." + world.name() + "." + biome.name(), false)){ + biomes.add(biome); + } + } + + if(biomes.size() > 0){ + this.pages = (int) Math.max(1, Math.ceil((double) biomes.size() / 27d)); + + if (page != 1) + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))), + (event) -> { + page--; + paint(); + }); + + if (page != pages) + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); + + for (int i = 9; i < ((getRows()-1)*9)+9; i++) { + int current = ((page - 1) * 36) - 9; + if (current + i >= biomes.size()) { + setItem(i, null); + continue; + } + CompatibleBiome transaction = biomes.get(current + i); + if (transaction == null) continue; + + ItemStack is = null; + // TODO create the item + + setItem(i, is); + } + } else { + setItem(31, CompatibleMaterial.BARRIER.getItem()); + } + } +} diff --git a/src/main/resources/menus.yml b/src/main/resources/menus.yml new file mode 100644 index 00000000..7b1db7ac --- /dev/null +++ b/src/main/resources/menus.yml @@ -0,0 +1,114 @@ +GUI: + Bank: + Main: + Title: 'Bank' + Placeholder: + Material: BLACK_STAINED_GLASS_PANE + DisplayName: "&fBank" + Lore: [] + Exit1: + Material: OAK_FENCE_GATE + Position: 0 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + Exit2: + Material: OAK_FENCE_GATE + Position: 8 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + Transaction: + Material: BOOK + Position: 4 + DisplayName: "&fTransaction log" + Lore: + - "Click to view full log" + Balance: + Material: GOLD_INGOT + Position: 13 + DisplayName: "&fBalance" + Lore: + - "&7Bank balance: &6${BALANCE}" + Deposit: + Material: GREEN_DYE + Position: 10 + DisplayName: "&a{DATETIME}" + Lore: + - '&7Click to deposit your money. Everything or a custom amount.' + Withdraw: + Material: RED_DYE + Position: 16 + DisplayName: "&c{DATETIME}" + Lore: + - '&7Click to withdraw your money. Everything or a custom amount.' + Selector: + Title: 'Select amount' + Placeholder: + Material: BLACK_STAINED_GLASS_PANE + DisplayName: "&fBank" + Lore: [] + Exit1: + Material: OAK_FENCE_GATE + Position: 0 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + Exit2: + Material: OAK_FENCE_GATE + Position: 8 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + All: + Material: GOLD_BLOCK + Position: 2 + DisplayName: "&fAll" + Lore: [] + Custom: + Material: PAPER + Position: 6 + DisplayName: "&fCustom" + Lore: [] + Transactions: + Title: 'Transactions' + Placeholder: + Material: AIR + DisplayName: "" + Lore: [] + Empty: + Material: BARRIER + Position: 31 + DisplayName: "&cBank" + Lore: [] + Info: + Material: PAINTING + Position: 31 + Displayname: '&fInfo' + Lore: + - '&7Total transactions: {TRANSACTIONS}' + Deposit: + Material: GREEN_DYE + Position: 31 + Displayname: '&a%dateTime' + Lore: + - '&7 {PLAYERNAME} deposited {AMOUNT}' + Withdraw: + Material: RED_DYE + Position: 31 + Displayname: '&c%dateTime' + Lore: + - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + PrevPage: + Material: ARROW + Position: 50 + Displayname: '&a&lPrevious Page' + Lore: + - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + NextPage: + Material: ARROW + Position: 54 + Displayname: '&a&lNext Page' + Lore: + - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + \ No newline at end of file From 9af318ff58f1137ff31564db1ef539b2324752bf Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 18:56:22 +0200 Subject: [PATCH 063/366] CoreProtect partial support --- pom.xml | 6 ++++ .../java/com/songoda/skyblock/SkyBlock.java | 29 +++++++++++++++++++ .../com/songoda/skyblock/listeners/Block.java | 6 +++- .../songoda/skyblock/listeners/Interact.java | 4 +++ src/main/resources/plugin.yml | 3 +- 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a53bd0c3..d44936c7 100644 --- a/pom.xml +++ b/pom.xml @@ -196,5 +196,11 @@ provided 4.9.0.6 + + net + coreprotect + provided + 2.18.2 + diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 5f86e20b..6c8f5ece 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -45,10 +45,13 @@ import com.songoda.skyblock.visit.VisitManager; import com.songoda.skyblock.visit.VisitTask; import com.songoda.skyblock.world.WorldManager; import com.songoda.skyblock.world.generator.VoidGenerator; +import net.coreprotect.CoreProtect; +import net.coreprotect.CoreProtectAPI; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.event.HandlerList; import org.bukkit.generator.ChunkGenerator; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import java.io.File; @@ -88,6 +91,8 @@ public class SkyBlock extends SongodaPlugin { private BankManager bankManager; private PermissionManager permissionManager; + private CoreProtectAPI coreProtectAPI; + private final GuiManager guiManager = new GuiManager(this); public static SkyBlock getInstance() { @@ -196,6 +201,8 @@ public class SkyBlock extends SongodaPlugin { this.getCommand("skyblock").setExecutor(new SkyBlockCommand()); + this.coreProtectAPI = loadCoreProtect(); + SkyBlockAPI.setImplementation(INSTANCE); } @@ -240,6 +247,24 @@ public class SkyBlock extends SongodaPlugin { HandlerList.unregisterAll(this); } + private CoreProtectAPI loadCoreProtect() { + Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect"); + + + if (plugin != null) { // Check before loading classes + if (plugin instanceof CoreProtect) { // Check that CoreProtect is loaded + CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI(); + if (CoreProtect.isEnabled()) { // Check that the API is enabled + if (CoreProtect.APIVersion() >= 6) { // Check that a compatible version of the API is loaded + return CoreProtect; + } + } + } + } + return null; + + } + @Override public void onConfigReload() { @@ -386,4 +411,8 @@ public class SkyBlock extends SongodaPlugin { public GuiManager getGuiManager() { return guiManager; } + + public CoreProtectAPI getCoreProtectAPI() { + return coreProtectAPI; + } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index ce16ea0d..b3a687cf 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -78,7 +78,7 @@ public class Block implements Listener { CompatibleMaterial material = CompatibleMaterial.getMaterial(block); byte data = block.getData(); - int droppedAmount = 0; + int droppedAmount; if (event.getPlayer().isSneaking()) { Location dropLoc = blockLocation.clone().add(0.5, 0.5, 0.5); int count = stackable.getSize(); @@ -96,6 +96,10 @@ public class Block implements Listener { droppedAmount = 1; } + if(skyblock.getCoreProtectAPI() != null) { + skyblock.getCoreProtectAPI().logRemoval(player.getName(), block.getLocation(), material.getMaterial(), null); + } + if (stackable.getSize() <= 1) { stackableManager.removeStack(stackable); } diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 0e053b5b..53244d01 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -236,6 +236,10 @@ public class Interact implements Listener { event.setCancelled(true); } + if(skyblock.getCoreProtectAPI() != null && material != null) { + skyblock.getCoreProtectAPI().logPlacement(player.getName(), location, material.getMaterial(), null); + } + if (player.getGameMode() != GameMode.CREATIVE) ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event), itemAmount); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2932d356..0f607091 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,7 +5,8 @@ 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, Residence] +softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, + EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence, CoreProtect] loadbefore: [Multiverse-Core, ProtocolLib] commands: island: From 1338dc8c9362324f0a2d24ae8c4a4887d3e8c814 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 18:56:41 +0200 Subject: [PATCH 064/366] Progression with bug gui --- .../com/songoda/skyblock/gui/wip/GuiBans.java | 4 +- src/main/resources/menus.yml | 53 +++++++++++++++++-- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index 6c0616f1..5c98531c 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -70,7 +70,7 @@ public class GuiBans extends Gui { if(bans.size() == 0){ setItem(31, CompatibleMaterial.BARRIER.getItem()); } else { - for (int i = 9; i < ((getRows()-2)*9)+18; i++) { // TODO check dynamic dimension! + for (int i = 9; i < ((getRows()-2)*9)+18; i++) { // TODO check dynamic dimension! - Arrows! int current = ((page - 1) * 36) - 18; if (current + i >= bans.size()) { setItem(i, null); @@ -109,7 +109,7 @@ public class GuiBans extends Gui { setButton(i, is, e -> { String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); // TODO Check if it actually works - Bukkit.getServer().dispatchCommand(e.player, "island unban " + playerName); + Bukkit.getServer().dispatchCommand(e.player, "island unban " + playerName); // TODO Command or APIs? }); } } diff --git a/src/main/resources/menus.yml b/src/main/resources/menus.yml index 7b1db7ac..a463be22 100644 --- a/src/main/resources/menus.yml +++ b/src/main/resources/menus.yml @@ -79,7 +79,7 @@ GUI: Empty: Material: BARRIER Position: 31 - DisplayName: "&cBank" + DisplayName: "&cNo transactions" Lore: [] Info: Material: PAINTING @@ -103,12 +103,55 @@ GUI: Material: ARROW Position: 50 Displayname: '&a&lPrevious Page' - Lore: - - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + Lore: [] NextPage: Material: ARROW Position: 54 Displayname: '&a&lNext Page' - Lore: - - '&7 {PLAYERNAME} withdrawn {AMOUNT}' + Lore: [] + Bans: + Title: '&8Island bans' + Exit1: + Material: OAK_FENCE_GATE + Position: 0 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + Exit2: + Material: OAK_FENCE_GATE + Position: 8 + DisplayName: "&cExit" + Lore: + - "&7Exits the Menu" + PrevPage: + Material: ARROW + Position: 50 + Displayname: '&a&lPrevious Page' + Lore: [] + NextPage: + Material: ARROW + Position: 54 + Displayname: '&a&lNext Page' + Lore: [] + Empty: + Material: BARRIER + Position: 31 + Displayname: '&cNo banned users' + Lore: [] + Head: + Displayname: '&a{PLAYERNAME}' + Lore: + - '' + - '&eClick to Unban player!' + Info: + Material: PAINTING + Position: 4 + Displayname: '&bInformations' + Lore: + - '&7Prevent certain players' + - '&7from entering your Island' + - '&7by banning them.' + - '' + - '&eClick to ban a player!' + \ No newline at end of file From db8dbeff4ca5378f694f2f12eb7f2f2a00b4edd0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 19:52:45 +0200 Subject: [PATCH 065/366] Arrows in ban gui --- .../com/songoda/skyblock/gui/wip/GuiBans.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index 5c98531c..53fa9637 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -70,7 +70,25 @@ public class GuiBans extends Gui { if(bans.size() == 0){ setItem(31, CompatibleMaterial.BARRIER.getItem()); } else { - for (int i = 9; i < ((getRows()-2)*9)+18; i++) { // TODO check dynamic dimension! - Arrows! + this.pages = (int) Math.max(1, Math.ceil((double) bans.size() / 36d)); + + if (page != 1) + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))), + (event) -> { + page--; + paint(); + }); + + if (page != pages) + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); + + for (int i = 9; i < ((getRows()-2)*9)+18; i++) { int current = ((page - 1) * 36) - 18; if (current + i >= bans.size()) { setItem(i, null); From 2638a3a896ac9be47ffde4f79480ffd21814afba Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 19:53:00 +0200 Subject: [PATCH 066/366] Use ChatColor library for color char --- src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java index 8b5af07a..98a9b161 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java @@ -212,6 +212,6 @@ public class Scoreboard { displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine); } - return displayLine.replace("§", "&"); // Returning unformatted line to avoid issues in next step + return displayLine.replace(String.valueOf(ChatColor.COLOR_CHAR), "&"); // Returning unformatted line to avoid issues in next step } } From 1da34a44d9436d0942490b8435990ef873ba33f6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 19:53:09 +0200 Subject: [PATCH 067/366] 2.3.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d44936c7..8dedb471 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.3-DEV2 + 2.3.3 jar clean install From 8f7d92959edd7eadd9d38fa2b87f53fde4189cbe Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 21 Jun 2020 20:05:54 +0200 Subject: [PATCH 068/366] CoreProtect support for explosions --- src/main/java/com/songoda/skyblock/listeners/Entity.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 1a0a954d..3e2522e0 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -423,6 +423,10 @@ public class Entity implements Listener { removeBlockFromLevel(island, block); } + if(skyblock.getCoreProtectAPI() != null) { + skyblock.getCoreProtectAPI().logRemoval("#" + entity.getType().toString().toLowerCase(), block.getLocation(), material.getMaterial(), null); + } + it.remove(); if(!removed){ removed = true; From 4ab5fa01ed0e68845e30071ae40aa5d1b6231053 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 02:05:20 +0200 Subject: [PATCH 069/366] Biome update --- .../songoda/skyblock/biome/BiomeManager.java | 24 +- .../songoda/skyblock/config/FileManager.java | 10 +- .../songoda/skyblock/gui/wip/BiomeIcon.java | 48 ++ .../songoda/skyblock/gui/wip/GuiBiome.java | 78 ++- src/main/resources/biomes.yml | 497 ++++++++++++++++++ 5 files changed, 647 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java create mode 100644 src/main/resources/biomes.yml diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 60b56207..e19d9aa6 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -27,7 +27,7 @@ public class BiomeManager { Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island); int radius = (int) Math.ceil(island.getRadius()); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + /*Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) { for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) { location.getWorld().setBiome(x, z, biome); @@ -41,7 +41,29 @@ public class BiomeManager { } } }); + });*/ + + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + long i = 0; + for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) { + for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) { + int finalX = x; + int finalZ = z; + Bukkit.getScheduler().runTaskLater(skyblock, () -> { + Chunk chunk = location.getWorld().getChunkAt(finalX >> 4, finalZ >> 4); + location.getWorld().loadChunk(chunk); + for(int xx = 0; xx < 16; xx++){ + for(int zz = 0; zz < 16; zz++){ + chunk.getBlock(xx, 0, zz).setBiome(biome); + } + } + updateBiome(island, chunk); + }, i); + i++; + } + } }); + } private Class packetPlayOutMapChunkClass; diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java index 07432f50..a695a73c 100644 --- a/src/main/java/com/songoda/skyblock/config/FileManager.java +++ b/src/main/java/com/songoda/skyblock/config/FileManager.java @@ -67,6 +67,8 @@ public class FileManager { configFiles.put("language.yml", new File(skyblock.getDataFolder(), "language.yml")); configFiles.put("settings.yml", new File(skyblock.getDataFolder(), "settings.yml")); configFiles.put("upgrades.yml", new File(skyblock.getDataFolder(), "upgrades.yml")); + // configFiles.put("biomes.yml", new File(skyblock.getDataFolder(), "biomes.yml")); + // configFiles.put("menus.yml", new File(skyblock.getDataFolder(), "menus.yml")); configFiles.put("generators.yml", new File(skyblock.getDataFolder(), "generators.yml")); configFiles.put("stackables.yml", new File(skyblock.getDataFolder(), "stackables.yml")); configFiles.put("structures.yml", new File(skyblock.getDataFolder(), "structures.yml")); @@ -90,7 +92,9 @@ public class FileManager { e.printStackTrace(); } try (InputStream is = skyblock.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) { - ByteStreams.copy(is, os); + if(is != null){ + ByteStreams.copy(is, os); + } } catch (IOException e) { e.printStackTrace(); } @@ -115,7 +119,9 @@ public class FileManager { try { configFile.createNewFile(); try (InputStream is = skyblock.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) { - ByteStreams.copy(is, os); + if(is != null){ + ByteStreams.copy(is, os); + } } if (fileName.equals("worlds.yml")) { diff --git a/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java b/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java new file mode 100644 index 00000000..4aaeb20e --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java @@ -0,0 +1,48 @@ +package com.songoda.skyblock.gui.wip; + +import com.songoda.core.compatibility.CompatibleBiome; +import com.songoda.skyblock.SkyBlock; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.io.File; + +public class BiomeIcon { + public final CompatibleBiome biome; + public final ItemStack displayItem; + public final boolean permission; + public final boolean normal; + public final boolean nether; + public final boolean end; + + public BiomeIcon(SkyBlock plugin, CompatibleBiome biome){ + this.biome = biome; + FileConfiguration biomeConfig = plugin.getFileManager().getConfig(new File("biomes.yml")).getFileConfiguration(); + this.displayItem = null; // TODO + ItemMeta im = displayItem.getItemMeta(); + if(im != null){ + im.setDisplayName(ChatColor.translateAlternateColorCodes('&', biomeConfig.getString("Biomes." + biome.name() + ".DisplayName", biome.name()))); + displayItem.setItemMeta(im); + } + this.permission = biomeConfig.getBoolean("Biomes." + biome.name() + ".Permission", true); + this.normal = biomeConfig.getBoolean("Biomes." + biome.name() + ".Normal", false); + this.nether = biomeConfig.getBoolean("Biomes." + biome.name() + ".Nether", false); + this.end = biomeConfig.getBoolean("Biomes." + biome.name() + ".End", false); + } + + public BiomeIcon(CompatibleBiome biome, ItemStack displayItem, String displayName, boolean permission, boolean normal, boolean nether, boolean end){ + this.biome = biome; + this.displayItem = displayItem; + ItemMeta im = displayItem.getItemMeta(); + if(im != null){ + im.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName)); + displayItem.setItemMeta(im); + } + this.permission = permission; + this.normal = normal; + this.nether = nether; + this.end = end; + } +} diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java index 41ac7ab3..0ae70f53 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java @@ -11,10 +11,18 @@ import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.bank.Transaction; +import com.songoda.skyblock.biome.BiomeManager; +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.gui.bank.GuiBankSelector; import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandEnvironment; +import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -55,6 +63,12 @@ public class GuiBiome extends Gui { } public void paint() { + SoundManager soundManager = plugin.getSoundManager(); + BiomeManager biomeManager = plugin.getBiomeManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + if (inventory != null) inventory.clear(); setActionForRange(0, 0, 1, 8, null); @@ -75,12 +89,29 @@ public class GuiBiome extends Gui { setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); } - List biomes = new ArrayList<>(); + List biomes = new ArrayList<>(); for(CompatibleBiome biome : CompatibleBiome.getCompatibleBiomes()) { if(biome.isCompatible() && player.hasPermission("fabledskyblock.biome." + biome.name().toLowerCase()) && config.getBoolean("Island.Biome." + world.name() + "." + biome.name(), false)){ - biomes.add(biome); + BiomeIcon icon = new BiomeIcon(plugin, biome); + switch(world){ + case Normal: + if(icon.normal){ + biomes.add(icon); + } + break; + case Nether: + if(icon.nether){ + biomes.add(icon); + } + break; + case End: + if(icon.end){ + biomes.add(icon); + } + break; + } } } @@ -109,13 +140,46 @@ public class GuiBiome extends Gui { setItem(i, null); continue; } - CompatibleBiome transaction = biomes.get(current + i); - if (transaction == null) continue; + BiomeIcon icon = biomes.get(current + i); + if (icon == null) continue; - ItemStack is = null; - // TODO create the item + setButton(i, icon.displayItem, event -> { + if (cooldownManager.hasPlayer(CooldownType.Biome, player) && !player.hasPermission("fabledskyblock.bypass.cooldown")) { + CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Biome, player); + Cooldown cooldown = cooldownPlayer.getCooldown(); - setItem(i, is); + if (cooldown.getTime() < 60) { + messageManager.sendMessage(player, + languageLoad.getString("Island.Biome.Cooldown.Message") + .replace("%time", + cooldown.getTime() + " " + languageLoad + .getString("Island.Biome.Cooldown.Word.Second"))); + } else { + long[] durationTime = NumberUtil.getDuration(cooldown.getTime()); + messageManager.sendMessage(player, + languageLoad.getString("Island.Biome.Cooldown.Message") + .replace("%time", durationTime[2] + " " + + languageLoad.getString("Island.Biome.Cooldown.Word.Minute") + + " " + durationTime[3] + " " + + languageLoad.getString("Island.Biome.Cooldown.Word.Second"))); + } + + soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + + return; + } + cooldownManager.createPlayer(CooldownType.Biome, player); + biomeManager.setBiome(island, icon.biome.getBiome()); + island.setBiome(icon.biome.getBiome()); + island.save(); + + soundManager.playSound(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island), + CompatibleSound.ENTITY_GENERIC_SPLASH.getSound(), 1.0F, 1.0F); + + if (!islandManager.isPlayerAtIsland(island, player, IslandWorld.Normal)) { + soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_SPLASH.getSound(), 1.0F, 1.0F); + } + }); } } else { setItem(31, CompatibleMaterial.BARRIER.getItem()); diff --git a/src/main/resources/biomes.yml b/src/main/resources/biomes.yml new file mode 100644 index 00000000..8ecc6bc8 --- /dev/null +++ b/src/main/resources/biomes.yml @@ -0,0 +1,497 @@ +Biomes: + BADLANDS: + DisplayName: 'Badlands' + DiplayItem: + Material: WHITE_TERRACOTTA + Data: 0 + Permission: true + Normal: true + Nether: false + End: false + BADLANDS_PLATEAU: + DisplayName: 'Badlands Plateau' + DiplayItem: + Material: RED_TERRACOTTA + Data: 14 + Permission: true + Normal: true + Nether: false + End: false + BAMBOO_JUNGLE: + DisplayName: 'Bamboo Jungle' + DiplayItem: + Material: BAMBOO + Data: 0 + Permission: true + Normal: true + Nether: false + End: false + BAMBOO_JUNGLE_HILLS: + DisplayName: 'Bamboo Jungle Hills' + DiplayItem: + Material: BAMBOO + Data: 0 + Permission: true + Normal: true + Nether: false + End: false + BASALT_DELTAS: + DisplayName: 'Basalt Deltas' + DiplayItem: + Material: BASALT + Data: 0 + Permission: true + Normal: false + Nether: true + End: false + BEACH: + DisplayName: 'Beach' + Permission: true + Normal: true + Nether: false + End: false + BIRCH_FOREST: + DisplayName: 'Birch Forest' + Permission: true + Normal: true + Nether: false + End: false + BIRCH_FOREST_HILLS: + DisplayName: 'Birch Forest Hills' + Permission: true + Normal: true + Nether: false + End: false + COLD_OCEAN: + DisplayName: 'Cold Ocean' + Permission: true + Normal: true + Nether: false + End: false + CRIMSON_FOREST: + DisplayName: 'Crimson Forest' + Permission: true + Normal: false + Nether: true + End: false + DARK_FOREST: + DisplayName: 'Dark Forest' + Permission: true + Normal: true + Nether: false + End: false + DARK_FOREST_HILLS: + DisplayName: 'Dark Forest Hills' + Permission: true + Normal: true + Nether: false + End: false + DEEP_COLD_OCEAN: + DisplayName: 'Deep Cold Ocean' + Permission: true + Normal: true + Nether: false + End: false + DEEP_FROZEN_OCEAN: + DisplayName: 'Deep Frozen Ocean' + Permission: true + Normal: true + Nether: false + End: false + DEEP_LUKEWARM_OCEAN: + DisplayName: 'Deep Lukewarm Ocean' + Permission: true + Normal: true + Nether: false + End: false + DEEP_OCEAN: + DisplayName: 'Deep Ocean' + Permission: true + Normal: true + Nether: false + End: false + DEEP_WARM_OCEAN: + DisplayName: 'Deep Warm Ocean' + Permission: true + Normal: true + Nether: false + End: false + DESERT: + DisplayName: 'Desert' + Permission: true + Normal: true + Nether: false + End: false + DESERT_HILLS: + DisplayName: 'Desert Hills' + Permission: true + Normal: true + Nether: false + End: false + DESERT_LAKES: + DisplayName: 'Desert Lakes' + Permission: true + Normal: true + Nether: false + End: false + END_BARRENS: + DisplayName: 'End Barrens' + Permission: true + Normal: false + Nether: false + End: end + END_HIGHLANDS: + DisplayName: 'End HighLands' + Permission: true + Normal: false + Nether: false + End: true + END_MIDLANDS: + DisplayName: 'End Midlands' + Permission: true + Normal: false + Nether: false + End: end + ERODED_BADLANDS: + DisplayName: 'Eroded Badlands' + Permission: true + Normal: true + Nether: false + End: false + FLOWER_FOREST: + DisplayName: 'Flower Forest' + Permission: true + Normal: true + Nether: false + End: false + FOREST: + DisplayName: 'Forest' + Permission: true + Normal: true + Nether: false + End: false + FROZEN_OCEAN: + DisplayName: 'Frozen Ocean' + Permission: true + Normal: true + Nether: false + End: false + FROZEN_RIVER: + DisplayName: 'Frozen River' + Permission: true + Normal: true + Nether: false + End: false + GIANT_SPRUCE_TAIGA: + DisplayName: 'Giant Spruce Taiga' + Permission: true + Normal: true + Nether: false + End: false + GIANT_SPRUCE_TAIGA_HILLS: + DisplayName: 'Giant Spruce Taiga Hills' + Permission: true + Normal: true + Nether: false + End: false + GIANT_TREE_TAIGA: + DisplayName: 'Giant Tree Taiga' + Permission: true + Normal: true + Nether: false + End: false + GIANT_TREE_TAIGA_HILLS: + DisplayName: 'Giant Tree Taiga Hills' + Permission: true + Normal: true + Nether: false + End: false + GRAVELLY_MOUNTAINS: + DisplayName: 'Gravelly Mountains' + Permission: true + Normal: true + Nether: false + End: false + ICE_SPIKES: + DisplayName: 'Ice Spikes' + Permission: true + Normal: true + Nether: false + End: false + JUNGLE: + DisplayName: 'Jungle' + Permission: true + Normal: true + Nether: false + End: false + JUNGLE_EDGE: + DisplayName: 'Jungle Edge' + Permission: true + Normal: true + Nether: false + End: false + JUNGLE_HILLS: + DisplayName: 'Jungle Hills' + Permission: true + Normal: true + Nether: false + End: false + LUKEWARM_OCEAN: + DisplayName: 'Lukewarm Ocean' + Permission: true + Normal: true + Nether: false + End: false + MODIFIED_BADLANDS_PLATEAU: + DisplayName: 'Modified Badlands Plateau' + Permission: true + Normal: true + Nether: false + End: false + MODIFIED_GRAVELLY_MOUNTAINS: + DisplayName: 'Modified Gravelly Mountains' + Permission: true + Normal: true + Nether: false + End: false + MODIFIED_JUNGLE: + DisplayName: 'Modified Jungle' + Permission: true + Normal: true + Nether: false + End: false + MODIFIED_JUNGLE_EDGE: + DisplayName: 'Modified Jungle Edge' + Permission: true + Normal: true + Nether: false + End: false + MODIFIED_WOODED_BADLANDS_PLATEAU: + DisplayName: 'Modified Wooden Badlands Plateau' + Permission: true + Normal: true + Nether: false + End: false + MOUNTAINS: + DisplayName: 'Mountains' + Permission: true + Normal: true + Nether: false + End: false + MOUNTAIN_EDGE: + DisplayName: 'Mountain Edge' + Permission: true + Normal: true + Nether: false + End: false + MUSHROOM_FIELDS: + DisplayName: 'Mushroom Fields' + Permission: true + Normal: true + Nether: false + End: false + MUSHROOM_FIELD_SHORE: + DisplayName: 'Mushroom Field Shore' + Permission: true + Normal: true + Nether: false + End: false + # PRE-1.16 + NETHER: + DisplayName: 'Nether' + Permission: true + Normal: false + Nether: true + End: false + NETHER_WASTES: + DisplayName: 'Nether Wastes' + Permission: true + Normal: false + Nether: true + End: false + OCEAN: + DisplayName: 'Ocean' + Permission: true + Normal: true + Nether: false + End: false + PLAINS: + DisplayName: 'Plains' + Permission: true + Normal: true + Nether: false + End: false + RIVER: + DisplayName: 'River' + Permission: true + Normal: true + Nether: false + End: false + SAVANNA: + DisplayName: 'Savanna' + Permission: true + Normal: true + Nether: false + End: false + SAVANNA_PLATEAU: + DisplayName: 'Savanna Plateau' + Permission: true + Normal: true + Nether: false + End: false + SHATTERED_SAVANNA: + DisplayName: 'Shattered Savanna' + Permission: true + Normal: true + Nether: false + End: false + SHATTERED_SAVANNA_PLATEAU: + DisplayName: 'Shattered Savanna Plateau' + Permission: true + Normal: true + Nether: false + End: false + SMALL_END_ISLANDS: + DisplayName: 'Small End Island' + Permission: true + Normal: false + Nether: false + End: true + SNOWY_BEACH: + DisplayName: 'Snowy Beach' + Permission: true + Normal: true + Nether: false + End: false + SNOWY_MOUNTAINS: + DisplayName: 'Snowy Mountains' + Permission: true + Normal: true + Nether: false + End: false + SNOWY_TAIGA: + DisplayName: 'Snowy Taiga' + Permission: true + Normal: true + Nether: false + End: false + SNOWY_TAIGA_HILLS: + DisplayName: 'Snowy Taiga Hills' + Permission: true + Normal: true + Nether: false + End: false + SNOWY_TAIGA_MOUNTAINS: + DisplayName: 'Snowy Taiga Mountains' + Permission: true + Normal: true + Nether: false + End: false + SNOWY_TUNDRA: + DisplayName: 'Snowy Tundra' + Permission: true + Normal: true + Nether: false + End: false + SOUL_SAND_VALLEY: + DisplayName: 'Soul Sand Valley' + Permission: true + Normal: false + Nether: true + End: false + STONE_SHORE: + DisplayName: 'Stone Shore' + Permission: true + Normal: true + Nether: false + End: false + SUNFLOWER_PLAINS: + DisplayName: 'Sunflower Plains' + Permission: true + Normal: true + Nether: false + End: false + SWAMP: + DisplayName: 'Swamp' + Permission: true + Normal: true + Nether: false + End: false + SWAMP_HILLS: + DisplayName: 'Swamp Hills' + Permission: true + Normal: true + Nether: false + End: false + TAIGA: + DisplayName: 'Taiga' + Permission: true + Normal: true + Nether: false + End: false + TAIGA_HILLS: + DisplayName: 'Taiga Hills' + Permission: true + Normal: true + Nether: false + End: false + TAIGA_MOUNTAINS: + DisplayName: 'Taiga Mountains' + Permission: true + Normal: true + Nether: false + End: false + TALL_BIRCH_FOREST: + DisplayName: 'Tall Birch Forest' + Permission: true + Normal: true + Nether: false + End: false + TALL_BIRCH_HILLS: + DisplayName: 'Tall Birch Hills' + Permission: true + Normal: true + Nether: false + End: false + THE_END: + DisplayName: 'The End' + Permission: true + Normal: false + Nether: false + End: true + THE_VOID: + DisplayName: 'The Void' + Permission: true + Normal: false + Nether: false + End: true + WARM_OCEAN: + DisplayName: 'Warm Ocean' + Permission: true + Normal: true + Nether: false + End: false + WARPED_FOREST: + DisplayName: 'Warped Forest' + Permission: true + Normal: false + Nether: true + End: false + WOODED_BADLANDS_PLATEAU: + DisplayName: 'Wooded Badlands Plateau' + Permission: true + Normal: true + Nether: false + End: false + WOODED_HILLS: + DisplayName: 'Wooded Hills' + Permission: true + Normal: true + Nether: false + End: false + WOODED_MOUNTAINS: + DisplayName: 'Wooded Mountains' + Permission: true + Normal: true + Nether: false + End: false \ No newline at end of file From 30e4637d3f98984c63ce5ebb4e13caae0fd6ce46 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 05:20:08 +0200 Subject: [PATCH 070/366] Fix for issues scanning or deleting an island in Paper with async chunk loads --- pom.xml | 6 +- .../java/com/songoda/skyblock/SkyBlock.java | 16 +++- .../skyblock/island/IslandManager.java | 57 ++++++++--- .../songoda/skyblock/levelling/ChunkUtil.java | 17 ++-- .../levelling/rework/IslandLevelManager.java | 9 +- .../skyblock/levelling/rework/IslandScan.java | 94 ++++++++++++------- 6 files changed, 139 insertions(+), 60 deletions(-) diff --git a/pom.xml b/pom.xml index 8dedb471..985158c7 100644 --- a/pom.xml +++ b/pom.xml @@ -127,9 +127,9 @@ - org.spigotmc - spigot - 1.15 + com.destroystokyo.papermc + paper + 1.15.2 provided diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 6c8f5ece..ba498e01 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -93,6 +93,8 @@ public class SkyBlock extends SongodaPlugin { private CoreProtectAPI coreProtectAPI; + private boolean paper; + private final GuiManager guiManager = new GuiManager(this); public static SkyBlock getInstance() { @@ -106,6 +108,14 @@ public class SkyBlock extends SongodaPlugin { @Override public void onPluginEnable() { + + paper = false; + try { + Class.forName("com.destroystokyo.paper.PaperConfig"); + paper = true; + Bukkit.getLogger().info("Enabling Paper hooks"); + } catch (ClassNotFoundException ignored) {} + // Run Songoda Updater SongodaCore.registerPlugin(this, 17, CompatibleMaterial.GRASS_BLOCK); @@ -135,7 +145,7 @@ public class SkyBlock extends SongodaPlugin { inviteManager = new InviteManager(this); biomeManager = new BiomeManager(this); - levellingManager = new IslandLevelManager(); + levellingManager = new IslandLevelManager(this); commandManager = new CommandManager(this); structureManager = new StructureManager(this); soundManager = new SoundManager(this); @@ -415,4 +425,8 @@ public class SkyBlock extends SongodaPlugin { public CoreProtectAPI getCoreProtectAPI() { return coreProtectAPI; } + + public boolean isPaper() { + return paper; + } } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index f0238949..caf93a35 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -18,6 +18,7 @@ import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.invite.Invite; import com.songoda.skyblock.invite.InviteManager; import com.songoda.skyblock.island.removal.ChunkDeleteSplitter; +import com.songoda.skyblock.levelling.ChunkUtil; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; @@ -56,6 +57,7 @@ import org.bukkit.plugin.Plugin; import java.io.File; import java.io.IOException; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; public class IslandManager { @@ -556,22 +558,15 @@ public class IslandManager { } } - final Map> snapshots = new HashMap<>(3); - - for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { - - final Location location = island.getLocation(worldList, IslandEnvironment.Island); - - if (location == null) continue; - - final World world = worldManager.getWorld(worldList); - - final List list = com.songoda.skyblock.levelling.ChunkUtil.getChunksToScan(island, worldList).stream().map(chunk -> chunk.getChunkSnapshot()).collect(Collectors.toList()); - - snapshots.put(world, list); + if (skyblock.isPaper() && Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false)) { + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + startDeletition(island, worldManager); + }); + } else { + startDeletition(island, worldManager); } - ChunkDeleteSplitter.startDeletion(snapshots); + skyblock.getVisitManager().deleteIsland(island.getOwnerUUID()); skyblock.getBanManager().deleteIsland(island.getOwnerUUID()); @@ -657,6 +652,40 @@ public class IslandManager { return true; } + private void startDeletition(Island island, WorldManager worldManager) { + final Map> snapshots = new HashMap<>(3); + + for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { + + final Location location = island.getLocation(worldList, IslandEnvironment.Island); + + if (location == null) continue; + + final World world = worldManager.getWorld(worldList); + + ChunkUtil chunks = new ChunkUtil(); + + + if (skyblock.isPaper() && Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false)) { + chunks.getChunksToScan(island, worldList, true); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + List positions = new LinkedList<>(); + for (CompletableFuture chunk : chunks.asyncPositions) { + positions.add(chunk.join()); + snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); + } + }); + } else { + chunks.getChunksToScan(island, worldList, false); + final List list = chunks.syncPositions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); + + snapshots.put(world, list); + } + } + + ChunkDeleteSplitter.startDeletion(snapshots); + } + public synchronized void deleteIslandData(UUID uuid) { FileManager fileManager = skyblock.getFileManager(); fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml")); diff --git a/src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java b/src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java index 63bcc64f..45472a36 100644 --- a/src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java +++ b/src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java @@ -3,7 +3,9 @@ package com.songoda.skyblock.levelling; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.CompletableFuture; +import com.sk89q.worldedit.bukkit.paperlib.PaperLib; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -13,11 +15,13 @@ import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; public class ChunkUtil { + public final List> asyncPositions = new LinkedList<>(); + public final List syncPositions = new LinkedList<>(); - public static List getChunksToScan(Island island, IslandWorld islandWorld) { + public void getChunksToScan(Island island, IslandWorld islandWorld, boolean paper) { Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island); - if (islandLocation == null) return new ArrayList<>(0); + if (islandLocation == null) return; World world = islandLocation.getWorld(); @@ -30,14 +34,15 @@ public class ChunkUtil { int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()); int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()); - final List positions = new LinkedList<>(); for (int x = minX; x < maxX + 16; x += 16) { for (int z = minZ; z < maxZ + 16; z += 16) { - positions.add(world.getChunkAt(x >> 4, z >> 4)); + if(paper){ + asyncPositions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); + } else { + syncPositions.add(world.getChunkAt(x >> 4, z >> 4)); + } } } - - return positions; } } diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java index 2d8ee400..83c02dd5 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java @@ -37,8 +37,10 @@ public final class IslandLevelManager { private Map inScan; private Map worth; private Map cachedPairs; + private final SkyBlock plugin; - public IslandLevelManager() { + public IslandLevelManager(SkyBlock plugin) { + this.plugin = plugin; this.inScan = new HashMap<>(); this.worth = new EnumMap<>(CompatibleMaterial.class); this.cachedPairs = new EnumMap<>(CompatibleMaterial.class); @@ -46,8 +48,7 @@ public final class IslandLevelManager { reloadWorth(); } - public void startScan(Player attemptScanner, Island island) { - + public void startScan(Player attemptScanner, Island island){ if (!Bukkit.isPrimaryThread()) { Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> startScan(attemptScanner, island)); return; @@ -73,7 +74,7 @@ public final class IslandLevelManager { messageManager.sendMessage(attemptScanner, config.getString("Command.Island.Level.Scanning.Started.Message")); } - inScan.put(island, new IslandScan(island).start()); + inScan.put(island, new IslandScan(plugin, island).start()); } public boolean isScanning(Island island) { diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java index d720bf41..8d21eeb7 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java @@ -12,10 +12,7 @@ import com.songoda.skyblock.levelling.ChunkUtil; import com.songoda.skyblock.levelling.rework.amount.AmountMaterialPair; import com.songoda.skyblock.levelling.rework.amount.BlockAmount; import com.songoda.skyblock.message.MessageManager; -import org.bukkit.Bukkit; -import org.bukkit.ChunkSnapshot; -import org.bukkit.Location; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -25,6 +22,7 @@ import java.io.File; import java.text.NumberFormat; import java.util.*; import java.util.Map.Entry; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; public final class IslandScan extends BukkitRunnable { @@ -37,13 +35,15 @@ public final class IslandScan extends BukkitRunnable { private final Map amounts; private final Configuration language; private final int runEveryX; + private final SkyBlock plugin; private int totalScanned; private int blocksSize; private Queue blocks; - public IslandScan(Island island) { + public IslandScan(SkyBlock plugin, Island island) { if (island == null) throw new IllegalArgumentException("island cannot be null"); + this.plugin = plugin; this.island = island; this.amounts = new EnumMap<>(CompatibleMaterial.class); this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration(); @@ -62,16 +62,34 @@ public final class IslandScan extends BukkitRunnable { final Map> snapshots = new HashMap<>(3); - populate(snapshots, IslandWorld.Normal); - if (hasNether) populate(snapshots, IslandWorld.Nether); - if (hasEnd) populate(snapshots, IslandWorld.End); - BlockScanner.startScanner(snapshots, (blocks) -> { - this.blocks = blocks; - this.blocksSize = blocks.size(); - this.runTaskTimer(SkyBlock.getInstance(), 20, 20); + if (skyblock.isPaper() && Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false)) { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + populate(snapshots, IslandWorld.Normal, true); + if (hasNether) populate(snapshots, IslandWorld.Nether, true); + if (hasEnd) populate(snapshots, IslandWorld.End, true); + + BlockScanner.startScanner(snapshots, (blocks) -> { + this.blocks = blocks; + this.blocksSize = blocks.size(); + this.runTaskTimer(SkyBlock.getInstance(), 20, 20); + + }); + }); + } else { + populate(snapshots, IslandWorld.Normal, false); + if (hasNether) populate(snapshots, IslandWorld.Nether, false); + if (hasEnd) populate(snapshots, IslandWorld.End, false); + + BlockScanner.startScanner(snapshots, (blocks) -> { + this.blocks = blocks; + this.blocksSize = blocks.size(); + this.runTaskTimer(SkyBlock.getInstance(), 20, 20); + + }); + } + - }); return this; } @@ -133,37 +151,49 @@ public final class IslandScan extends BukkitRunnable { SkyBlock.getInstance().getLevellingManager().stopScan(island); } - if (language.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) { + Bukkit.getScheduler().runTask(plugin, () -> { + if (language.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) { - final double percent = ((double) totalScanned / (double) blocksSize) * 100; + final double percent = ((double) totalScanned / (double) blocksSize) * 100; - String message = language.getString("Command.Island.Level.Scanning.Progress.Message"); - message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned)); - message = message.replace("%max_blocks%", String.valueOf(blocksSize)); - message = message.replace("%percent_whole%", String.valueOf((int) percent)); - message = message.replace("%percent%", FORMATTER.format(percent)); + String message = language.getString("Command.Island.Level.Scanning.Progress.Message"); + message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned)); + message = message.replace("%max_blocks%", String.valueOf(blocksSize)); + message = message.replace("%percent_whole%", String.valueOf((int) percent)); + message = message.replace("%percent%", FORMATTER.format(percent)); - final boolean displayComplete = totalScanned == blocksSize && language.getBoolean("Command.Island.Level.Scanning.Finished.Should-Display-Message"); - final MessageManager messageManager = SkyBlock.getInstance().getMessageManager(); + final boolean displayComplete = totalScanned == blocksSize && language.getBoolean("Command.Island.Level.Scanning.Finished.Should-Display-Message"); + final MessageManager messageManager = SkyBlock.getInstance().getMessageManager(); - for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { + for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { - messageManager.sendMessage(player, message); - if (displayComplete) - messageManager.sendMessage(player, language.getString("Command.Island.Level.Scanning.Finished.Message")); + messageManager.sendMessage(player, message); + if (displayComplete) + messageManager.sendMessage(player, language.getString("Command.Island.Level.Scanning.Finished.Message")); - // Check for level ups - island.getLevel().checkLevelUp(); + // Check for level ups + island.getLevel().checkLevelUp(); + } } - } - + }); } - private void populate(Map> snapshots, IslandWorld world) { + private void populate(Map> snapshots, IslandWorld world, boolean paper) { final SkyBlock skyblock = SkyBlock.getInstance(); - snapshots.put(skyblock.getWorldManager().getWorld(world), ChunkUtil.getChunksToScan(island, world).stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); + ChunkUtil chunks = new ChunkUtil(); + chunks.getChunksToScan(island, world, paper); + + if(paper){ + List positions = new LinkedList<>(); + for(CompletableFuture chunk : chunks.asyncPositions){ + positions.add(chunk.join()); + snapshots.put(skyblock.getWorldManager().getWorld(world), positions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); + } + } else { + snapshots.put(skyblock.getWorldManager().getWorld(world), chunks.syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); + } } public Set getDoubleBlocks() { From 60eb216b2bb090705a553a725581817ff435eb7f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 05:48:58 +0200 Subject: [PATCH 071/366] Optimized Island async scan --- .../com/songoda/skyblock/levelling/rework/IslandScan.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java index 8d21eeb7..a961c942 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java @@ -186,11 +186,11 @@ public final class IslandScan extends BukkitRunnable { chunks.getChunksToScan(island, world, paper); if(paper){ - List positions = new LinkedList<>(); + List positions = new LinkedList<>(); for(CompletableFuture chunk : chunks.asyncPositions){ - positions.add(chunk.join()); - snapshots.put(skyblock.getWorldManager().getWorld(world), positions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); + positions.add(chunk.join().getChunkSnapshot()); } + snapshots.put(skyblock.getWorldManager().getWorld(world), positions); } else { snapshots.put(skyblock.getWorldManager().getWorld(world), chunks.syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); } From 99f2fab2fc407af04c52512f1586361eb8cfaa06 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 16:30:56 +0200 Subject: [PATCH 072/366] Fix for bank not allowing decimals in action all --- .../java/com/songoda/skyblock/gui/bank/GuiBankSelector.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index 28503c85..f9f4e779 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -90,10 +90,16 @@ public class GuiBankSelector extends Gui { switch(type){ case DEPOSIT: amount = EconomyManager.getBalance(event.player); + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { + amount = Math.floor(amount); + } response = bankManager.deposit(event.player, island, amount, admin); break; case WITHDRAW: amount = island.getBankBalance(); + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { + amount = Math.floor(amount); + } response = bankManager.withdraw(event.player, island, amount, admin); break; default: From 47ef00bb6f7c4131064baa616b0eea3b46c10ede Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 17:02:10 +0200 Subject: [PATCH 073/366] Fix for proxy with island with more members --- .../skyblock/command/commands/admin/ProxyCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java index d97b773e..d5ad7cf6 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java @@ -41,9 +41,9 @@ public class ProxyCommand extends SubCommand { if (args.length == 1) { OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]); - UUID islandOwnerUUID = targetPlayerOffline.getOwner(); + UUID userUUID = targetPlayerOffline.getUUID(); - if (islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)) != null) { + if (islandManager.getIsland(Bukkit.getOfflinePlayer(userUUID)) != null) { if (islandManager.isPlayerProxyingAnotherPlayer(((Player)sender).getUniqueId())) { messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Proxy.IsOffPlayer.Message") @@ -57,7 +57,7 @@ public class ProxyCommand extends SubCommand { .replace("%player", targetPlayerOffline.getName())); soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - islandManager.addProxiedPlayer(((Player)sender).getUniqueId(), targetPlayerOffline.getUniqueId()); + islandManager.addProxiedPlayer(((Player)sender).getUniqueId(), userUUID); } } } else if (args.length == 0){ From cd15898858c7a7786a9ac2cb7a8e59c2618a093c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 17:02:40 +0200 Subject: [PATCH 074/366] Cauldron permission --- .../permission/PermissionManager.java | 1 + .../listening/CauldronPermission.java | 39 +++++++++++++++++++ src/main/resources/language.yml | 2 + src/main/resources/settings.yml | 3 ++ 4 files changed, 45 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/permission/permissions/listening/CauldronPermission.java diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 9bb7d17d..6d08121c 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -86,6 +86,7 @@ public class PermissionManager { new ItemPickupPermission(), new ItemDropPermission(), new FishingPermission(plugin), + new CauldronPermission(plugin), // Basic new MemberPermission(), diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/CauldronPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/CauldronPermission.java new file mode 100644 index 00000000..b788ecb9 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/CauldronPermission.java @@ -0,0 +1,39 @@ +package com.songoda.skyblock.permission.permissions.listening; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.permission.ListeningPermission; +import com.songoda.skyblock.permission.PermissionHandler; +import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +public class CauldronPermission extends ListeningPermission { + + private final SkyBlock plugin; + private final MessageManager messageManager; + + public CauldronPermission(SkyBlock plugin) { + super("Cauldron", CompatibleMaterial.CAULDRON, PermissionType.GENERIC); + this.plugin = plugin; + this.messageManager = plugin.getMessageManager(); + } + + @PermissionHandler + public void onInteract(PlayerInteractEvent event) { + if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) { + if(event.getItem() != null && !event.getItem().getType().isBlock()){ + Player player = event.getPlayer(); + Block block = event.getClickedBlock(); + + + if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.CAULDRON) + cancelAndMessage(event, player, plugin, messageManager); + } + } + + } +} diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index fee7823e..098e950e 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1168,6 +1168,8 @@ Menu: Displayname: '&aPvP' Noteblock: Displayname: '&aNoteblock use' + Cauldron: + Displayname: '&aCauldron use' Minecart: Displayname: '&aMinecart' Damage: diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index cbaed5f7..562bbb25 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -28,6 +28,7 @@ Settings: LeverButton: false Milking: false Jukebox: false + Cauldron: false PressurePlate: false Redstone: false Shearing: false @@ -59,6 +60,7 @@ Settings: AnimalBreeding: true Brewing: true Bucket: true + Cauldron: true WaterCollection: true Storage: true Workbench: true @@ -130,6 +132,7 @@ Settings: Crop: true Door: true Gate: true + Cauldron: true Projectile: true Enchant: true Fire: true From c099cab0818d663bee30c4c65d640a62115c8408 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 17:05:19 +0200 Subject: [PATCH 075/366] Reverted experimental algorithms for 2.3.4-DEV1 --- pom.xml | 2 +- src/main/java/com/songoda/skyblock/SkyBlock.java | 4 ++-- .../java/com/songoda/skyblock/biome/BiomeManager.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 985158c7..4a3c1abf 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.3 + 2.3.4-DEV1 jar clean install diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index ba498e01..ffcfe4f3 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -110,11 +110,11 @@ public class SkyBlock extends SongodaPlugin { public void onPluginEnable() { paper = false; - try { + /*try { Class.forName("com.destroystokyo.paper.PaperConfig"); paper = true; Bukkit.getLogger().info("Enabling Paper hooks"); - } catch (ClassNotFoundException ignored) {} + } catch (ClassNotFoundException ignored) {}*/ // Run Songoda Updater SongodaCore.registerPlugin(this, 17, CompatibleMaterial.GRASS_BLOCK); diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index e19d9aa6..751a35f3 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -27,7 +27,7 @@ public class BiomeManager { Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island); int radius = (int) Math.ceil(island.getRadius()); - /*Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) { for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) { location.getWorld().setBiome(x, z, biome); @@ -41,9 +41,9 @@ public class BiomeManager { } } }); - });*/ + }); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + /*Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { long i = 0; for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) { for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) { @@ -62,7 +62,7 @@ public class BiomeManager { i++; } } - }); + });*/ } From 5eda67adcd0c619754d2b4adbb34992896464494 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 19:06:25 +0200 Subject: [PATCH 076/366] Update PaperLib usage --- pom.xml | 28 +++++++++++++++++++ .../java/com/songoda/skyblock/SkyBlock.java | 15 ++++++++-- .../skyblock/levelling/rework/IslandScan.java | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4a3c1abf..47690f81 100644 --- a/pom.xml +++ b/pom.xml @@ -60,12 +60,14 @@ shade + ${project.build.directory}/dependency-reduced-pom.xml false false true com.songoda:SongodaCore + io.papermc:paperlib @@ -83,6 +85,10 @@ com.songoda.core ${project.groupId}.skyblock.core + + io.papermc.lib + ${project.groupId}.paperlib + @@ -100,6 +106,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + papermc + https://papermc.io/repo/repository/maven-public/ + minecraft-repo https://libraries.minecraft.net/ @@ -126,11 +136,29 @@ + + io.papermc + paperlib + 1.0.3 + compile + com.destroystokyo.papermc paper 1.15.2 provided + + + io.papermc + paperlib + + + + + org.spigotmc + spigot + 1.15 + provided com.github.MilkBowl diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index ffcfe4f3..7dbf9973 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -45,6 +45,7 @@ import com.songoda.skyblock.visit.VisitManager; import com.songoda.skyblock.visit.VisitTask; import com.songoda.skyblock.world.WorldManager; import com.songoda.skyblock.world.generator.VoidGenerator; +import io.papermc.lib.PaperLib; import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtectAPI; import org.bukkit.Bukkit; @@ -94,6 +95,7 @@ public class SkyBlock extends SongodaPlugin { private CoreProtectAPI coreProtectAPI; private boolean paper; + private boolean paperAsync; private final GuiManager guiManager = new GuiManager(this); @@ -110,11 +112,14 @@ public class SkyBlock extends SongodaPlugin { public void onPluginEnable() { paper = false; - /*try { + try { Class.forName("com.destroystokyo.paper.PaperConfig"); paper = true; - Bukkit.getLogger().info("Enabling Paper hooks"); - } catch (ClassNotFoundException ignored) {}*/ + paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); + this.getLogger().info("Enabling Paper hooks"); + } catch (ClassNotFoundException ignored) { + PaperLib.suggestPaper(this); + } // Run Songoda Updater SongodaCore.registerPlugin(this, 17, CompatibleMaterial.GRASS_BLOCK); @@ -429,4 +434,8 @@ public class SkyBlock extends SongodaPlugin { public boolean isPaper() { return paper; } + + public boolean isPaperAsync() { + return paperAsync; + } } diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java index a961c942..2bd573d0 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java @@ -63,7 +63,7 @@ public final class IslandScan extends BukkitRunnable { final Map> snapshots = new HashMap<>(3); - if (skyblock.isPaper() && Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false)) { + if (skyblock.isPaperAsync()) { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { populate(snapshots, IslandWorld.Normal, true); if (hasNether) populate(snapshots, IslandWorld.Nether, true); From 8506ad80bf60880bbed68d593a738f5b80d78ab4 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 19:06:43 +0200 Subject: [PATCH 077/366] Biome update with PaperLib --- .../songoda/skyblock/biome/BiomeManager.java | 55 +++++++++++++------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 751a35f3..ac917c05 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -1,10 +1,12 @@ package com.songoda.skyblock.biome; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.utils.version.NMSUtil; +import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -12,8 +14,6 @@ import org.bukkit.block.Biome; import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; -import java.util.HashSet; -import java.util.Set; public class BiomeManager { @@ -27,7 +27,7 @@ public class BiomeManager { Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island); int radius = (int) Math.ceil(island.getRadius()); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + /*Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) { for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) { location.getWorld().setBiome(x, z, biome); @@ -41,35 +41,54 @@ public class BiomeManager { } } }); - }); + });*/ - /*Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { long i = 0; for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) { for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) { int finalX = x; int finalZ = z; - Bukkit.getScheduler().runTaskLater(skyblock, () -> { - Chunk chunk = location.getWorld().getChunkAt(finalX >> 4, finalZ >> 4); - location.getWorld().loadChunk(chunk); - for(int xx = 0; xx < 16; xx++){ - for(int zz = 0; zz < 16; zz++){ - chunk.getBlock(xx, 0, zz).setBiome(biome); - } - } - updateBiome(island, chunk); - }, i); - i++; + + if(skyblock.isPaperAsync()){ + PaperLib.getChunkAtAsync(location.getWorld(), finalX >> 4, finalZ >> 4).thenAccept(chunk -> { + setChunkBiome(island, biome, chunk); + }); + } else { + Bukkit.getScheduler().runTaskLater(skyblock, () -> { + Chunk chunk = location.getWorld().getChunkAt(finalX >> 4, finalZ >> 4); + setChunkBiome(island, biome, chunk); + }, i); + i++; + } } } - });*/ + }); } + private void setChunkBiome(Island island, Biome biome, Chunk chunk) { + //location.getWorld().loadChunk(chunk); + for(int xx = 0; xx < 16; xx++){ + for(int zz = 0; zz < 16; zz++){ + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_15)){ + for(int y = 0; y<256; y++){ + chunk.getBlock(xx, y, zz).setBiome(biome); + } + } else { + chunk.getBlock(xx, 128, zz).setBiome(biome); + } + } + } + + updateBiomePacket(island, chunk); + } + private Class packetPlayOutMapChunkClass; private Class chunkClass; - private void updateBiome(Island island, Chunk chunk) { + private void updateBiomePacket(Island island, Chunk chunk) { if (packetPlayOutMapChunkClass == null) { packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk"); chunkClass = NMSUtil.getNMSClass("Chunk"); From f6d6059ad62ec688cc74fff8d94949996892c6a6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 19:06:51 +0200 Subject: [PATCH 078/366] Simplify --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index caf93a35..82b4ad5b 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -558,7 +558,7 @@ public class IslandManager { } } - if (skyblock.isPaper() && Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false)) { + if (skyblock.isPaperAsync()) { Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { startDeletition(island, worldManager); }); @@ -666,7 +666,7 @@ public class IslandManager { ChunkUtil chunks = new ChunkUtil(); - if (skyblock.isPaper() && Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false)) { + if (skyblock.isPaperAsync()) { chunks.getChunksToScan(island, worldList, true); Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { List positions = new LinkedList<>(); From bbe39cf52c364ab792e09fd8ece90846d60309d7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 22 Jun 2020 21:33:17 +0200 Subject: [PATCH 079/366] Use PaperLib for teleport and optimize other Paper hooks --- .../commands/island/TeleportCommand.java | 3 ++- .../skyblock/island/IslandManager.java | 21 +++++++------------ .../com/songoda/skyblock/listeners/Join.java | 3 ++- .../com/songoda/skyblock/listeners/Move.java | 3 ++- .../songoda/skyblock/listeners/Portal.java | 7 +++++-- .../skyblock/utils/world/LocationUtil.java | 3 ++- 6 files changed, 20 insertions(+), 20 deletions(-) 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 727d37d1..aecf938a 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 @@ -14,6 +14,7 @@ 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 io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -111,7 +112,7 @@ public class TeleportCommand extends SubCommand { Bukkit.getServer().getScheduler().runTask(skyblock, () -> { Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); LocationUtil.removeWaterFromLoc(skyblock, loc); - player.teleport(loc); + PaperLib.teleportAsync(player, loc); if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ player.setFallDistance(0.0F); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 82b4ad5b..966ff74a 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -41,6 +41,7 @@ import com.songoda.skyblock.utils.world.WorldBorder; import com.songoda.skyblock.utils.world.block.BlockDegreesType; import com.songoda.skyblock.visit.VisitManager; import com.songoda.skyblock.world.WorldManager; +import io.papermc.lib.PaperLib; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; @@ -269,7 +270,7 @@ public class IslandManager { } Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, () -> { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); + PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); player.setFallDistance(0.0F); }, configLoad.getInt("Island.Creation.TeleportTimeout") * 20); @@ -336,7 +337,7 @@ public class IslandManager { Bukkit.getScheduler().callSyncMethod(SkyBlock.getInstance(), () -> { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island)); + PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Island)); player.setGameMode(GameMode.SPECTATOR); return true; }); @@ -344,7 +345,7 @@ public class IslandManager { Bukkit.getScheduler().runTaskLater(skyblock, () -> { if (data.isPreview()) { Location spawn = fileManager.getLocation(fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")), "Location.Spawn", true); - player.teleport(spawn); + PaperLib.teleportAsync(player, spawn); player.setGameMode(GameMode.SURVIVAL); data.setIsland(null); islandStorage.remove(player.getUniqueId(), island); @@ -558,15 +559,7 @@ public class IslandManager { } } - if (skyblock.isPaperAsync()) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - startDeletition(island, worldManager); - }); - } else { - startDeletition(island, worldManager); - } - - + startDeletition(island, worldManager); skyblock.getVisitManager().deleteIsland(island.getOwnerUUID()); skyblock.getBanManager().deleteIsland(island.getOwnerUUID()); @@ -1113,7 +1106,7 @@ public class IslandManager { if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); if(loc != null){ - player.teleport(loc); + PaperLib.teleportAsync(player, loc); if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ player.setFallDistance(0.0F); } @@ -1153,7 +1146,7 @@ public class IslandManager { loc = LocationUtil.getSafeLocation(loc); } if(loc != null){ - player.teleport(loc); + PaperLib.teleportAsync(player, loc); if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ player.setFallDistance(0.0F); } diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index 0b3883dd..82a702a3 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -14,6 +14,7 @@ import com.songoda.skyblock.scoreboard.Scoreboard; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.usercache.UserCacheManager; import com.songoda.skyblock.utils.world.LocationUtil; +import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; @@ -60,7 +61,7 @@ public class Join implements Listener { if (configLoad.getBoolean("Island.Join.Spawn")) { LocationUtil.teleportPlayerToSpawn(player); } else if (configLoad.getBoolean("Island.Join.Island") && island != null) { - player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); + PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); player.setFallDistance(0.0F); teleportedToIsland = true; } diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index ff9f5c44..77d00779 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -14,6 +14,7 @@ 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 io.papermc.lib.PaperLib; import org.bukkit.*; import org.bukkit.attribute.Attribute; import org.bukkit.block.data.Waterlogged; @@ -209,7 +210,7 @@ public class Move implements Listener { } } if(loc != null){ - player.teleport(loc); + PaperLib.teleportAsync(player, loc); } else { LocationUtil.teleportPlayerToSpawn(player); player.sendMessage(ChatColor.translateAlternateColorCodes('&', diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index d7001f1a..9276d87a 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -15,6 +15,7 @@ import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; +import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; @@ -25,6 +26,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.player.PlayerMoveEvent; +import java.awt.print.Paper; import java.io.File; import java.util.HashMap; import java.util.Map; @@ -142,7 +144,8 @@ public class Portal implements Listener { default: IslandWorld toWorldF = toWorld; - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L); + + Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> PaperLib.teleportAsync(player, island.getLocation(toWorldF, spawnEnvironment)), 1L); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); player.setFallDistance(0.0F); tick.setTick(1); @@ -166,7 +169,7 @@ public class Portal implements Listener { if(safeLoc != null){ loc = safeLoc; } - player.teleport(loc); + PaperLib.teleportAsync(player, loc); }, 1L); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); player.setFallDistance(0.0F); 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 c2a4429f..a8c645e2 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -12,6 +12,7 @@ import com.songoda.skyblock.utils.math.VectorUtil; import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.block.BlockDegreesType; import com.songoda.skyblock.world.WorldManager; +import io.papermc.lib.PaperLib; import org.bukkit.*; import org.bukkit.World.Environment; import org.bukkit.block.Block; @@ -301,7 +302,7 @@ public final class LocationUtil { } Bukkit.getServer().getScheduler().runTask(skyblock, () -> { - player.teleport(spawnLocation); + PaperLib.teleportAsync(player, spawnLocation); player.setFallDistance(0.0F); }); } From 43925eddcf0f7293e35c46bdc50fa7c40c83f545 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 23 Jun 2020 05:43:17 +0200 Subject: [PATCH 080/366] Disabled void biome --- src/main/resources/biomes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/biomes.yml b/src/main/resources/biomes.yml index 8ecc6bc8..d4a01b8f 100644 --- a/src/main/resources/biomes.yml +++ b/src/main/resources/biomes.yml @@ -464,7 +464,7 @@ Biomes: Permission: true Normal: false Nether: false - End: true + End: false WARM_OCEAN: DisplayName: 'Warm Ocean' Permission: true From e689218228e2156c1156cd5b994f552c476cce18 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 23 Jun 2020 05:43:35 +0200 Subject: [PATCH 081/366] Initial work on Chunk loading update --- .../java/com/songoda/skyblock/SkyBlock.java | 1 + .../songoda/skyblock/biome/BiomeManager.java | 125 ++++++++++++++---- .../skyblock/biome/ChunkBiomeSplitter.java | 85 ++++++++++++ .../skyblock/blockscanner/BlockScanner.java | 32 +++-- .../skyblock/blockscanner/ChunkLoader.java | 101 ++++++++++++++ .../skyblock/island/IslandManager.java | 40 +++--- .../island/removal/ChunkDeleteSplitter.java | 2 +- .../songoda/skyblock/levelling/ChunkUtil.java | 48 ------- .../skyblock/levelling/rework/IslandScan.java | 27 ++-- 9 files changed, 338 insertions(+), 123 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java create mode 100644 src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java delete mode 100644 src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 7dbf9973..dd827ecf 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -116,6 +116,7 @@ public class SkyBlock extends SongodaPlugin { Class.forName("com.destroystokyo.paper.PaperConfig"); paper = true; paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); + paperAsync = false; this.getLogger().info("Enabling Paper hooks"); } catch (ClassNotFoundException ignored) { PaperLib.suggestPaper(this); diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index ac917c05..a4bbcea4 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -5,15 +5,15 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; +import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.utils.version.NMSUtil; -import io.papermc.lib.PaperLib; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.Location; +import org.bukkit.*; import org.bukkit.block.Biome; import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; +import java.util.*; +import java.util.concurrent.CompletableFuture; public class BiomeManager { @@ -27,6 +27,52 @@ public class BiomeManager { Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island); int radius = (int) Math.ceil(island.getRadius()); + final List snapshotList = new ArrayList<>(3); + + if (location == null) return; + + final World world = location.getWorld(); + + + new ChunkLoader(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncPositions, syncPositions) -> { + if (skyblock.isPaperAsync()) { + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + List positions = new LinkedList<>(); + for (CompletableFuture chunk : asyncPositions) { + positions.add(chunk.join()); + } + for(Chunk chunk : positions){ + setChunkBiome(biome, chunk); + updateBiomePacket(island, chunk); + } + //positions.stream().map(Chunk::getChunkSnapshot).forEach(snapshotList::add); + }); + + //Map> snapshots = new HashMap<>(3); + //snapshots.put(world, snapshotList); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + //ChunkBiomeSplitter.startUpdating(snapshots, biome, (chunk) -> { + // updateBiomePacket(island, chunk); + //}); + + }); + } else { + //syncPositions.stream().map(Chunk::getChunkSnapshot).forEach(snapshotList::add); + + //Map> snapshots = new HashMap<>(3); + //snapshots.put(world, snapshotList); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + //ChunkBiomeSplitter.startUpdating(snapshots, biome, (chunk) -> { + // updateBiomePacket(island, chunk); + //}); + for(Chunk chunk : syncPositions){ + setChunkBiome(biome, chunk); + updateBiomePacket(island, chunk); + } + }); + } + }); + /*Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) { for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) { @@ -42,33 +88,56 @@ public class BiomeManager { } }); });*/ + /*Bukkit.getScheduler().runTask(skyblock, () -> { + List chunks = new ArrayList<>(); - - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - long i = 0; - for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) { - for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) { - int finalX = x; - int finalZ = z; - - if(skyblock.isPaperAsync()){ - PaperLib.getChunkAtAsync(location.getWorld(), finalX >> 4, finalZ >> 4).thenAccept(chunk -> { - setChunkBiome(island, biome, chunk); - }); - } else { - Bukkit.getScheduler().runTaskLater(skyblock, () -> { - Chunk chunk = location.getWorld().getChunkAt(finalX >> 4, finalZ >> 4); - setChunkBiome(island, biome, chunk); - }, i); - i++; + if(skyblock.isPaperAsync()){ + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) { + for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) { + try { + Chunk chunk = PaperLib.getChunkAtAsync(location.getWorld(), x >> 4, z >> 4).get(); + setChunkBiome(biome, chunk); + chunks.add(chunk); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } } - } - } - }); + Bukkit.getScheduler().runTask(skyblock, () -> { + for(Chunk chunk : chunks){ + updateBiomePacket(island, chunk); + } + }); + }); + } else { + int x = location.getBlockX() - radius; + Bukkit.getScheduler().runTaskTimer(skyblock, () -> { + }, 2L, 2L); + while (x < location.getBlockX() + radius) { + int z = location.getBlockZ() - radius; + while (z < location.getBlockZ() + radius) { + chunks.add(location.getWorld().getChunkAt(x >> 4, z >> 4)); + z += 16; + } + x += 16; + } + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + for(Chunk chunk : chunks){ + setChunkBiome(biome, chunk); + } + Bukkit.getScheduler().runTask(skyblock, () -> { + for(Chunk chunk : chunks){ + updateBiomePacket(island, chunk); + } + }); + }); + } + });*/ } - private void setChunkBiome(Island island, Biome biome, Chunk chunk) { + private void setChunkBiome(Biome biome, Chunk chunk) { //location.getWorld().loadChunk(chunk); for(int xx = 0; xx < 16; xx++){ for(int zz = 0; zz < 16; zz++){ @@ -77,12 +146,10 @@ public class BiomeManager { chunk.getBlock(xx, y, zz).setBiome(biome); } } else { - chunk.getBlock(xx, 128, zz).setBiome(biome); + chunk.getBlock(xx, 0, zz).setBiome(biome); } } } - - updateBiomePacket(island, chunk); } private Class packetPlayOutMapChunkClass; diff --git a/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java b/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java new file mode 100644 index 00000000..08419927 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java @@ -0,0 +1,85 @@ +package com.songoda.skyblock.biome; + +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.blockscanner.BlockInfo; +import com.songoda.skyblock.blockscanner.BlockScanner; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.ChunkSnapshot; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.block.Block; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.CompletableFuture; + +public class ChunkBiomeSplitter extends BukkitRunnable { + + private final Map> snapshots; + private Queue blocks; + private final Biome biome; + private Chunk lastChunk; + private ChunkBiomeTask task; + + private ChunkBiomeSplitter(Map> snapshots, Biome biome, ChunkBiomeTask task) { + this.task = task; + this.snapshots = snapshots; + this.biome = biome; + lastChunk = null; + start(); + } + + private void start() { + Bukkit.getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> { + BlockScanner.startScanner(snapshots, true, true, true, (blocks) -> { + this.blocks = blocks; + this.runTaskTimer(SkyBlock.getInstance(), 2L, 2L); + }); + }); + } + + @Override + public void run() { + + int updateAmount = 0; + + for (Iterator it = blocks.iterator(); it.hasNext();) { + + if (updateAmount == 3500) break; + + final BlockInfo pair = it.next(); + final Block block = pair.getWorld().getBlockAt(pair.getX(), pair.getY(), pair.getZ()); + + if(!block.getChunk().equals(lastChunk)){ + lastChunk = block.getChunk(); + task.onChunkComplete(lastChunk); + } + + block.setBiome(biome); + + updateAmount++; + it.remove(); + } + + Bukkit.broadcastMessage("Amount: " + blocks.size() + " Empty: " + blocks.isEmpty()); + + if (blocks.isEmpty()) { + super.cancel(); + } + } + + public static void startUpdating(Map> snapshots, Biome biome, ChunkBiomeTask task) { + new ChunkBiomeSplitter(snapshots, biome, task); + } + + public interface ChunkBiomeTask { + + void onChunkComplete(Chunk chunk); + + } + +} diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index 09605c30..4caf43c3 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -59,9 +59,12 @@ public final class BlockScanner extends BukkitRunnable { private final Queue blocks; private final ScannerTasks tasks; - private int scanY; + private boolean ignoreLiquids; + private boolean ignoreAir; - private BlockScanner(Map> snapshots, ScannerTasks tasks) { + private BlockScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + this.ignoreLiquids = ignoreLiquids; + this.ignoreAir = ignoreAir; this.blocks = new ConcurrentLinkedQueue<>(); this.tasks = tasks; @@ -92,8 +95,15 @@ public final class BlockScanner extends BukkitRunnable { final ConfigurationSection liquidSection = config.getConfigurationSection("Island.World." + env + ".Liquid"); + int startY; + if(ignoreY){ + startY = 255; + } else { + startY = !ignoreLiquids && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0; + } + for (List sub : parts) { - queueWork(world, liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0, sub); + queueWork(world, startY, sub); } } @@ -102,8 +112,6 @@ public final class BlockScanner extends BukkitRunnable { } private void queueWork(World world, int scanY, List subList) { - - Bukkit.getServer().getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> { for (ChunkSnapshot shot : subList) { @@ -119,7 +127,13 @@ public final class BlockScanner extends BukkitRunnable { ? shot.getBlockType(x, y, z) : MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z))); - if (type == null || type == CompatibleMaterial.AIR || type == CompatibleMaterial.WATER) continue; + if(type == null){ + continue; + } else if(type.equals(CompatibleMaterial.AIR) && ignoreAir){ + continue; + } else if(type.equals(CompatibleMaterial.WATER) && ignoreLiquids){ + continue; + } blocks.add(new BlockInfo(world, x + (cX), y, z + (cZ))); } @@ -147,17 +161,17 @@ public final class BlockScanner extends BukkitRunnable { cancel(); } - public static void startScanner(Map> snapshots, ScannerTasks tasks) { + public static void startScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null"); if (tasks == null) throw new IllegalArgumentException("tasks cannot be null"); - final BlockScanner scanner = new BlockScanner(snapshots, tasks); + final BlockScanner scanner = new BlockScanner(snapshots, ignoreLiquids, ignoreAir, ignoreY, tasks); scanner.runTaskTimer(SkyBlock.getInstance(), 5, 5); } - public static interface ScannerTasks { + public interface ScannerTasks { void onComplete(Queue blocks); diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java new file mode 100644 index 00000000..e93099be --- /dev/null +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -0,0 +1,101 @@ +package com.songoda.skyblock.blockscanner; + +import com.sk89q.worldedit.bukkit.paperlib.PaperLib; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandEnvironment; +import com.songoda.skyblock.island.IslandWorld; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class ChunkLoader extends BukkitRunnable { + public final List> asyncPositions = new LinkedList<>(); + public final List syncPositions = new LinkedList<>(); + + private ChunkScannerTask generalTask; + private ChunkForChunkScannerTask chunkTask; + private final boolean paper; + private World world; + private int x; + private int z; + private int minZ; + private int maxX; + private int maxZ; + + private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk) { + this.paper = paper; + Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island); + + if (islandLocation == null) return; + + world = islandLocation.getWorld(); + + Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius()); + Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius()); + + int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()); + minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()); + + maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()); + maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()); + + x = minX; + z = minZ; + + // TODO Paper + this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L); + } + + @Override + public void run() { + for(int i = 0; i < 50; i++){ // TODO Config for chunk per tick + if(x < maxX){ + if(z < maxZ){ + if(paper){ + asyncPositions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); + } else { + syncPositions.add(world.getChunkAt(x >> 4, z >> 4)); + } + + z += 16; + } else { + z = minZ; + x += 16; + } + } else { + if(generalTask != null) { + generalTask.onComplete(asyncPositions, syncPositions); + } + this.cancel(); + } + } + Bukkit.broadcastMessage("Async: " + asyncPositions.size() + " Sync: " + syncPositions.size()); + } + + public static void startChunkLoading(Island island, IslandWorld islandWorld, boolean paper, ChunkScannerTask task){ + new ChunkLoader(island, islandWorld, paper, false); + } + + public static void startChunkLoadingPerChunk(Island island, IslandWorld islandWorld, boolean paper, ChunkForChunkScannerTask task){ + new ChunkLoader(island, islandWorld, paper, true); + } + + public interface ChunkScannerTask { + + void onComplete(List> asyncChunks, List syncChunks); + + } + + public interface ChunkForChunkScannerTask { + + void onChunkComplete(CompletableFuture asyncChunks, List syncChunks); + + } +} diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 966ff74a..fd2ab4a8 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1,7 +1,6 @@ package com.songoda.skyblock.island; import com.bekvon.bukkit.residence.Residence; -import com.bekvon.bukkit.residence.api.ResidenceApi; import com.bekvon.bukkit.residence.containers.Flags; import com.bekvon.bukkit.residence.protection.ClaimedResidence; import com.google.common.base.Preconditions; @@ -18,7 +17,7 @@ import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.invite.Invite; import com.songoda.skyblock.invite.InviteManager; import com.songoda.skyblock.island.removal.ChunkDeleteSplitter; -import com.songoda.skyblock.levelling.ChunkUtil; +import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; @@ -53,7 +52,6 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; import java.io.File; import java.io.IOException; @@ -559,7 +557,7 @@ public class IslandManager { } } - startDeletition(island, worldManager); + startDeletion(island, worldManager); skyblock.getVisitManager().deleteIsland(island.getOwnerUUID()); skyblock.getBanManager().deleteIsland(island.getOwnerUUID()); @@ -645,7 +643,7 @@ public class IslandManager { return true; } - private void startDeletition(Island island, WorldManager worldManager) { + private void startDeletion(Island island, WorldManager worldManager) { final Map> snapshots = new HashMap<>(3); for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { @@ -656,27 +654,25 @@ public class IslandManager { final World world = worldManager.getWorld(worldList); - ChunkUtil chunks = new ChunkUtil(); - - - if (skyblock.isPaperAsync()) { - chunks.getChunksToScan(island, worldList, true); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - List positions = new LinkedList<>(); - for (CompletableFuture chunk : chunks.asyncPositions) { - positions.add(chunk.join()); + new ChunkLoader(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncPositions, syncPositions) -> { + if(skyblock.isPaperAsync()){ + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + List positions = new LinkedList<>(); + for (CompletableFuture chunk : asyncPositions) { + positions.add(chunk.join()); + } snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); - } - }); - } else { - chunks.getChunksToScan(island, worldList, false); - final List list = chunks.syncPositions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); + ChunkDeleteSplitter.startDeletion(snapshots); + }); + } else { + final List list = syncPositions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); - snapshots.put(world, list); - } + snapshots.put(world, list); + ChunkDeleteSplitter.startDeletion(snapshots); + } + }); } - ChunkDeleteSplitter.startDeletion(snapshots); } public synchronized void deleteIslandData(UUID uuid) { diff --git a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java index dfe83160..ef0a210e 100644 --- a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java +++ b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java @@ -27,7 +27,7 @@ public class ChunkDeleteSplitter extends BukkitRunnable { } private void start() { - BlockScanner.startScanner(snapshots, (blocks) -> { + BlockScanner.startScanner(snapshots, false, false, (blocks) -> { this.blocks = blocks; this.runTaskTimer(SkyBlock.getInstance(), 20, 20); }); diff --git a/src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java b/src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java deleted file mode 100644 index 45472a36..00000000 --- a/src/main/java/com/songoda/skyblock/levelling/ChunkUtil.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.songoda.skyblock.levelling; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import com.sk89q.worldedit.bukkit.paperlib.PaperLib; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.World; - -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandEnvironment; -import com.songoda.skyblock.island.IslandWorld; - -public class ChunkUtil { - public final List> asyncPositions = new LinkedList<>(); - public final List syncPositions = new LinkedList<>(); - - public void getChunksToScan(Island island, IslandWorld islandWorld, boolean paper) { - Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island); - - if (islandLocation == null) return; - - World world = islandLocation.getWorld(); - - Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius()); - Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius()); - - int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()); - int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()); - - int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()); - int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()); - - - for (int x = minX; x < maxX + 16; x += 16) { - for (int z = minZ; z < maxZ + 16; z += 16) { - if(paper){ - asyncPositions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); - } else { - syncPositions.add(world.getChunkAt(x >> 4, z >> 4)); - } - } - } - } -} diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java index 2bd573d0..77b23bb1 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java @@ -8,7 +8,7 @@ import com.songoda.skyblock.blockscanner.BlockScanner; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandWorld; -import com.songoda.skyblock.levelling.ChunkUtil; +import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.levelling.rework.amount.AmountMaterialPair; import com.songoda.skyblock.levelling.rework.amount.BlockAmount; import com.songoda.skyblock.message.MessageManager; @@ -69,7 +69,7 @@ public final class IslandScan extends BukkitRunnable { if (hasNether) populate(snapshots, IslandWorld.Nether, true); if (hasEnd) populate(snapshots, IslandWorld.End, true); - BlockScanner.startScanner(snapshots, (blocks) -> { + BlockScanner.startScanner(snapshots, false, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); @@ -81,7 +81,7 @@ public final class IslandScan extends BukkitRunnable { if (hasNether) populate(snapshots, IslandWorld.Nether, false); if (hasEnd) populate(snapshots, IslandWorld.End, false); - BlockScanner.startScanner(snapshots, (blocks) -> { + BlockScanner.startScanner(snapshots, false, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); @@ -182,18 +182,17 @@ public final class IslandScan extends BukkitRunnable { final SkyBlock skyblock = SkyBlock.getInstance(); - ChunkUtil chunks = new ChunkUtil(); - chunks.getChunksToScan(island, world, paper); - - if(paper){ - List positions = new LinkedList<>(); - for(CompletableFuture chunk : chunks.asyncPositions){ - positions.add(chunk.join().getChunkSnapshot()); + new ChunkLoader(island, IslandWorld.Normal, paper, (asyncPositions, syncPositions) -> { + if(paper){ + List positions = new LinkedList<>(); + for(CompletableFuture chunk : asyncPositions){ + positions.add(chunk.join().getChunkSnapshot()); + } + snapshots.put(skyblock.getWorldManager().getWorld(world), positions); + } else { + snapshots.put(skyblock.getWorldManager().getWorld(world), syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); } - snapshots.put(skyblock.getWorldManager().getWorld(world), positions); - } else { - snapshots.put(skyblock.getWorldManager().getWorld(world), chunks.syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); - } + }); } public Set getDoubleBlocks() { From 8631b3b5cd3617f918c187162ce35e452987fdf0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 23 Jun 2020 17:52:10 +0200 Subject: [PATCH 082/366] Chunk loading rewrite --- .../java/com/songoda/skyblock/SkyBlock.java | 1 - .../songoda/skyblock/biome/BiomeManager.java | 126 ++---------------- .../skyblock/blockscanner/ChunkLoader.java | 71 ++++++++-- .../skyblock/island/IslandManager.java | 24 +++- .../island/removal/ChunkDeleteSplitter.java | 2 +- .../skyblock/levelling/rework/IslandScan.java | 65 ++++++--- 6 files changed, 138 insertions(+), 151 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index dd827ecf..7dbf9973 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -116,7 +116,6 @@ public class SkyBlock extends SongodaPlugin { Class.forName("com.destroystokyo.paper.PaperConfig"); paper = true; paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); - paperAsync = false; this.getLogger().info("Enabling Paper hooks"); } catch (ClassNotFoundException ignored) { PaperLib.suggestPaper(this); diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index a4bbcea4..eec7b5d0 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -1,6 +1,5 @@ package com.songoda.skyblock.biome; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; @@ -12,8 +11,6 @@ import org.bukkit.block.Biome; import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.concurrent.CompletableFuture; public class BiomeManager { @@ -25,129 +22,32 @@ public class BiomeManager { public void setBiome(Island island, Biome biome) { Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island); - int radius = (int) Math.ceil(island.getRadius()); - - final List snapshotList = new ArrayList<>(3); if (location == null) return; - final World world = location.getWorld(); - - - new ChunkLoader(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncPositions, syncPositions) -> { - if (skyblock.isPaperAsync()) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - List positions = new LinkedList<>(); - for (CompletableFuture chunk : asyncPositions) { - positions.add(chunk.join()); - } - for(Chunk chunk : positions){ - setChunkBiome(biome, chunk); - updateBiomePacket(island, chunk); - } - //positions.stream().map(Chunk::getChunkSnapshot).forEach(snapshotList::add); - }); - - //Map> snapshots = new HashMap<>(3); - //snapshots.put(world, snapshotList); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - //ChunkBiomeSplitter.startUpdating(snapshots, biome, (chunk) -> { - // updateBiomePacket(island, chunk); - //}); - - }); - } else { - //syncPositions.stream().map(Chunk::getChunkSnapshot).forEach(snapshotList::add); - - //Map> snapshots = new HashMap<>(3); - //snapshots.put(world, snapshotList); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - //ChunkBiomeSplitter.startUpdating(snapshots, biome, (chunk) -> { - // updateBiomePacket(island, chunk); - //}); - for(Chunk chunk : syncPositions){ - setChunkBiome(biome, chunk); - updateBiomePacket(island, chunk); - } - }); - } + if(skyblock.isPaperAsync()){ + // We keep it sequentially in order to use less RAM + ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { + Chunk chunk = asyncChunk.join(); + setChunkBiome(biome, chunk); + updateBiomePacket(island, chunk); }); - - /*Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) { - for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) { - location.getWorld().setBiome(x, z, biome); - } - } - Bukkit.getScheduler().runTask(skyblock, () -> { - for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) { - for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) { - Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4); - updateBiome(island, chunk); - } - } - }); - });*/ - /*Bukkit.getScheduler().runTask(skyblock, () -> { - List chunks = new ArrayList<>(); - - if(skyblock.isPaperAsync()){ + } else { + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) { - for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) { - try { - Chunk chunk = PaperLib.getChunkAtAsync(location.getWorld(), x >> 4, z >> 4).get(); - setChunkBiome(biome, chunk); - chunks.add(chunk); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - } - Bukkit.getScheduler().runTask(skyblock, () -> { - for(Chunk chunk : chunks){ - updateBiomePacket(island, chunk); - } - }); - }); - } else { - int x = location.getBlockX() - radius; - Bukkit.getScheduler().runTaskTimer(skyblock, () -> { - - }, 2L, 2L); - while (x < location.getBlockX() + radius) { - int z = location.getBlockZ() - radius; - while (z < location.getBlockZ() + radius) { - chunks.add(location.getWorld().getChunkAt(x >> 4, z >> 4)); - z += 16; - } - x += 16; - } - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - for(Chunk chunk : chunks){ + syncChunks.forEach(chunk -> { setChunkBiome(biome, chunk); - } - Bukkit.getScheduler().runTask(skyblock, () -> { - for(Chunk chunk : chunks){ - updateBiomePacket(island, chunk); - } + updateBiomePacket(island, chunk); }); }); - } - });*/ + }); + } } private void setChunkBiome(Biome biome, Chunk chunk) { - //location.getWorld().loadChunk(chunk); for(int xx = 0; xx < 16; xx++){ for(int zz = 0; zz < 16; zz++){ - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_15)){ - for(int y = 0; y<256; y++){ - chunk.getBlock(xx, y, zz).setBiome(biome); - } - } else { - chunk.getBlock(xx, 0, zz).setBiome(biome); - } + chunk.getBlock(xx, 0, zz).setBiome(biome); } } } diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java index e93099be..1e15191c 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -21,7 +21,8 @@ public class ChunkLoader extends BukkitRunnable { private ChunkScannerTask generalTask; private ChunkForChunkScannerTask chunkTask; - private final boolean paper; + private boolean chunkForChunk; + private boolean paper; private World world; private int x; private int z; @@ -29,7 +30,9 @@ public class ChunkLoader extends BukkitRunnable { private int maxX; private int maxZ; - private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk) { + private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkForChunkScannerTask chunkTask) { + this.chunkTask = chunkTask; + this.chunkForChunk = chunkForChunk; this.paper = paper; Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island); @@ -49,19 +52,63 @@ public class ChunkLoader extends BukkitRunnable { x = minX; z = minZ; - // TODO Paper - this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L); + if(paper){ + this.runTaskAsynchronously(SkyBlock.getInstance()); + } else { + this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L); + } + } + + private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkScannerTask generalTask) { + this.generalTask = generalTask; + this.chunkForChunk = chunkForChunk; + this.paper = paper; + Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island); + + if (islandLocation == null) return; + + world = islandLocation.getWorld(); + + Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius()); + Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius()); + + int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()); + minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()); + + maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()); + maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()); + + x = minX; + z = minZ; + + if(paper){ + this.runTaskAsynchronously(SkyBlock.getInstance()); + } else { + this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L); + } } @Override public void run() { - for(int i = 0; i < 50; i++){ // TODO Config for chunk per tick + for(int i = 0; i < 50 || paper; i++){ // TODO Config for chunk per tick if(x < maxX){ if(z < maxZ){ - if(paper){ - asyncPositions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); + if(!chunkForChunk){ + if(paper){ + asyncPositions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); + } else { + syncPositions.add(world.getChunkAt(x >> 4, z >> 4)); + } } else { - syncPositions.add(world.getChunkAt(x >> 4, z >> 4)); + if(paper){ + if(chunkTask != null) { + chunkTask.onChunkComplete(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4), null); + } + } else { + if(chunkTask != null) { + chunkTask.onChunkComplete(null, world.getChunkAt(x >> 4, z >> 4)); + } + } } z += 16; @@ -74,17 +121,17 @@ public class ChunkLoader extends BukkitRunnable { generalTask.onComplete(asyncPositions, syncPositions); } this.cancel(); + return; } } - Bukkit.broadcastMessage("Async: " + asyncPositions.size() + " Sync: " + syncPositions.size()); } public static void startChunkLoading(Island island, IslandWorld islandWorld, boolean paper, ChunkScannerTask task){ - new ChunkLoader(island, islandWorld, paper, false); + new ChunkLoader(island, islandWorld, paper, false, task); } public static void startChunkLoadingPerChunk(Island island, IslandWorld islandWorld, boolean paper, ChunkForChunkScannerTask task){ - new ChunkLoader(island, islandWorld, paper, true); + new ChunkLoader(island, islandWorld, paper, true, task); } public interface ChunkScannerTask { @@ -95,7 +142,7 @@ public class ChunkLoader extends BukkitRunnable { public interface ChunkForChunkScannerTask { - void onChunkComplete(CompletableFuture asyncChunks, List syncChunks); + void onChunkComplete(CompletableFuture asyncChunk, Chunk syncChunk); } } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index fd2ab4a8..7eed545d 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -654,7 +654,27 @@ public class IslandManager { final World world = worldManager.getWorld(worldList); - new ChunkLoader(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncPositions, syncPositions) -> { + if(skyblock.isPaperAsync()){ + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { + List positions = new LinkedList<>(); + for (CompletableFuture chunk : asyncChunks) { + positions.add(chunk.join()); + } + snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); + ChunkDeleteSplitter.startDeletion(snapshots); + }); + } else { + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { + Bukkit.getScheduler().runTask(skyblock, () -> { + final List list = syncChunks.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); + + snapshots.put(world, list); + ChunkDeleteSplitter.startDeletion(snapshots); + }); + }); + } + + /*new ChunkLoader(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncPositions, syncPositions) -> { if(skyblock.isPaperAsync()){ Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { List positions = new LinkedList<>(); @@ -670,7 +690,7 @@ public class IslandManager { snapshots.put(world, list); ChunkDeleteSplitter.startDeletion(snapshots); } - }); + });*/ } } diff --git a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java index ef0a210e..1c3f7491 100644 --- a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java +++ b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java @@ -27,7 +27,7 @@ public class ChunkDeleteSplitter extends BukkitRunnable { } private void start() { - BlockScanner.startScanner(snapshots, false, false, (blocks) -> { + BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { this.blocks = blocks; this.runTaskTimer(SkyBlock.getInstance(), 20, 20); }); diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java index 77b23bb1..06d5b3c8 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java @@ -65,32 +65,48 @@ public final class IslandScan extends BukkitRunnable { if (skyblock.isPaperAsync()) { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - populate(snapshots, IslandWorld.Normal, true); - if (hasNether) populate(snapshots, IslandWorld.Nether, true); - if (hasEnd) populate(snapshots, IslandWorld.End, true); + initScan(skyblock, hasNether, hasEnd, snapshots); + }); + } else { + initScan(skyblock, hasNether, hasEnd, snapshots); + } - BlockScanner.startScanner(snapshots, false, false, (blocks) -> { + + return this; + } + + private void initScan(SkyBlock skyblock, boolean hasNether, boolean hasEnd, Map> snapshots) { + populate(snapshots, IslandWorld.Normal, skyblock.isPaperAsync(), () -> { + + if (hasNether) { + populate(snapshots, IslandWorld.Nether, skyblock.isPaperAsync(), () -> { + if (hasEnd) { + populate(snapshots, IslandWorld.End, skyblock.isPaperAsync(), () -> { + BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + this.blocks = blocks; + this.blocksSize = blocks.size(); + this.runTaskTimer(SkyBlock.getInstance(), 20, 20); + + }); + }); + } else { + BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + this.blocks = blocks; + this.blocksSize = blocks.size(); + this.runTaskTimer(SkyBlock.getInstance(), 20, 20); + + }); + } + }); + } else { + BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); }); - }); - } else { - populate(snapshots, IslandWorld.Normal, false); - if (hasNether) populate(snapshots, IslandWorld.Nether, false); - if (hasEnd) populate(snapshots, IslandWorld.End, false); - - BlockScanner.startScanner(snapshots, false, false, (blocks) -> { - this.blocks = blocks; - this.blocksSize = blocks.size(); - this.runTaskTimer(SkyBlock.getInstance(), 20, 20); - - }); - } - - - return this; + } + }); } private void finalizeBlocks() { @@ -178,11 +194,11 @@ public final class IslandScan extends BukkitRunnable { }); } - private void populate(Map> snapshots, IslandWorld world, boolean paper) { + private void populate(Map> snapshots, IslandWorld world, boolean paper, PopulateTask task) { final SkyBlock skyblock = SkyBlock.getInstance(); - new ChunkLoader(island, IslandWorld.Normal, paper, (asyncPositions, syncPositions) -> { + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, paper, (asyncPositions, syncPositions) -> { if(paper){ List positions = new LinkedList<>(); for(CompletableFuture chunk : asyncPositions){ @@ -192,9 +208,14 @@ public final class IslandScan extends BukkitRunnable { } else { snapshots.put(skyblock.getWorldManager().getWorld(world), syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); } + task.onComplete(); }); } + private interface PopulateTask { + void onComplete(); + } + public Set getDoubleBlocks() { return doubleBlocks; } From 5648f5ea48cbed0b8c2ff87fda4c3741c1f64134 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 23 Jun 2020 18:00:24 +0200 Subject: [PATCH 083/366] Simplified some code --- .../songoda/skyblock/biome/BiomeManager.java | 19 ++++++++++--------- .../skyblock/island/IslandManager.java | 18 ------------------ 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index eec7b5d0..633aa308 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.biome; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; @@ -61,19 +62,19 @@ public class BiomeManager { chunkClass = NMSUtil.getNMSClass("Chunk"); } - for (Player all : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) { + for (Player player : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) { try { - if (NMSUtil.getVersionNumber() < 9) { - NMSUtil.sendPacket(all, + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { + NMSUtil.sendPacket(player, + packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(player + .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk), + 65535)); + } else { + NMSUtil.sendPacket(player, packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class) - .newInstance(all.getLocation().getChunk().getClass().getMethod("getHandle") + .newInstance(player.getLocation().getChunk().getClass().getMethod("getHandle") .invoke(chunk), true, 20)); - return; } - NMSUtil.sendPacket(all, - packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(all - .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk), - 65535)); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 7eed545d..87bd9195 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -673,24 +673,6 @@ public class IslandManager { }); }); } - - /*new ChunkLoader(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncPositions, syncPositions) -> { - if(skyblock.isPaperAsync()){ - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - List positions = new LinkedList<>(); - for (CompletableFuture chunk : asyncPositions) { - positions.add(chunk.join()); - } - snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); - ChunkDeleteSplitter.startDeletion(snapshots); - }); - } else { - final List list = syncPositions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); - - snapshots.put(world, list); - ChunkDeleteSplitter.startDeletion(snapshots); - } - });*/ } } From 34597b2009879d82d2178dab94ac7719e8be9887 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 23 Jun 2020 18:39:35 +0200 Subject: [PATCH 084/366] ChunkPerTick config option --- .../songoda/skyblock/blockscanner/ChunkLoader.java | 13 +++++++++++-- src/main/resources/config.yml | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java index 1e15191c..2734e2c0 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -5,12 +5,12 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; -import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.scheduler.BukkitRunnable; +import java.io.File; import java.util.LinkedList; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -29,8 +29,13 @@ public class ChunkLoader extends BukkitRunnable { private int minZ; private int maxX; private int maxZ; + private int chunkPerTick; private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkForChunkScannerTask chunkTask) { + chunkPerTick = SkyBlock.getInstance().getFileManager() + .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) + .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25); + this.chunkTask = chunkTask; this.chunkForChunk = chunkForChunk; this.paper = paper; @@ -60,6 +65,10 @@ public class ChunkLoader extends BukkitRunnable { } private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkScannerTask generalTask) { + chunkPerTick = SkyBlock.getInstance().getFileManager() + .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) + .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25); + this.generalTask = generalTask; this.chunkForChunk = chunkForChunk; this.paper = paper; @@ -90,7 +99,7 @@ public class ChunkLoader extends BukkitRunnable { @Override public void run() { - for(int i = 0; i < 50 || paper; i++){ // TODO Config for chunk per tick + for(int i = 0; i < chunkPerTick || paper; i++){ if(x < maxX){ if(z < maxZ){ if(!chunkForChunk){ diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 60818c68..c0d664f9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -9,6 +9,10 @@ Sound: # When disabled all sounds will be disabled. Enable: true Island: + Performance: + # Chunk loading per tick affecting operations like island deletion, scan and biome changing. + # This option is ignored when using Paper's async chunk load + ChunkPerTick: 25 Size: # [!] Do not go over 1000 for both of these options. # The size of an Island when created. From c4dce16b12e5538811caf12654e203fb9f0a6a22 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 16:14:42 +0200 Subject: [PATCH 085/366] Edited some comments --- .../java/com/songoda/skyblock/blockscanner/ChunkLoader.java | 2 +- src/main/resources/config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java index 2734e2c0..4c8dcb24 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -98,7 +98,7 @@ public class ChunkLoader extends BukkitRunnable { } @Override - public void run() { + public void run() { // TODO New algorithm that start from the center of the island for(int i = 0; i < chunkPerTick || paper; i++){ if(x < maxX){ if(z < maxZ){ diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c0d664f9..f9b339ab 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -294,7 +294,7 @@ Island: # items in their inventory if they die at an island. Enable: true Settings: - # When any of these options are disabled, the setting will be removed from the 'Island Settings' + # When any of these options are disabled, the setting will be removed from the settings menu # menu. KeepItemsOnDeath: Enable: true From e3324a68ff20efd7ff9f46805c1f6eb1ce9cc182 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 17:15:55 +0200 Subject: [PATCH 086/366] Now settings in config do what they should do --- .../skyblock/permission/PermissionManager.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 6d08121c..d006d820 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -74,9 +74,7 @@ public class PermissionManager { 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), @@ -93,7 +91,6 @@ public class PermissionManager { new VisitorPermission(), new KickPermission(), new BiomePermission(), - new KeepItemsOnDeathPermission(), new UnbanPermission(), new BanPermission(), new BorderPermission(), @@ -105,6 +102,21 @@ public class PermissionManager { new MainSpawnPermission(), new VisitorSpawnPermission()); + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")){ + registerPermission(new KeepItemsOnDeathPermission()); + } + + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Settings.PvP.Enable")){ + registerPermission(new PvpPermission(plugin)); + } + + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")){ + registerPermission(new DamagePermission(plugin)); + } + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")){ registerPermission(new HungerPermission(plugin)); From 59fc4f2bd9db494059915d52efe2fc7e48b58593 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 18:12:05 +0200 Subject: [PATCH 087/366] Use soundManager for everything --- .../command/commands/admin/AdminBank.java | 7 +++--- .../skyblock/gui/GuiSignatureEditor.java | 10 ++++---- .../skyblock/gui/GuiWelcomeEditor.java | 10 ++++---- .../songoda/skyblock/gui/bank/GuiBank.java | 6 +++-- .../skyblock/gui/bank/GuiBankSelector.java | 25 +++++++++++-------- .../skyblock/gui/bank/GuiBankTransaction.java | 7 ++++-- .../gui/permissions/GuiAdminPermissions.java | 7 ++++-- .../gui/permissions/GuiPermissions.java | 13 ++++++---- .../permissions/GuiPermissionsSelector.java | 2 +- .../com/songoda/skyblock/gui/wip/GuiBans.java | 8 +++--- .../songoda/skyblock/gui/wip/GuiBiome.java | 4 +-- .../songoda/skyblock/listeners/Interact.java | 6 ++--- .../permission/ListeningPermission.java | 2 +- 13 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index 9448f591..09cd258a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -29,6 +29,7 @@ public class AdminBank extends SubCommand { MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); FileManager fileManager = skyblock.getFileManager(); + SoundManager soundManager = skyblock.getSoundManager(); FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -37,7 +38,7 @@ public class AdminBank extends SubCommand { if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); return; } @@ -88,12 +89,12 @@ public class AdminBank extends SubCommand { skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); } break; default: messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); } } diff --git a/src/main/java/com/songoda/skyblock/gui/GuiSignatureEditor.java b/src/main/java/com/songoda/skyblock/gui/GuiSignatureEditor.java index 256c1fc4..340989cb 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiSignatureEditor.java +++ b/src/main/java/com/songoda/skyblock/gui/GuiSignatureEditor.java @@ -70,11 +70,11 @@ public class GuiSignatureEditor extends Gui { "Island.Visitor.Signature.Lines") || gui.getInputText().length() > mainConfig.getFileConfiguration() .getInt("Island.Visitor.Signature.Length")) { - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + plugin.getSoundManager().playSound(e.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); } else { signatureMessage.add(gui.getInputText().trim()); island.setMessage(IslandMessage.Signature, e.player.getName(), signatureMessage); - CompatibleSound.BLOCK_NOTE_BLOCK_PLING.play(e.player); + plugin.getSoundManager().playSound(e.player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1f, 1f); } e.player.closeInventory(); paint(); @@ -109,7 +109,7 @@ public class GuiSignatureEditor extends Gui { messageManager.sendMessage(player, configLoad.getString( "Command.Island.Settings.Owner.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); player.closeInventory(); return false; } else if (!(island1.hasRole(IslandRole.Operator, @@ -118,7 +118,7 @@ public class GuiSignatureEditor extends Gui { player.getUniqueId()))) { messageManager.sendMessage(player, configLoad .getString("Command.Island.Role.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); player.closeInventory(); return false; } else if (!plugin.getFileManager() @@ -129,7 +129,7 @@ public class GuiSignatureEditor extends Gui { messageManager.sendMessage(player, configLoad.getString( "Island.Settings.Visitor.Signature.Disabled.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); return false; } return true; diff --git a/src/main/java/com/songoda/skyblock/gui/GuiWelcomeEditor.java b/src/main/java/com/songoda/skyblock/gui/GuiWelcomeEditor.java index 7c680d77..933d28ed 100644 --- a/src/main/java/com/songoda/skyblock/gui/GuiWelcomeEditor.java +++ b/src/main/java/com/songoda/skyblock/gui/GuiWelcomeEditor.java @@ -70,11 +70,11 @@ public class GuiWelcomeEditor extends Gui { "Island.Visitor.Welcome.Lines") || gui.getInputText().length() > mainConfig.getFileConfiguration() .getInt("Island.Visitor.Welcome.Length")) { - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + plugin.getSoundManager().playSound(e.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f,1f); } else { welcomeMessage.add(gui.getInputText().trim()); island.setMessage(IslandMessage.Welcome, e.player.getName(), welcomeMessage); - CompatibleSound.BLOCK_NOTE_BLOCK_PLING.play(e.player); + plugin.getSoundManager().playSound(e.player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1f, 1f); } e.player.closeInventory(); paint(); @@ -109,7 +109,7 @@ public class GuiWelcomeEditor extends Gui { messageManager.sendMessage(player, configLoad.getString( "Command.Island.Settings.Owner.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); player.closeInventory(); return false; } else if (!(island1.hasRole(IslandRole.Operator, @@ -118,7 +118,7 @@ public class GuiWelcomeEditor extends Gui { player.getUniqueId()))) { messageManager.sendMessage(player, configLoad .getString("Command.Island.Role.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); player.closeInventory(); return false; } else if (!plugin.getFileManager() @@ -129,7 +129,7 @@ public class GuiWelcomeEditor extends Gui { messageManager.sendMessage(player, configLoad.getString( "Island.Settings.Visitor.Welcome.Disabled.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(player); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); return false; } return true; diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java index 56ce9111..370d5bda 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java @@ -37,6 +37,7 @@ import java.util.stream.Collectors; public class GuiBank extends Gui { private final SkyBlock plugin; private final BankManager bankManager; + private final SoundManager soundManager; private final Island island; private final FileConfiguration languageLoad; private final boolean admin; @@ -45,6 +46,7 @@ public class GuiBank extends Gui { super(2, returnGui); this.plugin = plugin;; this.bankManager = plugin.getBankManager(); + this.soundManager = plugin.getSoundManager(); this.island = island; this.admin = admin; this.languageLoad = plugin.getFileManager() @@ -71,13 +73,13 @@ public class GuiBank extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index f9f4e779..ea75ca31 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -11,6 +11,7 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; @@ -22,6 +23,7 @@ import java.util.Objects; public class GuiBankSelector extends Gui { private final SkyBlock plugin; private final BankManager bankManager; + private final SoundManager soundManager; private final Island island; private final FileConfiguration languageLoad; private final Type type; @@ -38,6 +40,7 @@ public class GuiBankSelector extends Gui { this.plugin = plugin; this.type = type; this.bankManager = plugin.getBankManager(); + this.soundManager = plugin.getSoundManager(); this.island = island; this.returnGui = returnGui; this.admin = admin; @@ -56,13 +59,13 @@ public class GuiBankSelector extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Input.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Input.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); @@ -109,18 +112,18 @@ public class GuiBankSelector extends Gui { switch(response){ case NOT_ENOUGH_MONEY: messageManager.sendMessage(event.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); break; case DECIMALS_NOT_ALLOWED: messageManager.sendMessage(event.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); break; case NEGATIVE_AMOUNT: messageManager.sendMessage(event.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); break; case SUCCESS: - CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(event.player); + soundManager.playSound(event.player, CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.getSound(), 1f, 1f); messageManager.sendMessage(event.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank." + finalAction + ".Message")).replace( "%amount%", NumberUtil.formatNumberByDecimal(amount))); @@ -142,7 +145,7 @@ public class GuiBankSelector extends Gui { amount = Double.parseDouble(gui.getInputText().trim()); } catch (NumberFormatException e1) { messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); return; } @@ -162,18 +165,18 @@ public class GuiBankSelector extends Gui { switch(response){ case NOT_ENOUGH_MONEY: messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); break; case DECIMALS_NOT_ALLOWED: messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); break; case NEGATIVE_AMOUNT: messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(e.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); break; case SUCCESS: - CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player); + soundManager.playSound(event.player, CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.getSound(), 1f, 1f); messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank." + finalAction + ".Message")).replace( "%amount%", NumberUtil.formatNumberByDecimal(amount))); break; diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java index e0a5f463..b5c419f1 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java @@ -10,6 +10,7 @@ import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.bank.Transaction; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.sound.SoundManager; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -22,6 +23,7 @@ import java.util.List; public class GuiBankTransaction extends Gui { private final SkyBlock plugin; private final BankManager bankManager; + private final SoundManager soundManager; private final FileConfiguration languageLoad; private final FileManager.Config config; private final Gui returnGui; @@ -33,6 +35,7 @@ public class GuiBankTransaction extends Gui { super(returnGui); this.plugin = plugin; this.bankManager = plugin.getBankManager(); + this.soundManager = plugin.getSoundManager(); this.transactionList = bankManager.getTransactions(island.getOwnerUUID()); this.transactions = this.transactionList.size(); this.returnGui = returnGui; @@ -61,13 +64,13 @@ public class GuiBankTransaction extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java index a2e8800b..66097e2e 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java @@ -13,6 +13,7 @@ import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.permission.BasicPermission; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.permission.PermissionType; +import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.visit.Visit; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; @@ -27,6 +28,7 @@ import java.util.stream.Collectors; public class GuiAdminPermissions extends Gui { private final PermissionManager permissionManager; + private final SoundManager soundManager; private final IslandRole role; private final FileConfiguration configLoad; private final FileManager.Config settingsConfig; @@ -36,6 +38,7 @@ public class GuiAdminPermissions extends Gui { public GuiAdminPermissions(SkyBlock plugin, IslandRole role, Gui returnGui) { super(6, returnGui); this.permissionManager = plugin.getPermissionManager(); + this.soundManager = plugin.getSoundManager(); this.role = role; this.returnGui = returnGui; this.configLoad = plugin.getFileManager() @@ -55,13 +58,13 @@ public class GuiAdminPermissions extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java index cdef8d6d..55c499dc 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java @@ -15,6 +15,7 @@ import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.permission.BasicPermission; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.permission.PermissionType; +import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.visit.Visit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -28,6 +29,7 @@ public class GuiPermissions extends Gui { private final SkyBlock plugin; private final PermissionManager permissionManager; + private final SoundManager soundManager; private final IslandRole role; private final Island island; private final FileConfiguration configLoad; @@ -38,6 +40,7 @@ public class GuiPermissions extends Gui { super(6, returnGui); this.plugin = plugin; this.permissionManager = plugin.getPermissionManager(); + this.soundManager = plugin.getSoundManager(); this.role = role; this.island = island; this.returnGui = returnGui; @@ -56,7 +59,7 @@ public class GuiPermissions extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); @@ -94,10 +97,10 @@ public class GuiPermissions extends Gui { (event -> { if (island.isOpen()) { plugin.getIslandManager().closeIsland(island); - CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1f, 1f); } else { island.setOpen(true); - CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1f, 1f); } paint(); })); @@ -105,7 +108,7 @@ public class GuiPermissions extends Gui { setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); @@ -144,7 +147,7 @@ public class GuiPermissions extends Gui { if (!hasPermission(island, event.player, role)) { plugin.getMessageManager().sendMessage(event.player, configLoad .getString("Command.Island.Settings.Permission.Change.Message")); - CompatibleSound.BLOCK_ANVIL_LAND.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); return; } diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java index 790a5fb1..c27b8d04 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java @@ -55,7 +55,7 @@ public class GuiPermissionsSelector extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + plugin.getSoundManager().playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index 53fa9637..15a9ffa7 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -9,6 +9,7 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.ban.BanManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; import org.bukkit.Bukkit; @@ -27,6 +28,7 @@ public class GuiBans extends Gui { private final SkyBlock plugin; private final BanManager banManager; private final PlayerDataManager playerDataManager; + private final SoundManager soundManager; private final Island island; private final FileConfiguration languageLoad; @@ -34,8 +36,8 @@ public class GuiBans extends Gui { super(returnGui); this.plugin = plugin; this.playerDataManager = plugin.getPlayerDataManager(); - ; this.banManager = plugin.getBanManager(); + this.soundManager = plugin.getSoundManager(); this.island = island; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); @@ -51,13 +53,13 @@ public class GuiBans extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java index 0ae70f53..02006aa7 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java @@ -75,13 +75,13 @@ public class GuiBiome extends Gui { setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { - CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player); + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 53244d01..7fffed2c 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -280,7 +280,7 @@ public class Interact implements Listener { if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")) { - CompatibleSound.BLOCK_FIRE_EXTINGUISH.play(block.getWorld(), block.getLocation(), 1.0F, 1.0F); + skyblock.getSoundManager().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 1.0F); block.setType(CompatibleMaterial.AIR.getBlockMaterial()); ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event)); @@ -346,8 +346,8 @@ public class Interact implements Listener { } } } - - CompatibleSound.ENTITY_CHICKEN_EGG.play(player, 10.0F, 10.0F); + + skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 10.0F, 10.0F); event.setCancelled(true); return; diff --git a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java index e9b1e03b..fcc639c1 100644 --- a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java @@ -88,7 +88,7 @@ public abstract class ListeningPermission extends BasicPermission { messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.Settings.Permission.Message")); - CompatibleSound.ENTITY_VILLAGER_NO.play(player); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1f, 1f); } protected void cancelAndMessage(Cancellable cancellable, Player player, From dffd68e50362cbf29f45c00aa2959ff63547ea57 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 18:58:39 +0200 Subject: [PATCH 088/366] Fix for MonsterHurting setting --- .../permissions/listening/BrewingPermission.java | 11 ----------- .../listening/MonsterHurtingPermission.java | 7 ++++--- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java index e7b014b4..74c68845 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java @@ -38,15 +38,4 @@ public class BrewingPermission extends ListeningPermission { if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.BREWING_STAND) cancelAndMessage(event, player, plugin, messageManager); } - - @PermissionHandler - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if (!(event.getDamager() instanceof Player)) return; - Player player = (Player)event.getDamager(); - Entity entity = event.getEntity(); - - if (!(entity instanceof Monster)) return; - - cancelAndMessage(event, player, plugin, messageManager); - } } diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java index 8d2558ef..75fea9e8 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java @@ -7,6 +7,7 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionPriority; import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.Bukkit; import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -32,8 +33,8 @@ public class MonsterHurtingPermission extends ListeningPermission { Entity entity = event.getEntity(); - if (entity.getType() == EntityType.ARMOR_STAND || !(entity instanceof Monster)) return; - - cancelAndMessage(event, player, plugin, messageManager); + if (entity instanceof Monster){ + cancelAndMessage(event, player, plugin, messageManager); + } } } From 62f05196c73d7b87efb74520bc33d21dd00259d6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 19:42:38 +0200 Subject: [PATCH 089/366] Allow toggling scoreboards with /is scoreboard --- .../skyblock/command/CommandManager.java | 1 + .../commands/island/ScoreboardCommand.java | 82 +++++++++++ .../com/songoda/skyblock/listeners/Join.java | 36 +---- .../skyblock/playerdata/PlayerData.java | 11 +- .../scoreboard/ScoreboardManager.java | 132 +++++++++++++----- src/main/resources/language.yml | 11 ++ 6 files changed, 201 insertions(+), 72 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index 5b844db1..97778834 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -89,6 +89,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { new VisitCommand(), new VisitorsCommand(), new VoteCommand(), + new ScoreboardCommand(), new WeatherCommand() ); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java new file mode 100644 index 00000000..cfe4ee8a --- /dev/null +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java @@ -0,0 +1,82 @@ +package com.songoda.skyblock.command.commands.island; + +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.skyblock.command.SubCommand; +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.permission.PermissionManager; +import com.songoda.skyblock.playerdata.PlayerData; +import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.scoreboard.ScoreboardManager; +import com.songoda.skyblock.sound.SoundManager; +import org.bukkit.Bukkit; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; + +public class ScoreboardCommand extends SubCommand { + + @Override + public void onCommandByPlayer(Player player, String[] args) { + MessageManager messageManager = skyblock.getMessageManager(); + PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + SoundManager soundManager = skyblock.getSoundManager(); + ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); + + Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + PlayerData playerData = playerDataManager.getPlayerData(player); + + if (playerData == null) { + messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Error.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } else if(!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Scoreboard.Enable", false)) { + messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.GlobalDisable.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + }else if (playerData.isScoreboard()) { + playerData.setScoreboard(false); + scoreboardManager.removePlayer(player); + + messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Disabled.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + } else { + playerData.setScoreboard(true); + scoreboardManager.addPlayer(player); + + messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Enabled.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + } + } + + @Override + public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { + sender.sendMessage("SkyBlock | Error: You must be a player to perform that command."); + } + + @Override + public String getName() { + return "scoreboard"; + } + + @Override + public String getInfoMessagePath() { + return "Command.Scoreboard.Info.Message"; + } + + @Override + public String[] getAliases() { + return new String[0]; + } + + @Override + public String[] getArguments() { + return new String[0]; + } +} diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index 82a702a3..9733fdc1 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -105,41 +105,7 @@ public class Join implements Listener { cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player)); if (scoreboardManager != null) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - Scoreboard scoreboard = new Scoreboard(skyblock, player); - Island island = islandManager.getIsland(player); - - if (island != null) { - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); - - cooldownManager.addCooldownPlayer(CooldownType.Levelling, cooldownManager.loadCooldownPlayer(CooldownType.Levelling, offlinePlayer)); - cooldownManager.addCooldownPlayer(CooldownType.Ownership, cooldownManager.loadCooldownPlayer(CooldownType.Ownership, offlinePlayer)); - - if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); - } else { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); - } - } else { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines")); - } else { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); - } - - } - } else { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname"))); - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines")); - } - - scoreboard.run(); - scoreboardManager.storeScoreboard(player, scoreboard); + scoreboardManager.addPlayer(player); } Island island = islandManager.getIslandPlayerAt(player); diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 43868005..e72addcd 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -153,15 +153,22 @@ public class PlayerData { this.playTime = playTime; } + public boolean isScoreboard() { + return getConfig().getFileConfiguration().getBoolean("Scoreboard", true); + } + + public void setScoreboard(boolean scoreboard) { + getConfig().getFileConfiguration().set("Scoreboard", scoreboard); + } + public boolean isPreview() { return preview; } - + public void setPreview(boolean preview) { this.preview = preview; } - public int getVisitTime() { return visitTime; } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 8e5f8b40..1f94c4e2 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -3,12 +3,17 @@ package com.songoda.skyblock.scoreboard; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.cooldown.CooldownManager; +import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.playerdata.PlayerData; +import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scoreboard.Objective; @@ -23,6 +28,8 @@ public class ScoreboardManager extends BukkitRunnable { private final static int VERSION = NMSUtil.getVersionNumber(); private final SkyBlock skyblock; private final Map scoreboardStorage = new HashMap<>(); + + private final PlayerDataManager playerDataManager; private int runTicks = 0; @@ -31,6 +38,7 @@ public class ScoreboardManager extends BukkitRunnable { public ScoreboardManager(SkyBlock skyblock) { this.skyblock = skyblock; + this.playerDataManager = skyblock.getPlayerDataManager(); this.runTaskTimer(skyblock, 20, 40); } @@ -95,42 +103,45 @@ public class ScoreboardManager extends BukkitRunnable { */ for (Player player : players) { - - final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - - for (Objective primaryObjective : objectives) { - - Objective obj = playerBoard.getObjective(primaryObjective.getName()); - - if (obj == null) - obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); - - obj.setDisplayName(primaryObjective.getDisplayName()); - obj.setDisplaySlot(primaryObjective.getDisplaySlot()); - if (VERSION > 12) obj.setRenderType(primaryObjective.getRenderType()); - } - - for (Team primaryTeam : teams) { - - Team obj = playerBoard.getTeam(primaryTeam.getName()); - - if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); - - obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); - obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); - if (VERSION > 11) obj.setColor(primaryTeam.getColor()); - obj.setDisplayName(primaryTeam.getDisplayName()); - obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); - obj.setPrefix(primaryTeam.getPrefix()); - obj.setSuffix(primaryTeam.getSuffix()); - - for (String primaryEntry : primaryTeam.getEntries()) { - obj.addEntry(primaryEntry); + + PlayerData pd = playerDataManager.getPlayerData(player); + if(pd != null && pd.isScoreboard()){ + final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); + + for (Objective primaryObjective : objectives) { + + Objective obj = playerBoard.getObjective(primaryObjective.getName()); + + if (obj == null) + obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); + + obj.setDisplayName(primaryObjective.getDisplayName()); + obj.setDisplaySlot(primaryObjective.getDisplaySlot()); + if (VERSION > 12) obj.setRenderType(primaryObjective.getRenderType()); } - - if (VERSION > 8) { - for (Option option : Option.values()) { - obj.setOption(option, primaryTeam.getOption(option)); + + for (Team primaryTeam : teams) { + + Team obj = playerBoard.getTeam(primaryTeam.getName()); + + if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); + + obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); + obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); + if (VERSION > 11) obj.setColor(primaryTeam.getColor()); + obj.setDisplayName(primaryTeam.getDisplayName()); + obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); + obj.setPrefix(primaryTeam.getPrefix()); + obj.setSuffix(primaryTeam.getSuffix()); + + for (String primaryEntry : primaryTeam.getEntries()) { + obj.addEntry(primaryEntry); + } + + if (VERSION > 8) { + for (Option option : Option.values()) { + obj.setOption(option, primaryTeam.getOption(option)); + } } } } @@ -211,4 +222,55 @@ public class ScoreboardManager extends BukkitRunnable { public boolean hasScoreboard(Player player) { return scoreboardStorage.containsKey(player.getUniqueId()); } + + public Map getScoreboardStorage() { + return this.scoreboardStorage; + } + + public void addPlayer(Player player){ + CooldownManager cooldownManager = skyblock.getCooldownManager(); + FileManager fileManager = skyblock.getFileManager(); + IslandManager islandManager = skyblock.getIslandManager(); + + Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Scoreboard scoreboard = new Scoreboard(skyblock, player); + Island island = islandManager.getIsland(player); + + if (island != null) { + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); + + cooldownManager.addCooldownPlayer(CooldownType.Levelling, cooldownManager.loadCooldownPlayer(CooldownType.Levelling, offlinePlayer)); + cooldownManager.addCooldownPlayer(CooldownType.Ownership, cooldownManager.loadCooldownPlayer(CooldownType.Ownership, offlinePlayer)); + + if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { + scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); + + if (islandManager.getVisitorsAtIsland(island).size() == 0) { + scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); + } else { + scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); + } + } else { + scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname"))); + + if (islandManager.getVisitorsAtIsland(island).size() == 0) { + scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines")); + } else { + scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); + } + + } + } else { + scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname"))); + scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines")); + } + + scoreboard.run(); + this.storeScoreboard(player, scoreboard); + } + + public void removePlayer(Player player){ + player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); + this.scoreboardStorage.remove(player.getUniqueId()); + } } \ No newline at end of file diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 098e950e..f039dd40 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -7,6 +7,17 @@ ClassLocalization: Operator: 'Operator' Owner: 'Owner' Command: + Scoreboard: + Disabled: + Message: '&bSkyBlock &8| &aInfo&8: &eScoreboard disabled.' + Enabled: + Message: '&bSkyBlock &8| &aInfo&8: &eScoreboard enabled.' + Error: + Message: '&bSkyBlock &8| &cError&8: &eAn error occurred.' + GlobalDisable: + Message: '&bSkyBlock &8| &cError&8: &eScoreboard are globally disabled.' + Info: + Message: '&bSkyBlock &8| &aInfo&8: &eEnable or disabled the scoreboard.' Island: Bans: Owner: From 7d3a2b95a8404d6947aaf369af07602ededffabd Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 20:29:58 +0200 Subject: [PATCH 090/366] Fixed Barrels not being counted in structures file --- .../utils/world/block/BlockStateType.java | 2 +- .../skyblock/utils/world/block/BlockUtil.java | 50 ++++++++++++++----- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java index 9f1141dc..ebfb6f2e 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java +++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java @@ -3,6 +3,6 @@ package com.songoda.skyblock.utils.world.block; public enum BlockStateType { NORMAL, BANNER, BEACON, BREWINGSTAND, COMMANDBLOCK, CHEST, DISPENSER, DROPPER, HOPPER, SHULKERBOX, CREATURESPAWNER, - ENDGATEWAY, FURNACE, JUKEBOX, SIGN, SKULL, DOUBLECHEST + ENDGATEWAY, FURNACE, JUKEBOX, SIGN, SKULL, DOUBLECHEST, BARREL } \ No newline at end of file diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java index 6434bb73..a65b70ce 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java @@ -172,7 +172,7 @@ public final class BlockUtil extends BlockUtils { blockData.setRotateFace(skull.getRotation().toString()); blockData.setStateType(BlockStateType.SKULL.toString()); } else { - if (NMSVersion > 8) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { if (blockState instanceof EndGateway) { EndGateway endGateway = (EndGateway) blockState; blockData.setExactTeleport(endGateway.isExactTeleport()); @@ -182,7 +182,7 @@ public final class BlockUtil extends BlockUtils { blockData.setStateType(BlockStateType.ENDGATEWAY.toString()); } - if (NMSVersion > 10) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { if (blockState instanceof ShulkerBox) { ShulkerBox shulkerBox = (ShulkerBox) blockState; @@ -197,6 +197,22 @@ public final class BlockUtil extends BlockUtils { blockData.setStateType(BlockStateType.SHULKERBOX.toString()); } } + + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)){ + if (blockState instanceof Barrel) { + Barrel barrel = (Barrel) blockState; + + for (int i = 0; i < barrel.getInventory().getSize(); i++) { + ItemStack is = barrel.getInventory().getItem(i); + + if (is != null && is.getType() != CompatibleMaterial.AIR.getMaterial()) { + blockData.addItem(i, ItemStackUtil.serializeItemStack(is)); + } + } + + blockData.setStateType(BlockStateType.BARREL.toString()); + } + } } } @@ -204,7 +220,7 @@ public final class BlockUtil extends BlockUtils { blockData.setFacing(((Stairs) materialData).getFacing().toString()); blockData.setDataType(BlockDataType.STAIRS.toString()); } else if (materialData instanceof org.bukkit.material.FlowerPot) { - if (NMSVersion >= 8 && NMSVersion <= 12) { + if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) { try { World world = block.getWorld(); @@ -256,7 +272,7 @@ public final class BlockUtil extends BlockUtils { Material material = Material.valueOf(materialStr); if (material == Material.AIR) return; - if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) + if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData()); else block.setBlockData(Bukkit.getServer().createBlockData(blockData.getBlockData())); @@ -376,14 +392,14 @@ public final class BlockUtil extends BlockUtils { skull.setRotation(BlockFace.valueOf(blockData.getRotateFace().toUpperCase())); skull.setSkullType(SkullType.valueOf(blockData.getSkullType().toUpperCase())); - if (NMSVersion > 9) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) { skull.setOwningPlayer(Bukkit.getServer().getOfflinePlayer(blockData.getSkullOwner())); } else { skull.setOwner(blockData.getSkullOwner()); } state.update(); } else { - if (NMSVersion > 8) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { if (blockTypeState == BlockStateType.ENDGATEWAY) { EndGateway endGateway = (EndGateway) state; endGateway.setExactTeleport(blockData.isExactTeleport()); @@ -399,15 +415,25 @@ public final class BlockUtil extends BlockUtils { state.update(); } - if (NMSVersion > 9) { - if (NMSVersion > 10) { - if (blockTypeState == BlockStateType.SHULKERBOX) { - ShulkerBox shulkerBox = (ShulkerBox) state; + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { + if (blockTypeState == BlockStateType.SHULKERBOX) { + ShulkerBox shulkerBox = (ShulkerBox) state; + for (Integer slotList : blockData.getInventory().keySet()) { + if (slotList < shulkerBox.getInventory().getSize()) { + ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList)); + shulkerBox.getInventory().setItem(slotList, is); + } + } + } + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)){ + if (blockTypeState == BlockStateType.BARREL) { + Barrel barrel = (Barrel) state; + for (Integer slotList : blockData.getInventory().keySet()) { - if (slotList < shulkerBox.getInventory().getSize()) { + if (slotList < barrel.getInventory().getSize()) { ItemStack is = ItemStackUtil.deserializeItemStack(blockData.getInventory().get(slotList)); - shulkerBox.getInventory().setItem(slotList, is); + barrel.getInventory().setItem(slotList, is); } } } From 28054da407daef6898cf0d4eb005ded8c3e2e8a6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 20:30:10 +0200 Subject: [PATCH 091/366] Removed useless code in GuiBans --- src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index 15a9ffa7..cf29cd98 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -25,8 +25,6 @@ import java.util.List; import java.util.UUID; public class GuiBans extends Gui { - private final SkyBlock plugin; - private final BanManager banManager; private final PlayerDataManager playerDataManager; private final SoundManager soundManager; private final Island island; @@ -34,9 +32,7 @@ public class GuiBans extends Gui { public GuiBans(SkyBlock plugin, Island island, Gui returnGui) { super(returnGui); - this.plugin = plugin; this.playerDataManager = plugin.getPlayerDataManager(); - this.banManager = plugin.getBanManager(); this.soundManager = plugin.getSoundManager(); this.island = island; this.languageLoad = plugin.getFileManager() @@ -46,7 +42,7 @@ public class GuiBans extends Gui { paint(); } - public void paint() { + public void paint() { // TODO Item to add ban if (inventory != null) inventory.clear(); setActionForRange(0, 0, 1, 8, null); From 9f36184f798621af89031c160314fd11fa788087 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 24 Jun 2020 20:38:58 +0200 Subject: [PATCH 092/366] 2.3.4-DEV2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47690f81..bf2297da 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.4-DEV1 + 2.3.4-DEV2 jar clean install From 58da5128d8cf9efa4772c34775559b1fa24c9a37 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 03:03:27 +0200 Subject: [PATCH 093/366] Package levelling renamed --- src/main/java/com/songoda/skyblock/SkyBlock.java | 2 +- .../skyblock/api/levelling/LevellingManager.java | 5 +++-- .../command/commands/admin/LevelScanCommand.java | 2 +- .../command/commands/admin/ReloadCommand.java | 2 +- .../command/commands/island/LevelCommand.java | 2 +- .../command/commands/island/ValueCommand.java | 2 +- .../levelling/{rework => }/IslandLevelManager.java | 12 ++++++------ .../skyblock/levelling/{rework => }/IslandScan.java | 6 +++--- .../levelling/{rework => }/LevellingMaterial.java | 2 +- .../{rework => }/amount/AmountMaterialPair.java | 2 +- .../levelling/{rework => }/amount/BlockAmount.java | 2 +- .../{rework => }/calculator/Calculator.java | 2 +- .../{rework => }/calculator/CalculatorRegistry.java | 3 +-- .../{rework => }/calculator/SpawnerCalculator.java | 2 +- .../calculator/impl/EpicSpawnerCalculator.java | 4 ++-- .../calculator/impl/UltimateStackerCalculator.java | 4 ++-- .../java/com/songoda/skyblock/listeners/Block.java | 4 +--- .../com/songoda/skyblock/listeners/Interact.java | 4 +--- .../java/com/songoda/skyblock/menus/Levelling.java | 2 +- .../com/songoda/skyblock/menus/admin/Levelling.java | 6 ++---- .../skyblock/placeholder/PlaceholderManager.java | 2 +- 21 files changed, 33 insertions(+), 39 deletions(-) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/IslandLevelManager.java (94%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/IslandScan.java (97%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/LevellingMaterial.java (93%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/amount/AmountMaterialPair.java (89%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/amount/BlockAmount.java (86%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/calculator/Calculator.java (63%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/calculator/CalculatorRegistry.java (89%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/calculator/SpawnerCalculator.java (84%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/calculator/impl/EpicSpawnerCalculator.java (77%) rename src/main/java/com/songoda/skyblock/levelling/{rework => }/calculator/impl/UltimateStackerCalculator.java (80%) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 7dbf9973..088914c8 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -23,7 +23,7 @@ import com.songoda.skyblock.invite.InviteManager; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.reward.RewardManager; import com.songoda.skyblock.leaderboard.LeaderboardManager; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.limit.LimitationInstanceHandler; import com.songoda.skyblock.listeners.*; import com.songoda.skyblock.localization.LocalizationManager; diff --git a/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java b/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java index ba6be39b..5d9a9bf8 100644 --- a/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java +++ b/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java @@ -2,12 +2,13 @@ package com.songoda.skyblock.api.levelling; import com.google.common.base.Preconditions; import com.songoda.skyblock.api.island.Island; +import com.songoda.skyblock.levelling.IslandLevelManager; public class LevellingManager { - private final com.songoda.skyblock.levelling.rework.IslandLevelManager levellingManager; + private final IslandLevelManager levellingManager; - public LevellingManager(com.songoda.skyblock.levelling.rework.IslandLevelManager levellingManager) { + public LevellingManager(IslandLevelManager levellingManager) { this.levellingManager = levellingManager; } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java index 50476025..a54509b6 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java @@ -5,7 +5,7 @@ import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.Bukkit; diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java index 5e80da00..d776e29c 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java @@ -16,7 +16,7 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.generator.GeneratorManager; import com.songoda.skyblock.leaderboard.LeaderboardManager; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.limit.LimitationInstanceHandler; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.scoreboard.ScoreboardManager; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java index 004fa6eb..ab70ca02 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java @@ -9,7 +9,7 @@ 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.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.menus.Levelling; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java index 1bcf0725..751bf0b3 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java @@ -5,7 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java similarity index 94% rename from src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java rename to src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java index 83c02dd5..b15ac2cd 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework; +package com.songoda.skyblock.levelling; import java.io.File; import java.util.ArrayList; @@ -9,6 +9,10 @@ import java.util.Map; import java.util.Map.Entry; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.levelling.calculator.Calculator; +import com.songoda.skyblock.levelling.calculator.CalculatorRegistry; +import com.songoda.skyblock.levelling.calculator.impl.EpicSpawnerCalculator; +import com.songoda.skyblock.levelling.calculator.impl.UltimateStackerCalculator; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; @@ -21,11 +25,7 @@ import org.bukkit.plugin.PluginManager; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.blockscanner.BlockInfo; import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.levelling.rework.amount.AmountMaterialPair; -import com.songoda.skyblock.levelling.rework.calculator.Calculator; -import com.songoda.skyblock.levelling.rework.calculator.CalculatorRegistry; -import com.songoda.skyblock.levelling.rework.calculator.impl.EpicSpawnerCalculator; -import com.songoda.skyblock.levelling.rework.calculator.impl.UltimateStackerCalculator; +import com.songoda.skyblock.levelling.amount.AmountMaterialPair; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.stackable.StackableManager; diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java similarity index 97% rename from src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java rename to src/main/java/com/songoda/skyblock/levelling/IslandScan.java index 06d5b3c8..5cbec2a5 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework; +package com.songoda.skyblock.levelling; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; @@ -9,8 +9,8 @@ import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.blockscanner.ChunkLoader; -import com.songoda.skyblock.levelling.rework.amount.AmountMaterialPair; -import com.songoda.skyblock.levelling.rework.amount.BlockAmount; +import com.songoda.skyblock.levelling.amount.AmountMaterialPair; +import com.songoda.skyblock.levelling.amount.BlockAmount; import com.songoda.skyblock.message.MessageManager; import org.bukkit.*; import org.bukkit.configuration.Configuration; diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/LevellingMaterial.java b/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java similarity index 93% rename from src/main/java/com/songoda/skyblock/levelling/rework/LevellingMaterial.java rename to src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java index eb923ba7..bf0936d3 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/LevellingMaterial.java +++ b/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework; +package com.songoda.skyblock.levelling; import com.songoda.core.compatibility.CompatibleMaterial; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/amount/AmountMaterialPair.java b/src/main/java/com/songoda/skyblock/levelling/amount/AmountMaterialPair.java similarity index 89% rename from src/main/java/com/songoda/skyblock/levelling/rework/amount/AmountMaterialPair.java rename to src/main/java/com/songoda/skyblock/levelling/amount/AmountMaterialPair.java index 6ce6317d..b853874a 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/amount/AmountMaterialPair.java +++ b/src/main/java/com/songoda/skyblock/levelling/amount/AmountMaterialPair.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework.amount; +package com.songoda.skyblock.levelling.amount; import com.songoda.core.compatibility.CompatibleMaterial; diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/amount/BlockAmount.java b/src/main/java/com/songoda/skyblock/levelling/amount/BlockAmount.java similarity index 86% rename from src/main/java/com/songoda/skyblock/levelling/rework/amount/BlockAmount.java rename to src/main/java/com/songoda/skyblock/levelling/amount/BlockAmount.java index 5bd5f038..d2ee12fa 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/amount/BlockAmount.java +++ b/src/main/java/com/songoda/skyblock/levelling/amount/BlockAmount.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework.amount; +package com.songoda.skyblock.levelling.amount; public class BlockAmount { diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/Calculator.java b/src/main/java/com/songoda/skyblock/levelling/calculator/Calculator.java similarity index 63% rename from src/main/java/com/songoda/skyblock/levelling/rework/calculator/Calculator.java rename to src/main/java/com/songoda/skyblock/levelling/calculator/Calculator.java index a50bd46f..639ac4ab 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/Calculator.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/Calculator.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework.calculator; +package com.songoda.skyblock.levelling.calculator; import org.bukkit.block.Block; diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/CalculatorRegistry.java b/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java similarity index 89% rename from src/main/java/com/songoda/skyblock/levelling/rework/calculator/CalculatorRegistry.java rename to src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java index 7f129267..19a2b1bc 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/CalculatorRegistry.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework.calculator; +package com.songoda.skyblock.levelling.calculator; import java.util.ArrayList; import java.util.HashMap; @@ -6,7 +6,6 @@ import java.util.List; import java.util.Map; import com.songoda.core.compatibility.CompatibleMaterial; -import org.bukkit.Material; public final class CalculatorRegistry { diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/SpawnerCalculator.java b/src/main/java/com/songoda/skyblock/levelling/calculator/SpawnerCalculator.java similarity index 84% rename from src/main/java/com/songoda/skyblock/levelling/rework/calculator/SpawnerCalculator.java rename to src/main/java/com/songoda/skyblock/levelling/calculator/SpawnerCalculator.java index 9c50eb98..0aa67491 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/SpawnerCalculator.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/SpawnerCalculator.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.levelling.rework.calculator; +package com.songoda.skyblock.levelling.calculator; import org.bukkit.block.Block; import org.bukkit.block.CreatureSpawner; diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/EpicSpawnerCalculator.java b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/EpicSpawnerCalculator.java similarity index 77% rename from src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/EpicSpawnerCalculator.java rename to src/main/java/com/songoda/skyblock/levelling/calculator/impl/EpicSpawnerCalculator.java index 3012f1b3..18447f71 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/EpicSpawnerCalculator.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/EpicSpawnerCalculator.java @@ -1,10 +1,10 @@ -package com.songoda.skyblock.levelling.rework.calculator.impl; +package com.songoda.skyblock.levelling.calculator.impl; import org.bukkit.block.CreatureSpawner; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.spawners.spawner.Spawner; -import com.songoda.skyblock.levelling.rework.calculator.SpawnerCalculator; +import com.songoda.skyblock.levelling.calculator.SpawnerCalculator; public class EpicSpawnerCalculator implements SpawnerCalculator { diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/UltimateStackerCalculator.java b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/UltimateStackerCalculator.java similarity index 80% rename from src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/UltimateStackerCalculator.java rename to src/main/java/com/songoda/skyblock/levelling/calculator/impl/UltimateStackerCalculator.java index 66a1716a..1e18b189 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/UltimateStackerCalculator.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/UltimateStackerCalculator.java @@ -1,8 +1,8 @@ -package com.songoda.skyblock.levelling.rework.calculator.impl; +package com.songoda.skyblock.levelling.calculator.impl; import org.bukkit.block.CreatureSpawner; -import com.songoda.skyblock.levelling.rework.calculator.SpawnerCalculator; +import com.songoda.skyblock.levelling.calculator.SpawnerCalculator; import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.spawner.SpawnerStack; diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index b3a687cf..ee5865bf 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -8,10 +8,9 @@ import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.generator.Generator; import com.songoda.skyblock.generator.GeneratorManager; import com.songoda.skyblock.island.*; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.limit.impl.BlockLimitation; import com.songoda.skyblock.permission.PermissionManager; -import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.utils.NumberUtil; @@ -31,7 +30,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.*; -import org.bukkit.event.player.PlayerShearEntityEvent; import org.bukkit.event.world.PortalCreateEvent; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 7fffed2c..4d5aaeab 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -10,7 +10,7 @@ import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.limit.impl.BlockLimitation; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; @@ -18,12 +18,10 @@ 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.version.NMSUtil; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; import org.apache.commons.lang.WordUtils; import org.bukkit.*; -import org.bukkit.block.BlockFace; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index b01250e3..a9735189 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -28,7 +28,7 @@ import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java index ae8adaa8..61bb1df3 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java @@ -5,8 +5,8 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; -import com.songoda.skyblock.levelling.rework.LevellingMaterial; +import com.songoda.skyblock.levelling.IslandLevelManager; +import com.songoda.skyblock.levelling.LevellingMaterial; import com.songoda.skyblock.menus.MenuType; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; @@ -16,12 +16,10 @@ import com.songoda.skyblock.utils.AbstractAnvilGUI; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; -import com.songoda.skyblock.utils.version.CompatibleSpawners; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.block.CreatureSpawner; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java index a6dd7f49..23a84e63 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java @@ -21,7 +21,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.leaderboard.Leaderboard; import com.songoda.skyblock.leaderboard.LeaderboardManager; -import com.songoda.skyblock.levelling.rework.IslandLevelManager; +import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.upgrade.Upgrade; import com.songoda.skyblock.upgrade.Upgrade.Type; import com.songoda.skyblock.utils.NumberUtil; From 08e5046f52a037b1c8904b85aaa135fce3c52469 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 03:03:36 +0200 Subject: [PATCH 094/366] A little config comment change --- src/main/resources/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f9b339ab..e192acda 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,12 +12,12 @@ Island: Performance: # Chunk loading per tick affecting operations like island deletion, scan and biome changing. # This option is ignored when using Paper's async chunk load - ChunkPerTick: 25 + # You should increase this only if you have an SSD + ChunkPerTick: 15 Size: # [!] Do not go over 1000 for both of these options. # The size of an Island when created. # [!] Do not go over the maximum. - # [!] Even numbers WILL create world border issues. Minimum: 100 # The maximum size of an Island based on the permission node 'fabledskyblock.size.'. Maximum: 200 @@ -166,7 +166,7 @@ Island: Lines: 6 # Length allowed for each line Length: 30 - # Max amount of players allowed at a Island. This also includes Island Members. + # Max amount of concurrent players allowed at an Island. This also includes Island Members. # [!] Set to -1 for unlimited capacity. Capacity: 25 # Allow Island Operators or Owners to ban players from their Island. From bf684fe4aaf97c46079d1f74c31b65998e4d905d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 03:08:22 +0200 Subject: [PATCH 095/366] Simplify level manager --- .../levelling/IslandLevelManager.java | 50 ++++++++++++++++- .../com/songoda/skyblock/listeners/Block.java | 53 ++++--------------- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java index b15ac2cd..705c66ac 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java @@ -9,14 +9,18 @@ import java.util.Map; import java.util.Map.Entry; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; +import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.levelling.calculator.Calculator; import com.songoda.skyblock.levelling.calculator.CalculatorRegistry; import com.songoda.skyblock.levelling.calculator.impl.EpicSpawnerCalculator; import com.songoda.skyblock.levelling.calculator.impl.UltimateStackerCalculator; +import com.songoda.skyblock.utils.version.CompatibleSpawners; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.CreatureSpawner; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -210,5 +214,49 @@ public final class IslandLevelManager { return new AmountMaterialPair(compMaterial, amount + stackSize); } - + + public void updateLevel(Island island, Location location) { + // Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client. + // BUG: Player can infinitely increase their level by placing a block at their + // feet. + // It doesn't take the block away but still increments the level. + // This doesn't happen in Spigot, but does happen in PaperSpigot due to a + // BlockPlaceEvent being incorrectly fired. + // The solution is to wait a tick to make sure that the block was actually + // placed. + // This shouldn't cause any issues besides the task number being increased + // insanely fast. + if(ServerVersion.isServerVersion(ServerVersion.V1_8)){ + Bukkit.getScheduler().runTask(plugin, () -> { + updateLevelLocation(island, location); + }); + } else { + updateLevelLocation(island, location); + } + } + + private void updateLevelLocation(Island island, Location location) { + Block block = location.getBlock(); + CompatibleMaterial material = CompatibleMaterial.getMaterial(block); + + if (material == null || material == CompatibleMaterial.AIR) return; + + if (material == CompatibleMaterial.SPAWNER) { + if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || Bukkit.getPluginManager().isPluginEnabled("WildStacker")) + return; + + CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType()); + + if (spawner != null) + material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial()); + } + + long materialAmount = 0; + IslandLevel level = island.getLevel(); + + if (level.hasMaterial(material.name())) + materialAmount = level.getMaterialAmount(material.name()); + + level.setMaterialAmount(material.name(), materialAmount + 1); + } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index ee5865bf..e1af24ab 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -185,7 +185,7 @@ public class Block implements Listener { IslandManager islandManager = skyblock.getIslandManager(); WorldManager worldManager = skyblock.getWorldManager(); - IslandLevelManager levellingManager = skyblock.getLevellingManager(); + IslandLevelManager islandLevelManager = skyblock.getLevellingManager(); if (!worldManager.isIslandWorld(block.getWorld())) return; Location blockLoc = block.getLocation(); @@ -201,7 +201,7 @@ public class Block implements Listener { return; } - if (levellingManager.isScanning(island)) { + if (islandLevelManager.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); @@ -286,8 +286,8 @@ public class Block implements Listener { if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial() && event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return; - - updateLevel(island, blockLoc); + + islandLevelManager.updateLevel(island, blockLoc); } @EventHandler @@ -297,6 +297,7 @@ public class Block implements Listener { GeneratorManager generatorManager = skyblock.getGeneratorManager(); IslandManager islandManager = skyblock.getIslandManager(); WorldManager worldManager = skyblock.getWorldManager(); + IslandLevelManager islandLevelManager = skyblock.getLevellingManager(); Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld()); @@ -382,7 +383,7 @@ public class Block implements Listener { toBlockState.setData(genState.getData()); toBlockState.setType(genState.getType()); toBlockState.update(); - updateLevel(island, genState.getLocation()); + islandLevelManager.updateLevel(island, genState.getLocation()); return; } } @@ -541,6 +542,8 @@ public class Block implements Listener { public void onBlockForm(BlockFormEvent event) { org.bukkit.block.Block block = event.getBlock(); WorldManager worldManager = skyblock.getWorldManager(); + IslandLevelManager islandLevelManager = skyblock.getLevellingManager(); + if (!worldManager.isIslandWorld(block.getWorld())) return; // Check ice/snow forming @@ -612,7 +615,7 @@ public class Block implements Listener { state.setType(genState.getType()); if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData()); - updateLevel(island, genState.getLocation()); + islandLevelManager.updateLevel(island, genState.getLocation()); return; } } @@ -715,42 +718,4 @@ public class Block implements Listener { event.setCancelled(true); } - private void updateLevel(Island island, Location location) { - // Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client. - // BUG: Player can infinitely increase their level by placing a block at their - // feet. - // It doesn't take the block away but still increments the level. - // This doesn't happen in Spigot, but does happen in PaperSpigot due to a - // BlockPlaceEvent being incorrectly fired. - // The solution is to wait a tick to make sure that the block was actually - // placed. - // This shouldn't cause any issues besides the task number being increased - // insanely fast. - // TODO Do this only in 1.8.8 - Bukkit.getScheduler().runTask(skyblock, () -> { - org.bukkit.block.Block block = location.getBlock(); - CompatibleMaterial material = CompatibleMaterial.getMaterial(block); - - if (material == null || material == CompatibleMaterial.AIR) return; - - if (material == CompatibleMaterial.SPAWNER) { - if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || Bukkit.getPluginManager().isPluginEnabled("WildStacker")) - return; - - CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType()); - - if (spawner != null) - material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial()); - } - - long materialAmount = 0; - IslandLevel level = island.getLevel(); - - if (level.hasMaterial(material.name())) - materialAmount = level.getMaterialAmount(material.name()); - - level.setMaterialAmount(material.name(), materialAmount + 1); - }); - } - } From d3d150e1ba87fb32ed49f4a9acc70294995cc940 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 04:20:55 +0200 Subject: [PATCH 096/366] Typo in pom, make it build --- pom.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index fd0e1754..64af6a6a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,12 +7,10 @@ skyblock 2.3.2 jar - UTF-8 UTF-8 - < - + clean install FabledSkyblock-${project.version} From bd3ee69a9a5e201736a6e6e05e012dc18087ae93 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 04:33:49 +0200 Subject: [PATCH 097/366] Update PaperLib to 1.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6f89bae3..139be75c 100644 --- a/pom.xml +++ b/pom.xml @@ -143,7 +143,7 @@ io.papermc paperlib - 1.0.3 + 1.0.4 compile From b8db90a40cb6a166af79fe55d65e62649f05b452 Mon Sep 17 00:00:00 2001 From: WolfDW Date: Thu, 25 Jun 2020 02:38:45 +0000 Subject: [PATCH 098/366] Update levelling.yml --- src/main/resources/levelling.yml | 718 +++++++++++++++++++++++++++++++ 1 file changed, 718 insertions(+) diff --git a/src/main/resources/levelling.yml b/src/main/resources/levelling.yml index c8d20eb3..b98ee706 100644 --- a/src/main/resources/levelling.yml +++ b/src/main/resources/levelling.yml @@ -3,1438 +3,2156 @@ # Points Earned Materials: ACACIA_BUTTON: + Limit: -1 Points: 1 ACACIA_DOOR: + Limit: -1 Points: 1 ACACIA_FENCE: + Limit: -1 Points: 2 ACACIA_FENCE_GATE: + Limit: -1 Points: 4 ACACIA_LEAVES: + Limit: -1 Points: 0 ACACIA_LOG: + Limit: -1 Points: 0 ACACIA_PLANKS: + Limit: -1 Points: 1 ACACIA_PRESSURE_PLATE: + Limit: -1 Points: 2 ACACIA_SAPLING: + Limit: -1 Points: 1 ACACIA_SLAB: + Limit: -1 Points: 1 ACACIA_STAIRS: + Limit: -1 Points: 2 ACACIA_TRAPDOOR: + Limit: -1 Points: 3 ACACIA_WOOD: + Limit: -1 Points: 1 ACTIVATOR_RAIL: + Limit: -1 Points: 1 ALLIUM: + Limit: -1 Points: 1 ANDESITE: + Limit: -1 Points: 1 ANDESITE_SLAB: + Limit: -1 Points: 1 ANDESITE_STAIRS: + Limit: -1 Points: 1 ANDESITE_WALL: + Limit: -1 Points: 1 ANVIL: + Limit: -1 Points: 10 ATTACHED_MELON_STEM: + Limit: -1 Points: 1 ATTACHED_PUMPKIN_STEM: + Limit: -1 Points: 1 AZURE_BLUET: + Limit: -1 Points: 1 BARRIER: + Limit: -1 Points: 0 BAMBOO: + Limit: -1 Points: 1 BAMBOO_SAPLING: + Limit: -1 Points: 1 BARREL: + Limit: -1 Points: 1 BEACON: + Limit: -1 Points: 500 BEDROCK: + Limit: -1 Points: 0 BEETROOTS: + Limit: -1 Points: 1 BELL: + Limit: -1 Points: 7 BIRCH_BUTTON: + Limit: -1 Points: 1 BIRCH_DOOR: + Limit: -1 Points: 2 BIRCH_FENCE: + Limit: -1 Points: 2 BIRCH_FENCE_GATE: + Limit: -1 Points: 4 BIRCH_LEAVES: + Limit: -1 Points: 0 BIRCH_LOG: + Limit: -1 Points: 0 BIRCH_PLANKS: + Limit: -1 Points: 1 BIRCH_PRESSURE_PLATE: + Limit: -1 Points: 2 BIRCH_SAPLING: + Limit: -1 Points: 1 BIRCH_SIGN: + Limit: -1 Points: 6 BIRCH_SLAB: + Limit: -1 Points: 1 BIRCH_STAIRS: + Limit: -1 Points: 2 BIRCH_TRAPDOOR: + Limit: -1 Points: 3 BIRCH_WALL_SIGN: + Limit: -1 Points: 6 BIRCH_WOOD: + Limit: -1 Points: 1 BLACK_BANNER: + Limit: -1 Points: 2 BLACK_BED: + Limit: -1 Points: 6 BLACK_CARPET: + Limit: -1 Points: 1 BLACK_CONCRETE: + Limit: -1 Points: 3 BLACK_CONCRETE_POWDER: + Limit: -1 Points: 2 BLACK_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 BLACK_SHULKER_BOX: + Limit: -1 Points: 11 BLACK_STAINED_GLASS: + Limit: -1 Points: 2 BLACK_STAINED_GLASS_PANE: + Limit: -1 Points: 1 BLACK_TERRACOTTA: + Limit: -1 Points: 2 BLACK_WALL_BANNER: + Limit: -1 Points: 2 BLACK_WOOL: + Limit: -1 Points: 2 BLAST_FURNACE: + Limit: -1 Points: 6 BLUE_BANNER: + Limit: -1 Points: 2 BLUE_BED: + Limit: -1 Points: 6 BLUE_CARPET: + Limit: -1 Points: 1 BLUE_CONCRETE: + Limit: -1 Points: 3 BLUE_CONCRETE_POWDER: + Limit: -1 Points: 2 BLUE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 BLUE_ICE: + Limit: -1 Points: 1 BLUE_ORCHID: + Limit: -1 Points: 1 BLUE_SHULKER_BOX: + Limit: -1 Points: 11 BLUE_STAINED_GLASS: + Limit: -1 Points: 2 BLUE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 BLUE_TERRACOTTA: + Limit: -1 Points: 2 BLUE_WALL_BANNER: + Limit: -1 Points: 2 BLUE_WOOL: + Limit: -1 Points: 2 BONE_BLOCK: + Limit: -1 Points: 1 BOOKSHELF: + Limit: -1 Points: 5 BRAIN_CORAL: + Limit: -1 Points: 1 BRAIN_CORAL_BLOCK: + Limit: -1 Points: 1 BRAIN_CORAL_FAN: + Limit: -1 Points: 1 BRAIN_CORAL_WALL_FAN: + Limit: -1 Points: 1 BREWING_STAND: + Limit: -1 Points: 20 BRICKS: + Limit: -1 Points: 5 BRICK_SLAB: + Limit: -1 Points: 3 BRICK_STAIRS: + Limit: -1 Points: 5 BRICK_WALL: + Limit: -1 Points: 3 BROWN_BANNER: + Limit: -1 Points: 2 BROWN_BED: + Limit: -1 Points: 6 BROWN_CARPET: + Limit: -1 Points: 1 BROWN_CONCRETE: + Limit: -1 Points: 3 BROWN_CONCRETE_POWDER: + Limit: -1 Points: 2 BROWN_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 BROWN_MUSHROOM: + Limit: -1 Points: 1 BROWN_MUSHROOM_BLOCK: + Limit: -1 Points: 1 BROWN_SHULKER_BOX: + Limit: -1 Points: 11 BROWN_STAINED_GLASS: + Limit: -1 Points: 2 BROWN_STAINED_GLASS_PANE: + Limit: -1 Points: 1 BROWN_TERRACOTTA: + Limit: -1 Points: 2 BROWN_WALL_BANNER: + Limit: -1 Points: 2 BROWN_WOOL: + Limit: -1 Points: 1 BUBBLE_COLUMN: + Limit: -1 Points: 1 BUBBLE_CORAL: + Limit: -1 Points: 1 BUBBLE_CORAL_BLOCK: + Limit: -1 Points: 1 BUBBLE_CORAL_FAN: + Limit: -1 Points: 1 BUBBLE_CORAL_WALL_FAN: + Limit: -1 Points: 1 CACTUS: + Limit: -1 Points: 1 CAMPFIRE: + Limit: -1 Points: 2 CAKE: + Limit: -1 Points: 9 CARROTS: + Limit: -1 Points: 1 CARTOGRAPHY_TABLE: + Limit: -1 Points: 5 CARVED_PUMPKIN: + Limit: -1 Points: 2 CAULDRON: + Limit: -1 Points: 10 CAVE_AIR: + Limit: -1 Points: 0 CHAIN_COMMAND_BLOCK: + Limit: -1 Points: 0 CHEST: + Limit: -1 Points: 8 CHIPPED_ANVIL: + Limit: -1 Points: 9 CHISELED_QUARTZ_BLOCK: + Limit: -1 Points: 2 CHISELED_RED_SANDSTONE: + Limit: -1 Points: 2 CHISELED_SANDSTONE: + Limit: -1 Points: 2 CHISELED_STONE_BRICKS: + Limit: -1 Points: 2 CHORUS_FLOWER: + Limit: -1 Points: 1 CHORUS_PLANT: + Limit: -1 Points: 1 CLAY: + Limit: -1 Points: 2 COAL_BLOCK: + Limit: -1 Points: 9 COAL_ORE: + Limit: -1 Points: 1 COARSE_DIRT: + Limit: -1 Points: 2 COBBLESTONE: + Limit: -1 Points: 1 COBBLESTONE_SLAB: + Limit: -1 Points: 1 COBBLESTONE_STAIRS: + Limit: -1 Points: 2 COBBLESTONE_WALL: + Limit: -1 Points: 1 COBWEB: + Limit: -1 Points: 10 COCOA: + Limit: -1 Points: 1 COMMAND_BLOCK: + Limit: -1 Points: 0 COMPARATOR: + Limit: -1 Points: 10 COMPOSTER: + Limit: -1 Points: 4 CONDUIT: + Limit: -1 Points: 1 CORNFLOWER: + Limit: -1 Points: 1 CRACKED_STONE_BRICKS: + Limit: -1 Points: 2 CRAFTING_TABLE: + Limit: -1 Points: 1 CREEPER_HEAD: + Limit: -1 Points: 1 CREEPER_WALL_HEAD: + Limit: -1 Points: 1 CUT_RED_SANDSTONE: + Limit: -1 Points: 1 CUT_RED_SANDSTONE_SLAB: + Limit: -1 Points: 1 CUT_SANDSTONE: + Limit: -1 Points: 1 CUT_SANDSTONE_SLAB: + Limit: -1 Points: 1 CYAN_BANNER: + Limit: -1 Points: 2 CYAN_BED: + Limit: -1 Points: 6 CYAN_CARPET: + Limit: -1 Points: 1 CYAN_CONCRETE: + Limit: -1 Points: 3 CYAN_CONCRETE_POWDER: + Limit: -1 Points: 2 CYAN_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 CYAN_SHULKER_BOX: + Limit: -1 Points: 11 CYAN_STAINED_GLASS: + Limit: -1 Points: 2 CYAN_STAINED_GLASS_PANE: + Limit: -1 Points: 1 CYAN_TERRACOTTA: + Limit: -1 Points: 2 CYAN_WALL_BANNER: + Limit: -1 Points: 2 CYAN_WOOL: + Limit: -1 Points: 2 DAMAGED_ANVIL: + Limit: -1 Points: 5 DANDELION: + Limit: -1 Points: 1 DARK_OAK_BUTTON: + Limit: -1 Points: 1 DARK_OAK_DOOR: + Limit: -1 Points: 2 DARK_OAK_FENCE: + Limit: -1 Points: 2 DARK_OAK_FENCE_GATE: + Limit: -1 Points: 4 DARK_OAK_LEAVES: + Limit: -1 Points: 0 DARK_OAK_LOG: + Limit: -1 Points: 0 DARK_OAK_PLANKS: + Limit: -1 Points: 1 DARK_OAK_PRESSURE_PLATE: + Limit: -1 Points: 2 DARK_OAK_SAPLING: + Limit: -1 Points: 1 DARK_OAK_SIGN: + Limit: -1 Points: 6 DARK_OAK_SLAB: + Limit: -1 Points: 1 DARK_OAK_STAIRS: + Limit: -1 Points: 2 DARK_OAK_TRAPDOOR: + Limit: -1 Points: 3 DARK_OAK_WALL_SIGN: + Limit: -1 Points: 6 DARK_OAK_WOOD: + Limit: -1 Points: 1 DARK_PRISMARINE: + Limit: -1 Points: 1 DARK_PRISMARINE_SLAB: + Limit: -1 Points: 1 DARK_PRISMARINE_STAIRS: + Limit: -1 Points: 2 DAYLIGHT_DETECTOR: + Limit: -1 Points: 10 DEAD_BRAIN_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_BRAIN_CORAL_FAN: + Limit: -1 Points: 1 DEAD_BRAIN_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_BUBBLE_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_BUBBLE_CORAL_FAN: + Limit: -1 Points: 1 DEAD_BUBBLE_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_BUSH: + Limit: -1 Points: 1 DEAD_FIRE_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_FIRE_CORAL_FAN: + Limit: -1 Points: 1 DEAD_FIRE_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_HORN_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_HORN_CORAL_FAN: + Limit: -1 Points: 1 DEAD_HORN_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_TUBE_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_TUBE_CORAL_FAN: + Limit: -1 Points: 1 DEAD_TUBE_CORAL_WALL_FAN: + Limit: -1 Points: 1 DETECTOR_RAIL: + Limit: -1 Points: 10 DIAMOND_BLOCK: + Limit: -1 Points: 300 DIAMOND_ORE: + Limit: -1 Points: 1 DIORITE: + Limit: -1 Points: 1 DIORITE_SLAB: + Limit: -1 Points: 1 DIORITE_STAIRS: + Limit: -1 Points: 1 DIORITE_WALL: + Limit: -1 Points: 1 DIRT: + Limit: -1 Points: 3 DISPENSER: + Limit: -1 Points: 5 DRAGON_EGG: + Limit: -1 Points: 150 DRAGON_HEAD: + Limit: -1 Points: 1 DRAGON_WALL_HEAD: + Limit: -1 Points: 1 DRIED_KELP_BLOCK: + Limit: -1 Points: 1 DROPPER: + Limit: -1 Points: 4 EMERALD_BLOCK: + Limit: -1 Points: 150 EMERALD_ORE: + Limit: -1 Points: 1 ENCHANTING_TABLE: + Limit: -1 Points: 150 ENDER_CHEST: + Limit: -1 Points: 150 END_GATEWAY: + Limit: -1 Points: 0 END_PORTAL: + Limit: -1 Points: 0 END_PORTAL_FRAME: + Limit: -1 Points: 0 END_ROD: + Limit: -1 Points: 1 END_STONE: + Limit: -1 Points: 1 END_STONE_BRICK_SLAB: + Limit: -1 Points: 1 END_STONE_BRICK_STAIRS: + Limit: -1 Points: 1 END_STONE_BRICK_WALL: + Limit: -1 Points: 1 END_STONE_BRICKS: + Limit: -1 Points: 2 FARMLAND: + Limit: -1 Points: 1 FERN: + Limit: -1 Points: 1 FIRE: + Limit: -1 Points: 0 FIRE_CORAL: + Limit: -1 Points: 1 FIRE_CORAL_BLOCK: + Limit: -1 Points: 1 FIRE_CORAL_FAN: + Limit: -1 Points: 1 FIRE_CORAL_WALL_FAN: + Limit: -1 Points: 1 FLETCHING_TABLE: + Limit: -1 Points: 4 FLOWER_POT: + Limit: -1 Points: 1 FROSTED_ICE: + Limit: -1 Points: 1 FURNACE: + Limit: -1 Points: 8 GLASS: + Limit: -1 Points: 2 GLASS_PANE: + Limit: -1 Points: 1 GLOWSTONE: + Limit: -1 Points: 1 GOLD_BLOCK: + Limit: -1 Points: 150 GOLD_ORE: + Limit: -1 Points: 1 GRANITE: + Limit: -1 Points: 1 GRANITE_SLAB: + Limit: -1 Points: 1 GRANITE_STAIRS: + Limit: -1 Points: 1 GRANITE_WALL: + Limit: -1 Points: 1 GRASS: + Limit: -1 Points: 4 GRASS_BLOCK: + Limit: -1 Points: 4 GRASS_PATH: + Limit: -1 Points: 4 GRAVEL: + Limit: -1 Points: 1 GRAY_BANNER: + Limit: -1 Points: 2 GRAY_BED: + Limit: -1 Points: 6 GRAY_CARPET: + Limit: -1 Points: 1 GRAY_CONCRETE: + Limit: -1 Points: 3 GRAY_CONCRETE_POWDER: + Limit: -1 Points: 2 GRAY_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 GRAY_SHULKER_BOX: + Limit: -1 Points: 11 GRAY_STAINED_GLASS: + Limit: -1 Points: 2 GRAY_STAINED_GLASS_PANE: + Limit: -1 Points: 1 GRAY_TERRACOTTA: + Limit: -1 Points: 2 GRAY_WALL_BANNER: + Limit: -1 Points: 2 GRAY_WOOL: + Limit: -1 Points: 2 GREEN_BANNER: + Limit: -1 Points: 2 GREEN_BED: + Limit: -1 Points: 6 GREEN_CARPET: + Limit: -1 Points: 1 GREEN_CONCRETE: + Limit: -1 Points: 3 GREEN_CONCRETE_POWDER: + Limit: -1 Points: 2 GREEN_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 GREEN_SHULKER_BOX: + Limit: -1 Points: 11 GREEN_STAINED_GLASS: + Limit: -1 Points: 2 GREEN_STAINED_GLASS_PANE: + Limit: -1 Points: 1 GREEN_TERRACOTTA: + Limit: -1 Points: 2 GREEN_WALL_BANNER: + Limit: -1 Points: 2 GREEN_WOOL: + Limit: -1 Points: 2 GRINDSTONE: + Limit: -1 Points: 4 HAY_BLOCK: + Limit: -1 Points: 2 HEAVY_WEIGHTED_PRESSURE_PLATE: + Limit: -1 Points: 3 HOPPER: + Limit: -1 Points: 5 HORN_CORAL: + Limit: -1 Points: 1 HORN_CORAL_BLOCK: + Limit: -1 Points: 1 HORN_CORAL_FAN: + Limit: -1 Points: 1 HORN_CORAL_WALL_FAN: + Limit: -1 Points: 1 ICE: + Limit: -1 Points: 5 INFESTED_CHISELED_STONE_BRICKS: + Limit: -1 Points: 2 INFESTED_COBBLESTONE: + Limit: -1 Points: 1 INFESTED_CRACKED_STONE_BRICKS: + Limit: -1 Points: 2 INFESTED_MOSSY_STONE_BRICKS: + Limit: -1 Points: 2 INFESTED_STONE: + Limit: -1 Points: 1 INFESTED_STONE_BRICKS: + Limit: -1 Points: 2 IRON_BARS: + Limit: -1 Points: 2 IRON_BLOCK: + Limit: -1 Points: 10 IRON_DOOR: + Limit: -1 Points: 5 IRON_ORE: + Limit: -1 Points: 1 IRON_TRAPDOOR: + Limit: -1 Points: 4 JACK_O_LANTERN: + Limit: -1 Points: 2 JIGSAW: + Limit: -1 Points: 4 JUKEBOX: + Limit: -1 Points: 10 JUNGLE_BUTTON: + Limit: -1 Points: 1 JUNGLE_DOOR: + Limit: -1 Points: 2 JUNGLE_FENCE: + Limit: -1 Points: 2 JUNGLE_FENCE_GATE: + Limit: -1 Points: 4 JUNGLE_LEAVES: + Limit: -1 Points: 0 JUNGLE_LOG: + Limit: -1 Points: 0 JUNGLE_PLANKS: + Limit: -1 Points: 1 JUNGLE_PRESSURE_PLATE: + Limit: -1 Points: 2 JUNGLE_SAPLING: + Limit: -1 Points: 1 JUNGLE_SIGN: + Limit: -1 Points: 6 JUNGLE_SLAB: + Limit: -1 Points: 1 JUNGLE_STAIRS: + Limit: -1 Points: 2 JUNGLE_TRAPDOOR: + Limit: -1 Points: 3 JUNGLE_WALL_SIGN: + Limit: -1 Points: 6 JUNGLE_WOOD: + Limit: -1 Points: 1 KELP: + Limit: -1 Points: 1 KELP_PLANT: + Limit: -1 Points: 1 LADDER: + Limit: -1 Points: 2 LANTERN: + Limit: -1 Points: 3 LAPIS_BLOCK: + Limit: -1 Points: 10 LAPIS_ORE: + Limit: -1 Points: 1 LARGE_FERN: + Limit: -1 Points: 1 LECTERN: + Limit: -1 Points: 4 LEVER: + Limit: -1 Points: 1 LIGHT_BLUE_BANNER: + Limit: -1 Points: 2 LIGHT_BLUE_BED: + Limit: -1 Points: 6 LIGHT_BLUE_CARPET: + Limit: -1 Points: 1 LIGHT_BLUE_CONCRETE: + Limit: -1 Points: 2 LIGHT_BLUE_CONCRETE_POWDER: + Limit: -1 Points: 2 LIGHT_BLUE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 LIGHT_BLUE_SHULKER_BOX: + Limit: -1 Points: 11 LIGHT_BLUE_STAINED_GLASS: + Limit: -1 Points: 2 LIGHT_BLUE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 LIGHT_BLUE_TERRACOTTA: + Limit: -1 Points: 2 LIGHT_BLUE_WALL_BANNER: + Limit: -1 Points: 2 LIGHT_BLUE_WOOL: + Limit: -1 Points: 2 LIGHT_GRAY_BANNER: + Limit: -1 Points: 2 LIGHT_GRAY_BED: + Limit: -1 Points: 6 LIGHT_GRAY_CARPET: + Limit: -1 Points: 1 LIGHT_GRAY_CONCRETE: + Limit: -1 Points: 3 LIGHT_GRAY_CONCRETE_POWDER: + Limit: -1 Points: 2 LIGHT_GRAY_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 LIGHT_GRAY_SHULKER_BOX: + Limit: -1 Points: 11 LIGHT_GRAY_STAINED_GLASS: + Limit: -1 Points: 2 LIGHT_GRAY_STAINED_GLASS_PANE: + Limit: -1 Points: 1 LIGHT_GRAY_TERRACOTTA: + Limit: -1 Points: 2 LIGHT_GRAY_WALL_BANNER: + Limit: -1 Points: 2 LIGHT_GRAY_WOOL: + Limit: -1 Points: 2 LIGHT_WEIGHTED_PRESSURE_PLATE: + Limit: -1 Points: 3 LILAC: + Limit: -1 Points: 1 LILY_OF_THE_VALLEY: + Limit: -1 Points: 1 LILY_PAD: + Limit: -1 Points: 5 LIME_BANNER: + Limit: -1 Points: 2 LIME_BED: + Limit: -1 Points: 6 LIME_CARPET: + Limit: -1 Points: 1 LIME_CONCRETE: + Limit: -1 Points: 3 LIME_CONCRETE_POWDER: + Limit: -1 Points: 2 LIME_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 LIME_SHULKER_BOX: + Limit: -1 Points: 11 LIME_STAINED_GLASS: + Limit: -1 Points: 2 LIME_STAINED_GLASS_PANE: + Limit: -1 Points: 1 LIME_TERRACOTTA: + Limit: -1 Points: 2 LIME_WALL_BANNER: + Limit: -1 Points: 2 LIME_WOOL: + Limit: -1 Points: 2 LOOM: + Limit: -1 Points: 4 MAGENTA_BANNER: + Limit: -1 Points: 2 MAGENTA_BED: + Limit: -1 Points: 6 MAGENTA_CARPET: + Limit: -1 Points: 1 MAGENTA_CONCRETE: + Limit: -1 Points: 3 MAGENTA_CONCRETE_POWDER: + Limit: -1 Points: 2 MAGENTA_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 MAGENTA_SHULKER_BOX: + Limit: -1 Points: 11 MAGENTA_STAINED_GLASS: + Limit: -1 Points: 2 MAGENTA_STAINED_GLASS_PANE: + Limit: -1 Points: 1 MAGENTA_TERRACOTTA: + Limit: -1 Points: 2 MAGENTA_WALL_BANNER: + Limit: -1 Points: 2 MAGENTA_WOOL: + Limit: -1 Points: 2 MAGMA_BLOCK: + Limit: -1 Points: 1 MELON: + Limit: -1 Points: 1 MELON_STEM: + Limit: -1 Points: 1 MOSSY_COBBLESTONE: + Limit: -1 Points: 1 MOSSY_COBBLESTONE_SLAB: + Limit: -1 Points: 1 MOSSY_COBBLESTONE_STAIRS: + Limit: -1 Points: 1 MOSSY_COBBLESTONE_WALL: + Limit: -1 Points: 1 MOSSY_STONE_BRICK_SLAB: + Limit: -1 Points: 1 MOSSY_STONE_BRICK_STAIRS: + Limit: -1 Points: 1 MOSSY_STONE_BRICK_WALL: + Limit: -1 Points: 1 MOSSY_STONE_BRICKS: + Limit: -1 Points: 1 MOVING_PISTON: + Limit: -1 Points: 1 MUSHROOM_STEM: + Limit: -1 Points: 1 MYCELIUM: + Limit: -1 Points: 5 NETHERRACK: + Limit: -1 Points: 1 NETHER_BRICK_WALL: + Limit: -1 Points: 1 NETHER_BRICKS: + Limit: -1 Points: 2 NETHER_BRICK_FENCE: + Limit: -1 Points: 2 NETHER_BRICK_SLAB: + Limit: -1 Points: 1 NETHER_BRICK_STAIRS: + Limit: -1 Points: 2 NETHER_PORTAL: + Limit: -1 Points: 1 NETHER_QUARTZ_ORE: + Limit: -1 Points: 1 NETHER_WART: + Limit: -1 Points: 1 NETHER_WART_BLOCK: + Limit: -1 Points: 2 NOTE_BLOCK: + Limit: -1 Points: 10 OAK_BUTTON: + Limit: -1 Points: 1 OAK_DOOR: + Limit: -1 Points: 2 OAK_FENCE: + Limit: -1 Points: 2 OAK_FENCE_GATE: + Limit: -1 Points: 4 OAK_LEAVES: + Limit: -1 Points: 0 OAK_LOG: + Limit: -1 Points: 0 OAK_PLANKS: + Limit: -1 Points: 1 OAK_PRESSURE_PLATE: + Limit: -1 Points: 2 OAK_SAPLING: + Limit: -1 Points: 1 OAK_SIGN: + Limit: -1 Points: 6 OAK_SLAB: + Limit: -1 Points: 1 OAK_STAIRS: + Limit: -1 Points: 2 OAK_TRAPDOOR: + Limit: -1 Points: 3 OAK_WALL_SIGN: + Limit: -1 Points: 6 OAK_WOOD: + Limit: -1 Points: 1 OBSERVER: + Limit: -1 Points: 1 OBSIDIAN: + Limit: -1 Points: 10 ORANGE_BANNER: + Limit: -1 Points: 2 ORANGE_BED: + Limit: -1 Points: 6 ORANGE_CARPET: + Limit: -1 Points: 1 ORANGE_CONCRETE: + Limit: -1 Points: 3 ORANGE_CONCRETE_POWDER: + Limit: -1 Points: 2 ORANGE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 ORANGE_SHULKER_BOX: + Limit: -1 Points: 11 ORANGE_STAINED_GLASS: + Limit: -1 Points: 2 ORANGE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 ORANGE_TERRACOTTA: + Limit: -1 Points: 2 ORANGE_TULIP: + Limit: -1 Points: 1 ORANGE_WALL_BANNER: + Limit: -1 Points: 2 ORANGE_WOOL: + Limit: -1 Points: 2 OXEYE_DAISY: + Limit: -1 Points: 1 PACKED_ICE: + Limit: -1 Points: 5 PEONY: + Limit: -1 Points: 1 PETRIFIED_OAK_SLAB: + Limit: -1 Points: 1 PINK_BANNER: + Limit: -1 Points: 2 PINK_BED: + Limit: -1 Points: 6 PINK_CARPET: + Limit: -1 Points: 1 PINK_CONCRETE: + Limit: -1 Points: 3 PINK_CONCRETE_POWDER: + Limit: -1 Points: 2 PINK_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 PINK_SHULKER_BOX: + Limit: -1 Points: 11 PINK_STAINED_GLASS: + Limit: -1 Points: 2 PINK_STAINED_GLASS_PANE: + Limit: -1 Points: 1 PINK_TERRACOTTA: + Limit: -1 Points: 2 PINK_TULIP: + Limit: -1 Points: 1 PINK_WALL_BANNER: + Limit: -1 Points: 2 PINK_WOOL: + Limit: -1 Points: 2 PISTON: + Limit: -1 Points: 2 PISTON_HEAD: + Limit: -1 Points: 1 PLAYER_HEAD: + Limit: -1 Points: 1 PLAYER_WALL_HEAD: + Limit: -1 Points: 1 PODZOL: + Limit: -1 Points: 2 POLISHED_ANDESITE: + Limit: -1 Points: 1 POLISHED_ANDESITE_SLAB: + Limit: -1 Points: 1 POLISHED_ANDESITE_STAIRS: + Limit: -1 Points: 1 POLISHED_DIORITE: + Limit: -1 Points: 1 POLISHED_DIORITE_SLAB: + Limit: -1 Points: 1 POLISHED_DIORITE_STAIRS: + Limit: -1 Points: 1 POLISHED_GRANITE: + Limit: -1 Points: 1 POLISHED_GRANITE_SLAB: + Limit: -1 Points: 1 POLISHED_GRANITE_STAIRS: + Limit: -1 Points: 1 POPPY: + Limit: -1 Points: 1 POTATOES: + Limit: -1 Points: 1 POTTED_ACACIA_SAPLING: + Limit: -1 Points: 1 POTTED_ALLIUM: + Limit: -1 Points: 1 POTTED_AZURE_BLUET: + Limit: -1 Points: 1 POTTED_BAMBOO: + Limit: -1 Points: 1 POTTED_BIRCH_SAPLING: + Limit: -1 Points: 1 POTTED_BLUE_ORCHID: + Limit: -1 Points: 1 POTTED_BROWN_MUSHROOM: + Limit: -1 Points: 1 POTTED_CACTUS: + Limit: -1 Points: 1 POTTED_CORNFLOWER: + Limit: -1 Points: 1 POTTED_DANDELION: + Limit: -1 Points: 1 POTTED_DARK_OAK_SAPLING: + Limit: -1 Points: 1 POTTED_DEAD_BUSH: + Limit: -1 Points: 1 POTTED_FERN: + Limit: -1 Points: 1 POTTED_JUNGLE_SAPLING: + Limit: -1 Points: 1 POTTED_LILY_OF_THE_VALLEY: + Limit: -1 Points: 1 POTTED_OAK_SAPLING: + Limit: -1 Points: 1 POTTED_ORANGE_TULIP: + Limit: -1 Points: 1 POTTED_OXEYE_DAISY: + Limit: -1 Points: 1 POTTED_PINK_TULIP: + Limit: -1 Points: 1 POTTED_POPPY: + Limit: -1 Points: 1 POTTED_RED_MUSHROOM: + Limit: -1 Points: 1 POTTED_RED_TULIP: + Limit: -1 Points: 1 POTTED_SPRUCE_SAPLING: + Limit: -1 Points: 1 POTTED_WHITE_TULIP: + Limit: -1 Points: 1 POTTED_WITHER_ROSE: + Limit: -1 Points: 1 POWERED_RAIL: + Limit: -1 Points: 2 PRISMARINE: + Limit: -1 Points: 1 PRISMARINE_BRICKS: + Limit: -1 Points: 2 PRISMARINE_BRICK_SLAB: + Limit: -1 Points: 1 PRISMARINE_BRICK_STAIRS: + Limit: -1 Points: 2 PRISMARINE_SLAB: + Limit: -1 Points: 1 PRISMARINE_STAIRS: + Limit: -1 Points: 2 PRISMARINE_WALL: + Limit: -1 Points: 1 PUMPKIN: + Limit: -1 Points: 1 PUMPKIN_STEM: + Limit: -1 Points: 1 PURPLE_BANNER: + Limit: -1 Points: 2 PURPLE_BED: + Limit: -1 Points: 6 PURPLE_CARPET: + Limit: -1 Points: 1 PURPLE_CONCRETE: + Limit: -1 Points: 3 PURPLE_CONCRETE_POWDER: + Limit: -1 Points: 2 PURPLE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 PURPLE_SHULKER_BOX: + Limit: -1 Points: 11 PURPLE_STAINED_GLASS: + Limit: -1 Points: 2 PURPLE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 PURPLE_TERRACOTTA: + Limit: -1 Points: 2 PURPLE_WALL_BANNER: + Limit: -1 Points: 2 PURPLE_WOOL: + Limit: -1 Points: 2 PURPUR_BLOCK: + Limit: -1 Points: 1 PURPUR_PILLAR: + Limit: -1 Points: 1 PURPUR_SLAB: + Limit: -1 Points: 1 PURPUR_STAIRS: + Limit: -1 Points: 2 QUARTZ_BLOCK: + Limit: -1 Points: 1 QUARTZ_PILLAR: + Limit: -1 Points: 1 QUARTZ_SLAB: + Limit: -1 Points: 1 QUARTZ_STAIRS: + Limit: -1 Points: 2 RAIL: + Limit: -1 Points: 1 REDSTONE_BLOCK: + Limit: -1 Points: 10 REDSTONE_LAMP: + Limit: -1 Points: 10 REDSTONE_ORE: + Limit: -1 Points: 1 REDSTONE_TORCH: + Limit: -1 Points: 5 REDSTONE_WALL_TORCH: + Limit: -1 Points: 5 REDSTONE_WIRE: + Limit: -1 Points: 1 RED_BED: + Limit: -1 Points: 6 RED_CARPET: + Limit: -1 Points: 1 RED_CONCRETE: + Limit: -1 Points: 3 RED_CONCRETE_POWDER: + Limit: -1 Points: 2 RED_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 RED_MUSHROOM: + Limit: -1 Points: 1 RED_MUSHROOM_BLOCK: + Limit: -1 Points: 1 RED_NETHER_BRICK_SLAB: + Limit: -1 Points: 1 RED_NETHER_BRICK_STAIRS: + Limit: -1 Points: 1 RED_NETHER_BRICK_WALL: + Limit: -1 Points: 1 RED_NETHER_BRICKS: + Limit: -1 Points: 2 RED_SAND: + Limit: -1 Points: 1 RED_SANDSTONE: + Limit: -1 Points: 1 RED_SANDSTONE_SLAB: + Limit: -1 Points: 1 RED_SANDSTONE_STAIRS: + Limit: -1 Points: 2 RED_SANDSTONE_WALL: + Limit: -1 Points: 1 RED_SHULKER_BOX: + Limit: -1 Points: 11 RED_STAINED_GLASS: + Limit: -1 Points: 2 RED_STAINED_GLASS_PANE: + Limit: -1 Points: 1 RED_TERRACOTTA: + Limit: -1 Points: 2 RED_TULIP: + Limit: -1 Points: 1 RED_WALL_BANNER: + Limit: -1 Points: 2 RED_WOOL: + Limit: -1 Points: 1 REPEATER: + Limit: -1 Points: 6 REPEATING_COMMAND_BLOCK: + Limit: -1 Points: 0 ROSE_BUSH: + Limit: -1 Points: 1 SAND: + Limit: -1 Points: 1 SANDSTONE: + Limit: -1 Points: 1 SANDSTONE_SLAB: + Limit: -1 Points: 1 SANDSTONE_STAIRS: + Limit: -1 Points: 2 SANDSTONE_WALL: + Limit: -1 Points: 1 SCAFFOLDING: + Limit: -1 Points: 1 SEAGRASS: + Limit: -1 Points: 1 SEA_LANTERN: + Limit: -1 Points: 9 SEA_PICKLE: + Limit: -1 Points: 1 SHULKER_BOX: + Limit: -1 Points: 10 SKELETON_SKULL: + Limit: -1 Points: 10 SKELETON_WALL_SKULL: + Limit: -1 Points: 10 SLIME_BLOCK: + Limit: -1 Points: 10 SMITHING_TABLE: + Limit: -1 Points: 4 SMOKER: + Limit: -1 Points: 4 SMOOTH_QUARTZ: + Limit: -1 Points: 1 SMOOTH_QUARTZ_SLAB: + Limit: -1 Points: 1 SMOOTH_QUARTZ_STAIRS: + Limit: -1 Points: 1 SMOOTH_RED_SANDSTONE: + Limit: -1 Points: 1 SMOOTH_SANDSTONE: + Limit: -1 Points: 1 SMOOTH_SANDSTONE_SLAB: + Limit: -1 Points: 1 SMOOTH_SANDSTONE_STAIRS: + Limit: -1 Points: 1 SMOOTH_STONE: + Limit: -1 Points: 1 SMOOTH_STONE_SLAB: + Limit: -1 Points: 1 SNOW: + Limit: -1 Points: 1 SNOW_BLOCK: + Limit: -1 Points: 1 SOUL_SAND: + Limit: -1 Points: 1 SPAWNER: + Limit: -1 Points: 10 SPAWNER_BAT: + Limit: -1 Points: 10 SPAWNER_BLAZE: + Limit: -1 Points: 10 SPAWNER_CAVE_SPIDER: + Limit: -1 Points: 10 SPAWNER_CHICKEN: + Limit: -1 Points: 10 SPAWNER_COD: + Limit: -1 Points: 10 SPAWNER_COW: + Limit: -1 Points: 10 SPAWNER_CREEPER: + Limit: -1 Points: 10 SPAWNER_DOLPHIN: + Limit: -1 Points: 10 SPAWNER_DONKEY: + Limit: -1 Points: 10 SPAWNER_DROWNED: + Limit: -1 Points: 10 SPAWNER_ELDER_GUARDIAN: + Limit: -1 Points: 10 SPAWNER_ENDER_DRAGON: + Limit: -1 Points: 10 SPAWNER_ENDERMAN: + Limit: -1 Points: 10 SPAWNER_ENDERMITE: + Limit: -1 Points: 10 SPAWNER_EVOKER: + Limit: -1 Points: 10 SPAWNER_GHAST: + Limit: -1 Points: 10 SPAWNER_GIANT: + Limit: -1 Points: 10 SPAWNER_GUARDIAN: + Limit: -1 Points: 10 SPAWNER_HORSE: + Limit: -1 Points: 10 SPAWNER_HUSK: + Limit: -1 Points: 10 SPAWNER_ILLUSIONER: + Limit: -1 Points: 10 SPAWNER_IRON_GOLEM: + Limit: -1 Points: 10 SPAWNER_LLAMA: + Limit: -1 Points: 10 SPAWNER_MAGMA_CUBE: + Limit: -1 Points: 10 SPAWNER_MULE: + Limit: -1 Points: 10 SPAWNER_MUSHROOM_COW: + Limit: -1 Points: 10 SPAWNER_OCELOT: + Limit: -1 Points: 10 SPAWNER_PARROT: + Limit: -1 Points: 10 SPAWNER_PHANTOM: + Limit: -1 Points: 10 SPAWNER_PIG: + Limit: -1 Points: 10 SPAWNER_PIG_ZOMBIE: + Limit: -1 Points: 10 SPAWNER_POLAR_BEAR: + Limit: -1 Points: 10 SPAWNER_PUFFERFISH: + Limit: -1 Points: 10 SPAWNER_RABBIT: + Limit: -1 Points: 10 SPAWNER_SALMON: + Limit: -1 Points: 10 SPAWNER_SHEEP: + Limit: -1 Points: 10 SPAWNER_SHULKER: + Limit: -1 Points: 10 SPAWNER_SILVERFISH: + Limit: -1 Points: 10 SPAWNER_SKELETON: + Limit: -1 Points: 10 SPAWNER_SKELETON_HORSE: + Limit: -1 Points: 10 SPAWNER_SLIME: + Limit: -1 Points: 10 SPAWNER_SNOWMAN: + Limit: -1 Points: 10 SPAWNER_SPIDER: + Limit: -1 Points: 10 SPAWNER_SQUID: + Limit: -1 Points: 10 SPAWNER_STRAY: + Limit: -1 Points: 10 SPAWNER_TROPICAL_FISH: + Limit: -1 Points: 10 SPAWNER_TURTLE: + Limit: -1 Points: 10 SPAWNER_VEX: + Limit: -1 Points: 10 SPAWNER_VILLAGER: + Limit: -1 Points: 10 SPAWNER_VINDICATOR: + Limit: -1 Points: 10 SPAWNER_WITCH: + Limit: -1 Points: 10 SPAWNER_WITHER: + Limit: -1 Points: 10 SPAWNER_WITHER_SKELETON: + Limit: -1 Points: 10 SPAWNER_WOLF: + Limit: -1 Points: 10 SPAWNER_ZOMBIE: + Limit: -1 Points: 10 SPAWNER_ZOMBIE_HORSE: + Limit: -1 Points: 10 SPAWNER_ZOMBIE_VILLAGER: + Limit: -1 Points: 10 SPONGE: + Limit: -1 Points: 10 SPRUCE_BUTTON: + Limit: -1 Points: 1 SPRUCE_DOOR: + Limit: -1 Points: 2 SPRUCE_FENCE: + Limit: -1 Points: 2 SPRUCE_FENCE_GATE: + Limit: -1 Points: 4 SPRUCE_LEAVES: + Limit: -1 Points: 0 SPRUCE_LOG: + Limit: -1 Points: 0 SPRUCE_PLANKS: + Limit: -1 Points: 1 SPRUCE_PRESSURE_PLATE: + Limit: -1 Points: 2 SPRUCE_SAPLING: + Limit: -1 Points: 1 SPRUCE_SIGN: + Limit: -1 Points: 6 SPRUCE_SLAB: + Limit: -1 Points: 1 SPRUCE_STAIRS: + Limit: -1 Points: 2 SPRUCE_TRAPDOOR: + Limit: -1 Points: 3 SPRUCE_WALL_SIGN: + Limit: -1 Points: 6 SPRUCE_WOOD: + Limit: -1 Points: 1 STICKY_PISTON: + Limit: -1 Points: 1 STONE: + Limit: -1 Points: 1 STONE_BRICKS: + Limit: -1 Points: 2 STONE_BRICK_SLAB: + Limit: -1 Points: 1 STONE_BRICK_STAIRS: + Limit: -1 Points: 2 STONE_BRICK_WALL: + Limit: -1 Points: 1 STONE_BUTTON: + Limit: -1 Points: 1 STONECUTTER: + Limit: -1 Points: 4 STONE_PRESSURE_PLATE: + Limit: -1 Points: 2 STONE_SLAB: + Limit: -1 Points: 1 STONE_STAIRS: + Limit: -1 Points: 1 STRIPPED_ACACIA_LOG: + Limit: -1 Points: 0 STRIPPED_ACACIA_WOOD: + Limit: -1 Points: 1 STRIPPED_BIRCH_LOG: + Limit: -1 Points: 0 STRIPPED_BIRCH_WOOD: + Limit: -1 Points: 1 STRIPPED_DARK_OAK_LOG: + Limit: -1 Points: 0 STRIPPED_DARK_OAK_WOOD: + Limit: -1 Points: 1 STRIPPED_JUNGLE_LOG: + Limit: -1 Points: 0 STRIPPED_JUNGLE_WOOD: + Limit: -1 Points: 1 STRIPPED_OAK_LOG: + Limit: -1 Points: 0 STRIPPED_OAK_WOOD: + Limit: -1 Points: 1 STRIPPED_SPRUCE_LOG: + Limit: -1 Points: 0 STRIPPED_SPRUCE_WOOD: + Limit: -1 Points: 1 SUGAR_CANE: + Limit: -1 Points: 1 SUNFLOWER: + Limit: -1 Points: 1 SWEET_BERRY_BUSH: + Limit: -1 Points: 1 TALL_GRASS: + Limit: -1 Points: 1 TALL_SEAGRASS: + Limit: -1 Points: 1 TERRACOTTA: + Limit: -1 Points: 2 TNT: + Limit: -1 Points: 5 TORCH: + Limit: -1 Points: 1 TRAPPED_CHEST: + Limit: -1 Points: 10 TRIPWIRE: + Limit: -1 Points: 2 TRIPWIRE_HOOK: + Limit: -1 Points: 2 TUBE_CORAL: + Limit: -1 Points: 1 TUBE_CORAL_BLOCK: + Limit: -1 Points: 1 TUBE_CORAL_FAN: + Limit: -1 Points: 1 TUBE_CORAL_WALL_FAN: + Limit: -1 Points: 1 TURTLE_EGG: + Limit: -1 Points: 1 VINE: + Limit: -1 Points: 1 VOID_AIR: + Limit: -1 Points: 0 WALL_TORCH: + Limit: -1 Points: 1 WET_SPONGE: + Limit: -1 Points: 10 WHEAT: + Limit: -1 Points: 1 WHITE_BANNER: + Limit: -1 Points: 2 WHITE_BED: + Limit: -1 Points: 6 WHITE_CARPET: + Limit: -1 Points: 1 WHITE_CONCRETE: + Limit: -1 Points: 3 WHITE_CONCRETE_POWDER: + Limit: -1 Points: 2 WHITE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 WHITE_SHULKER_BOX: + Limit: -1 Points: 11 WHITE_STAINED_GLASS: + Limit: -1 Points: 2 WHITE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 WHITE_TERRACOTTA: + Limit: -1 Points: 2 WHITE_TULIP: + Limit: -1 Points: 1 WHITE_WALL_BANNER: + Limit: -1 Points: 2 WHITE_WOOL: + Limit: -1 Points: 3 WITHER_ROSE: + Limit: -1 Points: 1 WITHER_SKELETON_SKULL: + Limit: -1 Points: 10 WITHER_SKELETON_WALL_SKULL: + Limit: -1 Points: 10 YELLOW_BANNER: + Limit: -1 Points: 2 YELLOW_BED: + Limit: -1 Points: 6 YELLOW_CARPET: + Limit: -1 Points: 1 YELLOW_CONCRETE: + Limit: -1 Points: 2 YELLOW_CONCRETE_POWDER: + Limit: -1 Points: 2 YELLOW_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 YELLOW_SHULKER_BOX: + Limit: -1 Points: 11 YELLOW_STAINED_GLASS: + Limit: -1 Points: 2 YELLOW_STAINED_GLASS_PANE: + Limit: -1 Points: 1 YELLOW_TERRACOTTA: + Limit: -1 Points: 2 YELLOW_WALL_BANNER: + Limit: -1 Points: 2 YELLOW_WOOL: + Limit: -1 Points: 2 ZOMBIE_HEAD: + Limit: -1 Points: 1 ZOMBIE_WALL_HEAD: + Limit: -1 Points: 1 \ No newline at end of file From 46495540c1b831fd0c0b236088b7c7498c1c92e6 Mon Sep 17 00:00:00 2001 From: WolfDW Date: Thu, 25 Jun 2020 02:40:41 +0000 Subject: [PATCH 099/366] Added island score block limits. --- src/main/java/com/songoda/skyblock/menus/Levelling.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index a9735189..300893cb 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -260,7 +260,14 @@ public class Levelling { inventorySlot++; - long pointsEarned = materialAmount * pointsMultiplier; + long materialLimit = mainConfig.getFileConfiguration().getLong("Materials." + material + ".Limit", materialAmount); + long materialAmountCounted = Math.min(materialLimit, materialAmount); + + if (materialLimit == -1) + materialAmountCounted = materialAmount; + + long pointsEarned = materialAmountCounted * pointsMultiplier; + String name = skyblock.getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(materials); From 4bac2282c81f58e230ba423fa4b7dcd1c9edcf47 Mon Sep 17 00:00:00 2001 From: WolfDW Date: Thu, 25 Jun 2020 02:44:08 +0000 Subject: [PATCH 100/366] Added island score block limits. --- .../songoda/skyblock/island/IslandLevel.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java index be1825f3..9d3d9784 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java @@ -78,8 +78,15 @@ public class IslandLevel { if (current == null) continue; long pointsRequired = current.getLong("Points", 0); + long blockAmount = entry.getValue(); - if (pointsRequired != 0) pointsEarned = pointsEarned + (entry.getValue() * pointsRequired); + long materialLimit = current.getLong("Limit", -1); + long materialAmountCounted = Math.min(materialLimit, blockAmount); + + if (materialLimit == -1) + materialAmountCounted = blockAmount; + + if (pointsRequired != 0) pointsEarned = pointsEarned + (materialAmountCounted * pointsRequired); } @@ -99,12 +106,17 @@ public class IslandLevel { if (current == null) return 0; Long boxedAmount = this.materials.get(material); - if (boxedAmount == null) return 0; + long materialLimit = current.getLong("Limit", -1); + long materialAmountCounted = Math.min(materialLimit, boxedAmount); + + if (materialLimit == -1) + materialAmountCounted = boxedAmount; + long pointsRequired = current.getLong("Points"); - return pointsRequired == 0 ? 0 : boxedAmount * pointsRequired; + return pointsRequired == 0 ? 0 : materialAmountCounted * pointsRequired; } public long getLevel() { From 5cc02f4e676864d427d2d645870bba8543ddd377 Mon Sep 17 00:00:00 2001 From: WolfDW Date: Thu, 25 Jun 2020 02:44:54 +0000 Subject: [PATCH 101/366] Added island score block limits. --- src/main/java/com/songoda/skyblock/menus/Levelling.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index 300893cb..f879a80b 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -260,7 +260,7 @@ public class Levelling { inventorySlot++; - long materialLimit = mainConfig.getFileConfiguration().getLong("Materials." + material + ".Limit", materialAmount); + long materialLimit = mainConfig.getFileConfiguration().getLong("Materials." + material + ".Limit", -1); long materialAmountCounted = Math.min(materialLimit, materialAmount); if (materialLimit == -1) From 62cd1ddbcbd92b25c9bb017d60c353f2f6be3861 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 05:08:35 +0200 Subject: [PATCH 102/366] More async Paper support for chunk loading --- .../skyblock/island/IslandManager.java | 7 ++- .../com/songoda/skyblock/listeners/Move.java | 56 +++++++++++-------- .../songoda/skyblock/listeners/Portal.java | 14 ++++- .../listening/PortalPermission.java | 27 +++++---- .../skyblock/utils/world/LocationUtil.java | 43 +++++++------- 5 files changed, 90 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 87bd9195..6422f7b1 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1138,10 +1138,13 @@ public class IslandManager { } } - Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor); if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - loc = LocationUtil.getSafeLocation(loc); + CompletableFuture safeLoc = LocationUtil.getSafeLocation(loc); + if(safeLoc != null){ + loc = safeLoc.join(); + } } if(loc != null){ PaperLib.teleportAsync(player, loc); diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 77d00779..fbdaaaf7 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -29,6 +29,7 @@ import org.bukkit.potion.PotionEffect; import java.io.File; import java.util.Objects; +import java.util.concurrent.CompletableFuture; public class Move implements Listener { @@ -193,30 +194,41 @@ 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)); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + Location loc = null; + 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)) { + CompletableFuture safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main)); + if(safeLoc != null){ + loc = safeLoc.join(); + } + } else { + loc = island.getLocation(world, IslandEnvironment.Main); + LocationUtil.removeWaterFromLoc(skyblock, loc); + } } else { - loc = island.getLocation(world, IslandEnvironment.Main); - LocationUtil.removeWaterFromLoc(skyblock, loc); + if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { + CompletableFuture safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor)); + if(safeLoc != null){ + loc = safeLoc.join(); + } + } else { + loc = island.getLocation(world, IslandEnvironment.Visitor); + } } - } 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){ - PaperLib.teleportAsync(player, 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")))); - } + Location finalLoc = loc; + Bukkit.getScheduler().runTask(skyblock, () -> { + if(finalLoc != null){ + PaperLib.teleportAsync(player, finalLoc); + } else { + LocationUtil.teleportPlayerToSpawn(player); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message"))); + } + }); + }); } private void teleportPlayerToIslandSpawn(Player player, Island island) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 9276d87a..3874091e 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -31,6 +31,7 @@ import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import java.util.concurrent.CompletableFuture; public class Portal implements Listener { @@ -163,13 +164,20 @@ 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, () -> { + Bukkit.getScheduler().runTaskLaterAsynchronously(skyblock, () -> { Location loc = island.getLocation(toWorldF, spawnEnvironment); - Location safeLoc = LocationUtil.getSafeLocation(loc); + CompletableFuture tempSafeLoc = LocationUtil.getSafeLocation(loc); + Location safeLoc = null; + if(tempSafeLoc != null) { + safeLoc = tempSafeLoc.join(); + } if(safeLoc != null){ loc = safeLoc; } - PaperLib.teleportAsync(player, loc); + Location finalLoc = loc; + Bukkit.getScheduler().runTask(skyblock, () -> { + PaperLib.teleportAsync(player, finalLoc); + }); }, 1L); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); player.setFallDistance(0.0F); diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index fbd4ef43..65769a12 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -17,6 +17,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import java.util.concurrent.CompletableFuture; + public class PortalPermission extends ListeningPermission { private final SkyBlock plugin; @@ -68,17 +70,22 @@ public class PortalPermission extends ListeningPermission { } } - private Location getToLocation(Location from, Player player) { - IslandManager islandManager = plugin.getIslandManager(); - Island island = islandManager.getIslandAtLocation(from); - Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); - if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ - to = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - if(to == null){ - to = LocationUtil.getSpawnLocation(); + private CompletableFuture getToLocation(Location from, Player player) { + return CompletableFuture.supplyAsync(() -> { + IslandManager islandManager = plugin.getIslandManager(); + Island island = islandManager.getIslandAtLocation(from); + Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); + if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ + CompletableFuture safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); + if(safeLoc != null) { + to = safeLoc.join(); + } + if(to == null){ + to = LocationUtil.getSpawnLocation(); + } } - } - return to; + return to; + }); } } 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 a8c645e2..0b2abe20 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -25,6 +25,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.concurrent.CompletableFuture; import java.util.logging.Level; public final class LocationUtil { @@ -41,29 +42,31 @@ public final class LocationUtil { } } - public static @Nullable Location getSafeLocation(Location loc){ - boolean found = false; - Location locChecked = null; - if(loc != null && loc.getWorld() != null){ - 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); + public static @Nullable CompletableFuture getSafeLocation(Location loc){ + return CompletableFuture.supplyAsync(() -> { + boolean found = false; + Location locChecked = null; + if(loc != null && loc.getWorld() != null){ + 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; + } } - if (found) { - locChecked = locChecked.add(0d,1d,0d); - } else { - locChecked = null; - } - } - return locChecked; + return locChecked; + }); } public static @Nonnull Location getDefinitiveLocation(Location loc){ From ce85deb4e3ff5b0ee8990ee931bd3fa8a5473425 Mon Sep 17 00:00:00 2001 From: WolfDW Date: Thu, 25 Jun 2020 14:15:40 +0000 Subject: [PATCH 103/366] Island score block limits --- .../songoda/skyblock/island/IslandLevel.java | 18 +- .../com/songoda/skyblock/menus/Levelling.java | 17 +- src/main/resources/language.yml | 2 +- src/main/resources/levelling.yml | 718 ++++++++++++++++++ 4 files changed, 748 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java index be1825f3..9d3d9784 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java @@ -78,8 +78,15 @@ public class IslandLevel { if (current == null) continue; long pointsRequired = current.getLong("Points", 0); + long blockAmount = entry.getValue(); - if (pointsRequired != 0) pointsEarned = pointsEarned + (entry.getValue() * pointsRequired); + long materialLimit = current.getLong("Limit", -1); + long materialAmountCounted = Math.min(materialLimit, blockAmount); + + if (materialLimit == -1) + materialAmountCounted = blockAmount; + + if (pointsRequired != 0) pointsEarned = pointsEarned + (materialAmountCounted * pointsRequired); } @@ -99,12 +106,17 @@ public class IslandLevel { if (current == null) return 0; Long boxedAmount = this.materials.get(material); - if (boxedAmount == null) return 0; + long materialLimit = current.getLong("Limit", -1); + long materialAmountCounted = Math.min(materialLimit, boxedAmount); + + if (materialLimit == -1) + materialAmountCounted = boxedAmount; + long pointsRequired = current.getLong("Points"); - return pointsRequired == 0 ? 0 : boxedAmount * pointsRequired; + return pointsRequired == 0 ? 0 : materialAmountCounted * pointsRequired; } public long getLevel() { diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index a9735189..b6cea6e6 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -260,7 +260,14 @@ public class Levelling { inventorySlot++; - long pointsEarned = materialAmount * pointsMultiplier; + long materialLimit = mainConfig.getFileConfiguration().getLong("Materials." + material + ".Limit", -1); + long materialAmountCounted = Math.min(materialLimit, materialAmount); + + if (materialLimit == -1) + materialAmountCounted = materialAmount; + + long pointsEarned = materialAmountCounted * pointsMultiplier; + String name = skyblock.getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(materials); @@ -271,11 +278,15 @@ public class Levelling { is.setAmount(Math.min(Math.toIntExact(materialAmount), 64)); is.setType(CompatibleMaterial.getMaterial(is).getMaterial()); + long finalMaterialAmountCounted = materialAmountCounted; List lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore"); - lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)).replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name)); + lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)).replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)) + .replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted))); nInv.addItem(nInv.createItem(is, configLoad.getString("Menu.Levelling.Item.Material.Displayname").replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)) - .replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name), lore, null, null, null), inventorySlot); + .replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted)) + ,lore, null, null, null), inventorySlot); + } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index f039dd40..92928327 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -2307,7 +2307,7 @@ Menu: Material: Displayname: '&7%material &8(&e+%points Points&8)' Lore: - - '&8(&e%blocks Blocks&8)' + - '&8(&e%blocks Blocks&8, &e%counted Counted&8)' Title: '&8Island Levelling' ControlPanel: Item: diff --git a/src/main/resources/levelling.yml b/src/main/resources/levelling.yml index c8d20eb3..b98ee706 100644 --- a/src/main/resources/levelling.yml +++ b/src/main/resources/levelling.yml @@ -3,1438 +3,2156 @@ # Points Earned Materials: ACACIA_BUTTON: + Limit: -1 Points: 1 ACACIA_DOOR: + Limit: -1 Points: 1 ACACIA_FENCE: + Limit: -1 Points: 2 ACACIA_FENCE_GATE: + Limit: -1 Points: 4 ACACIA_LEAVES: + Limit: -1 Points: 0 ACACIA_LOG: + Limit: -1 Points: 0 ACACIA_PLANKS: + Limit: -1 Points: 1 ACACIA_PRESSURE_PLATE: + Limit: -1 Points: 2 ACACIA_SAPLING: + Limit: -1 Points: 1 ACACIA_SLAB: + Limit: -1 Points: 1 ACACIA_STAIRS: + Limit: -1 Points: 2 ACACIA_TRAPDOOR: + Limit: -1 Points: 3 ACACIA_WOOD: + Limit: -1 Points: 1 ACTIVATOR_RAIL: + Limit: -1 Points: 1 ALLIUM: + Limit: -1 Points: 1 ANDESITE: + Limit: -1 Points: 1 ANDESITE_SLAB: + Limit: -1 Points: 1 ANDESITE_STAIRS: + Limit: -1 Points: 1 ANDESITE_WALL: + Limit: -1 Points: 1 ANVIL: + Limit: -1 Points: 10 ATTACHED_MELON_STEM: + Limit: -1 Points: 1 ATTACHED_PUMPKIN_STEM: + Limit: -1 Points: 1 AZURE_BLUET: + Limit: -1 Points: 1 BARRIER: + Limit: -1 Points: 0 BAMBOO: + Limit: -1 Points: 1 BAMBOO_SAPLING: + Limit: -1 Points: 1 BARREL: + Limit: -1 Points: 1 BEACON: + Limit: -1 Points: 500 BEDROCK: + Limit: -1 Points: 0 BEETROOTS: + Limit: -1 Points: 1 BELL: + Limit: -1 Points: 7 BIRCH_BUTTON: + Limit: -1 Points: 1 BIRCH_DOOR: + Limit: -1 Points: 2 BIRCH_FENCE: + Limit: -1 Points: 2 BIRCH_FENCE_GATE: + Limit: -1 Points: 4 BIRCH_LEAVES: + Limit: -1 Points: 0 BIRCH_LOG: + Limit: -1 Points: 0 BIRCH_PLANKS: + Limit: -1 Points: 1 BIRCH_PRESSURE_PLATE: + Limit: -1 Points: 2 BIRCH_SAPLING: + Limit: -1 Points: 1 BIRCH_SIGN: + Limit: -1 Points: 6 BIRCH_SLAB: + Limit: -1 Points: 1 BIRCH_STAIRS: + Limit: -1 Points: 2 BIRCH_TRAPDOOR: + Limit: -1 Points: 3 BIRCH_WALL_SIGN: + Limit: -1 Points: 6 BIRCH_WOOD: + Limit: -1 Points: 1 BLACK_BANNER: + Limit: -1 Points: 2 BLACK_BED: + Limit: -1 Points: 6 BLACK_CARPET: + Limit: -1 Points: 1 BLACK_CONCRETE: + Limit: -1 Points: 3 BLACK_CONCRETE_POWDER: + Limit: -1 Points: 2 BLACK_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 BLACK_SHULKER_BOX: + Limit: -1 Points: 11 BLACK_STAINED_GLASS: + Limit: -1 Points: 2 BLACK_STAINED_GLASS_PANE: + Limit: -1 Points: 1 BLACK_TERRACOTTA: + Limit: -1 Points: 2 BLACK_WALL_BANNER: + Limit: -1 Points: 2 BLACK_WOOL: + Limit: -1 Points: 2 BLAST_FURNACE: + Limit: -1 Points: 6 BLUE_BANNER: + Limit: -1 Points: 2 BLUE_BED: + Limit: -1 Points: 6 BLUE_CARPET: + Limit: -1 Points: 1 BLUE_CONCRETE: + Limit: -1 Points: 3 BLUE_CONCRETE_POWDER: + Limit: -1 Points: 2 BLUE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 BLUE_ICE: + Limit: -1 Points: 1 BLUE_ORCHID: + Limit: -1 Points: 1 BLUE_SHULKER_BOX: + Limit: -1 Points: 11 BLUE_STAINED_GLASS: + Limit: -1 Points: 2 BLUE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 BLUE_TERRACOTTA: + Limit: -1 Points: 2 BLUE_WALL_BANNER: + Limit: -1 Points: 2 BLUE_WOOL: + Limit: -1 Points: 2 BONE_BLOCK: + Limit: -1 Points: 1 BOOKSHELF: + Limit: -1 Points: 5 BRAIN_CORAL: + Limit: -1 Points: 1 BRAIN_CORAL_BLOCK: + Limit: -1 Points: 1 BRAIN_CORAL_FAN: + Limit: -1 Points: 1 BRAIN_CORAL_WALL_FAN: + Limit: -1 Points: 1 BREWING_STAND: + Limit: -1 Points: 20 BRICKS: + Limit: -1 Points: 5 BRICK_SLAB: + Limit: -1 Points: 3 BRICK_STAIRS: + Limit: -1 Points: 5 BRICK_WALL: + Limit: -1 Points: 3 BROWN_BANNER: + Limit: -1 Points: 2 BROWN_BED: + Limit: -1 Points: 6 BROWN_CARPET: + Limit: -1 Points: 1 BROWN_CONCRETE: + Limit: -1 Points: 3 BROWN_CONCRETE_POWDER: + Limit: -1 Points: 2 BROWN_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 BROWN_MUSHROOM: + Limit: -1 Points: 1 BROWN_MUSHROOM_BLOCK: + Limit: -1 Points: 1 BROWN_SHULKER_BOX: + Limit: -1 Points: 11 BROWN_STAINED_GLASS: + Limit: -1 Points: 2 BROWN_STAINED_GLASS_PANE: + Limit: -1 Points: 1 BROWN_TERRACOTTA: + Limit: -1 Points: 2 BROWN_WALL_BANNER: + Limit: -1 Points: 2 BROWN_WOOL: + Limit: -1 Points: 1 BUBBLE_COLUMN: + Limit: -1 Points: 1 BUBBLE_CORAL: + Limit: -1 Points: 1 BUBBLE_CORAL_BLOCK: + Limit: -1 Points: 1 BUBBLE_CORAL_FAN: + Limit: -1 Points: 1 BUBBLE_CORAL_WALL_FAN: + Limit: -1 Points: 1 CACTUS: + Limit: -1 Points: 1 CAMPFIRE: + Limit: -1 Points: 2 CAKE: + Limit: -1 Points: 9 CARROTS: + Limit: -1 Points: 1 CARTOGRAPHY_TABLE: + Limit: -1 Points: 5 CARVED_PUMPKIN: + Limit: -1 Points: 2 CAULDRON: + Limit: -1 Points: 10 CAVE_AIR: + Limit: -1 Points: 0 CHAIN_COMMAND_BLOCK: + Limit: -1 Points: 0 CHEST: + Limit: -1 Points: 8 CHIPPED_ANVIL: + Limit: -1 Points: 9 CHISELED_QUARTZ_BLOCK: + Limit: -1 Points: 2 CHISELED_RED_SANDSTONE: + Limit: -1 Points: 2 CHISELED_SANDSTONE: + Limit: -1 Points: 2 CHISELED_STONE_BRICKS: + Limit: -1 Points: 2 CHORUS_FLOWER: + Limit: -1 Points: 1 CHORUS_PLANT: + Limit: -1 Points: 1 CLAY: + Limit: -1 Points: 2 COAL_BLOCK: + Limit: -1 Points: 9 COAL_ORE: + Limit: -1 Points: 1 COARSE_DIRT: + Limit: -1 Points: 2 COBBLESTONE: + Limit: -1 Points: 1 COBBLESTONE_SLAB: + Limit: -1 Points: 1 COBBLESTONE_STAIRS: + Limit: -1 Points: 2 COBBLESTONE_WALL: + Limit: -1 Points: 1 COBWEB: + Limit: -1 Points: 10 COCOA: + Limit: -1 Points: 1 COMMAND_BLOCK: + Limit: -1 Points: 0 COMPARATOR: + Limit: -1 Points: 10 COMPOSTER: + Limit: -1 Points: 4 CONDUIT: + Limit: -1 Points: 1 CORNFLOWER: + Limit: -1 Points: 1 CRACKED_STONE_BRICKS: + Limit: -1 Points: 2 CRAFTING_TABLE: + Limit: -1 Points: 1 CREEPER_HEAD: + Limit: -1 Points: 1 CREEPER_WALL_HEAD: + Limit: -1 Points: 1 CUT_RED_SANDSTONE: + Limit: -1 Points: 1 CUT_RED_SANDSTONE_SLAB: + Limit: -1 Points: 1 CUT_SANDSTONE: + Limit: -1 Points: 1 CUT_SANDSTONE_SLAB: + Limit: -1 Points: 1 CYAN_BANNER: + Limit: -1 Points: 2 CYAN_BED: + Limit: -1 Points: 6 CYAN_CARPET: + Limit: -1 Points: 1 CYAN_CONCRETE: + Limit: -1 Points: 3 CYAN_CONCRETE_POWDER: + Limit: -1 Points: 2 CYAN_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 CYAN_SHULKER_BOX: + Limit: -1 Points: 11 CYAN_STAINED_GLASS: + Limit: -1 Points: 2 CYAN_STAINED_GLASS_PANE: + Limit: -1 Points: 1 CYAN_TERRACOTTA: + Limit: -1 Points: 2 CYAN_WALL_BANNER: + Limit: -1 Points: 2 CYAN_WOOL: + Limit: -1 Points: 2 DAMAGED_ANVIL: + Limit: -1 Points: 5 DANDELION: + Limit: -1 Points: 1 DARK_OAK_BUTTON: + Limit: -1 Points: 1 DARK_OAK_DOOR: + Limit: -1 Points: 2 DARK_OAK_FENCE: + Limit: -1 Points: 2 DARK_OAK_FENCE_GATE: + Limit: -1 Points: 4 DARK_OAK_LEAVES: + Limit: -1 Points: 0 DARK_OAK_LOG: + Limit: -1 Points: 0 DARK_OAK_PLANKS: + Limit: -1 Points: 1 DARK_OAK_PRESSURE_PLATE: + Limit: -1 Points: 2 DARK_OAK_SAPLING: + Limit: -1 Points: 1 DARK_OAK_SIGN: + Limit: -1 Points: 6 DARK_OAK_SLAB: + Limit: -1 Points: 1 DARK_OAK_STAIRS: + Limit: -1 Points: 2 DARK_OAK_TRAPDOOR: + Limit: -1 Points: 3 DARK_OAK_WALL_SIGN: + Limit: -1 Points: 6 DARK_OAK_WOOD: + Limit: -1 Points: 1 DARK_PRISMARINE: + Limit: -1 Points: 1 DARK_PRISMARINE_SLAB: + Limit: -1 Points: 1 DARK_PRISMARINE_STAIRS: + Limit: -1 Points: 2 DAYLIGHT_DETECTOR: + Limit: -1 Points: 10 DEAD_BRAIN_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_BRAIN_CORAL_FAN: + Limit: -1 Points: 1 DEAD_BRAIN_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_BUBBLE_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_BUBBLE_CORAL_FAN: + Limit: -1 Points: 1 DEAD_BUBBLE_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_BUSH: + Limit: -1 Points: 1 DEAD_FIRE_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_FIRE_CORAL_FAN: + Limit: -1 Points: 1 DEAD_FIRE_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_HORN_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_HORN_CORAL_FAN: + Limit: -1 Points: 1 DEAD_HORN_CORAL_WALL_FAN: + Limit: -1 Points: 1 DEAD_TUBE_CORAL_BLOCK: + Limit: -1 Points: 1 DEAD_TUBE_CORAL_FAN: + Limit: -1 Points: 1 DEAD_TUBE_CORAL_WALL_FAN: + Limit: -1 Points: 1 DETECTOR_RAIL: + Limit: -1 Points: 10 DIAMOND_BLOCK: + Limit: -1 Points: 300 DIAMOND_ORE: + Limit: -1 Points: 1 DIORITE: + Limit: -1 Points: 1 DIORITE_SLAB: + Limit: -1 Points: 1 DIORITE_STAIRS: + Limit: -1 Points: 1 DIORITE_WALL: + Limit: -1 Points: 1 DIRT: + Limit: -1 Points: 3 DISPENSER: + Limit: -1 Points: 5 DRAGON_EGG: + Limit: -1 Points: 150 DRAGON_HEAD: + Limit: -1 Points: 1 DRAGON_WALL_HEAD: + Limit: -1 Points: 1 DRIED_KELP_BLOCK: + Limit: -1 Points: 1 DROPPER: + Limit: -1 Points: 4 EMERALD_BLOCK: + Limit: -1 Points: 150 EMERALD_ORE: + Limit: -1 Points: 1 ENCHANTING_TABLE: + Limit: -1 Points: 150 ENDER_CHEST: + Limit: -1 Points: 150 END_GATEWAY: + Limit: -1 Points: 0 END_PORTAL: + Limit: -1 Points: 0 END_PORTAL_FRAME: + Limit: -1 Points: 0 END_ROD: + Limit: -1 Points: 1 END_STONE: + Limit: -1 Points: 1 END_STONE_BRICK_SLAB: + Limit: -1 Points: 1 END_STONE_BRICK_STAIRS: + Limit: -1 Points: 1 END_STONE_BRICK_WALL: + Limit: -1 Points: 1 END_STONE_BRICKS: + Limit: -1 Points: 2 FARMLAND: + Limit: -1 Points: 1 FERN: + Limit: -1 Points: 1 FIRE: + Limit: -1 Points: 0 FIRE_CORAL: + Limit: -1 Points: 1 FIRE_CORAL_BLOCK: + Limit: -1 Points: 1 FIRE_CORAL_FAN: + Limit: -1 Points: 1 FIRE_CORAL_WALL_FAN: + Limit: -1 Points: 1 FLETCHING_TABLE: + Limit: -1 Points: 4 FLOWER_POT: + Limit: -1 Points: 1 FROSTED_ICE: + Limit: -1 Points: 1 FURNACE: + Limit: -1 Points: 8 GLASS: + Limit: -1 Points: 2 GLASS_PANE: + Limit: -1 Points: 1 GLOWSTONE: + Limit: -1 Points: 1 GOLD_BLOCK: + Limit: -1 Points: 150 GOLD_ORE: + Limit: -1 Points: 1 GRANITE: + Limit: -1 Points: 1 GRANITE_SLAB: + Limit: -1 Points: 1 GRANITE_STAIRS: + Limit: -1 Points: 1 GRANITE_WALL: + Limit: -1 Points: 1 GRASS: + Limit: -1 Points: 4 GRASS_BLOCK: + Limit: -1 Points: 4 GRASS_PATH: + Limit: -1 Points: 4 GRAVEL: + Limit: -1 Points: 1 GRAY_BANNER: + Limit: -1 Points: 2 GRAY_BED: + Limit: -1 Points: 6 GRAY_CARPET: + Limit: -1 Points: 1 GRAY_CONCRETE: + Limit: -1 Points: 3 GRAY_CONCRETE_POWDER: + Limit: -1 Points: 2 GRAY_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 GRAY_SHULKER_BOX: + Limit: -1 Points: 11 GRAY_STAINED_GLASS: + Limit: -1 Points: 2 GRAY_STAINED_GLASS_PANE: + Limit: -1 Points: 1 GRAY_TERRACOTTA: + Limit: -1 Points: 2 GRAY_WALL_BANNER: + Limit: -1 Points: 2 GRAY_WOOL: + Limit: -1 Points: 2 GREEN_BANNER: + Limit: -1 Points: 2 GREEN_BED: + Limit: -1 Points: 6 GREEN_CARPET: + Limit: -1 Points: 1 GREEN_CONCRETE: + Limit: -1 Points: 3 GREEN_CONCRETE_POWDER: + Limit: -1 Points: 2 GREEN_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 GREEN_SHULKER_BOX: + Limit: -1 Points: 11 GREEN_STAINED_GLASS: + Limit: -1 Points: 2 GREEN_STAINED_GLASS_PANE: + Limit: -1 Points: 1 GREEN_TERRACOTTA: + Limit: -1 Points: 2 GREEN_WALL_BANNER: + Limit: -1 Points: 2 GREEN_WOOL: + Limit: -1 Points: 2 GRINDSTONE: + Limit: -1 Points: 4 HAY_BLOCK: + Limit: -1 Points: 2 HEAVY_WEIGHTED_PRESSURE_PLATE: + Limit: -1 Points: 3 HOPPER: + Limit: -1 Points: 5 HORN_CORAL: + Limit: -1 Points: 1 HORN_CORAL_BLOCK: + Limit: -1 Points: 1 HORN_CORAL_FAN: + Limit: -1 Points: 1 HORN_CORAL_WALL_FAN: + Limit: -1 Points: 1 ICE: + Limit: -1 Points: 5 INFESTED_CHISELED_STONE_BRICKS: + Limit: -1 Points: 2 INFESTED_COBBLESTONE: + Limit: -1 Points: 1 INFESTED_CRACKED_STONE_BRICKS: + Limit: -1 Points: 2 INFESTED_MOSSY_STONE_BRICKS: + Limit: -1 Points: 2 INFESTED_STONE: + Limit: -1 Points: 1 INFESTED_STONE_BRICKS: + Limit: -1 Points: 2 IRON_BARS: + Limit: -1 Points: 2 IRON_BLOCK: + Limit: -1 Points: 10 IRON_DOOR: + Limit: -1 Points: 5 IRON_ORE: + Limit: -1 Points: 1 IRON_TRAPDOOR: + Limit: -1 Points: 4 JACK_O_LANTERN: + Limit: -1 Points: 2 JIGSAW: + Limit: -1 Points: 4 JUKEBOX: + Limit: -1 Points: 10 JUNGLE_BUTTON: + Limit: -1 Points: 1 JUNGLE_DOOR: + Limit: -1 Points: 2 JUNGLE_FENCE: + Limit: -1 Points: 2 JUNGLE_FENCE_GATE: + Limit: -1 Points: 4 JUNGLE_LEAVES: + Limit: -1 Points: 0 JUNGLE_LOG: + Limit: -1 Points: 0 JUNGLE_PLANKS: + Limit: -1 Points: 1 JUNGLE_PRESSURE_PLATE: + Limit: -1 Points: 2 JUNGLE_SAPLING: + Limit: -1 Points: 1 JUNGLE_SIGN: + Limit: -1 Points: 6 JUNGLE_SLAB: + Limit: -1 Points: 1 JUNGLE_STAIRS: + Limit: -1 Points: 2 JUNGLE_TRAPDOOR: + Limit: -1 Points: 3 JUNGLE_WALL_SIGN: + Limit: -1 Points: 6 JUNGLE_WOOD: + Limit: -1 Points: 1 KELP: + Limit: -1 Points: 1 KELP_PLANT: + Limit: -1 Points: 1 LADDER: + Limit: -1 Points: 2 LANTERN: + Limit: -1 Points: 3 LAPIS_BLOCK: + Limit: -1 Points: 10 LAPIS_ORE: + Limit: -1 Points: 1 LARGE_FERN: + Limit: -1 Points: 1 LECTERN: + Limit: -1 Points: 4 LEVER: + Limit: -1 Points: 1 LIGHT_BLUE_BANNER: + Limit: -1 Points: 2 LIGHT_BLUE_BED: + Limit: -1 Points: 6 LIGHT_BLUE_CARPET: + Limit: -1 Points: 1 LIGHT_BLUE_CONCRETE: + Limit: -1 Points: 2 LIGHT_BLUE_CONCRETE_POWDER: + Limit: -1 Points: 2 LIGHT_BLUE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 LIGHT_BLUE_SHULKER_BOX: + Limit: -1 Points: 11 LIGHT_BLUE_STAINED_GLASS: + Limit: -1 Points: 2 LIGHT_BLUE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 LIGHT_BLUE_TERRACOTTA: + Limit: -1 Points: 2 LIGHT_BLUE_WALL_BANNER: + Limit: -1 Points: 2 LIGHT_BLUE_WOOL: + Limit: -1 Points: 2 LIGHT_GRAY_BANNER: + Limit: -1 Points: 2 LIGHT_GRAY_BED: + Limit: -1 Points: 6 LIGHT_GRAY_CARPET: + Limit: -1 Points: 1 LIGHT_GRAY_CONCRETE: + Limit: -1 Points: 3 LIGHT_GRAY_CONCRETE_POWDER: + Limit: -1 Points: 2 LIGHT_GRAY_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 LIGHT_GRAY_SHULKER_BOX: + Limit: -1 Points: 11 LIGHT_GRAY_STAINED_GLASS: + Limit: -1 Points: 2 LIGHT_GRAY_STAINED_GLASS_PANE: + Limit: -1 Points: 1 LIGHT_GRAY_TERRACOTTA: + Limit: -1 Points: 2 LIGHT_GRAY_WALL_BANNER: + Limit: -1 Points: 2 LIGHT_GRAY_WOOL: + Limit: -1 Points: 2 LIGHT_WEIGHTED_PRESSURE_PLATE: + Limit: -1 Points: 3 LILAC: + Limit: -1 Points: 1 LILY_OF_THE_VALLEY: + Limit: -1 Points: 1 LILY_PAD: + Limit: -1 Points: 5 LIME_BANNER: + Limit: -1 Points: 2 LIME_BED: + Limit: -1 Points: 6 LIME_CARPET: + Limit: -1 Points: 1 LIME_CONCRETE: + Limit: -1 Points: 3 LIME_CONCRETE_POWDER: + Limit: -1 Points: 2 LIME_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 LIME_SHULKER_BOX: + Limit: -1 Points: 11 LIME_STAINED_GLASS: + Limit: -1 Points: 2 LIME_STAINED_GLASS_PANE: + Limit: -1 Points: 1 LIME_TERRACOTTA: + Limit: -1 Points: 2 LIME_WALL_BANNER: + Limit: -1 Points: 2 LIME_WOOL: + Limit: -1 Points: 2 LOOM: + Limit: -1 Points: 4 MAGENTA_BANNER: + Limit: -1 Points: 2 MAGENTA_BED: + Limit: -1 Points: 6 MAGENTA_CARPET: + Limit: -1 Points: 1 MAGENTA_CONCRETE: + Limit: -1 Points: 3 MAGENTA_CONCRETE_POWDER: + Limit: -1 Points: 2 MAGENTA_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 MAGENTA_SHULKER_BOX: + Limit: -1 Points: 11 MAGENTA_STAINED_GLASS: + Limit: -1 Points: 2 MAGENTA_STAINED_GLASS_PANE: + Limit: -1 Points: 1 MAGENTA_TERRACOTTA: + Limit: -1 Points: 2 MAGENTA_WALL_BANNER: + Limit: -1 Points: 2 MAGENTA_WOOL: + Limit: -1 Points: 2 MAGMA_BLOCK: + Limit: -1 Points: 1 MELON: + Limit: -1 Points: 1 MELON_STEM: + Limit: -1 Points: 1 MOSSY_COBBLESTONE: + Limit: -1 Points: 1 MOSSY_COBBLESTONE_SLAB: + Limit: -1 Points: 1 MOSSY_COBBLESTONE_STAIRS: + Limit: -1 Points: 1 MOSSY_COBBLESTONE_WALL: + Limit: -1 Points: 1 MOSSY_STONE_BRICK_SLAB: + Limit: -1 Points: 1 MOSSY_STONE_BRICK_STAIRS: + Limit: -1 Points: 1 MOSSY_STONE_BRICK_WALL: + Limit: -1 Points: 1 MOSSY_STONE_BRICKS: + Limit: -1 Points: 1 MOVING_PISTON: + Limit: -1 Points: 1 MUSHROOM_STEM: + Limit: -1 Points: 1 MYCELIUM: + Limit: -1 Points: 5 NETHERRACK: + Limit: -1 Points: 1 NETHER_BRICK_WALL: + Limit: -1 Points: 1 NETHER_BRICKS: + Limit: -1 Points: 2 NETHER_BRICK_FENCE: + Limit: -1 Points: 2 NETHER_BRICK_SLAB: + Limit: -1 Points: 1 NETHER_BRICK_STAIRS: + Limit: -1 Points: 2 NETHER_PORTAL: + Limit: -1 Points: 1 NETHER_QUARTZ_ORE: + Limit: -1 Points: 1 NETHER_WART: + Limit: -1 Points: 1 NETHER_WART_BLOCK: + Limit: -1 Points: 2 NOTE_BLOCK: + Limit: -1 Points: 10 OAK_BUTTON: + Limit: -1 Points: 1 OAK_DOOR: + Limit: -1 Points: 2 OAK_FENCE: + Limit: -1 Points: 2 OAK_FENCE_GATE: + Limit: -1 Points: 4 OAK_LEAVES: + Limit: -1 Points: 0 OAK_LOG: + Limit: -1 Points: 0 OAK_PLANKS: + Limit: -1 Points: 1 OAK_PRESSURE_PLATE: + Limit: -1 Points: 2 OAK_SAPLING: + Limit: -1 Points: 1 OAK_SIGN: + Limit: -1 Points: 6 OAK_SLAB: + Limit: -1 Points: 1 OAK_STAIRS: + Limit: -1 Points: 2 OAK_TRAPDOOR: + Limit: -1 Points: 3 OAK_WALL_SIGN: + Limit: -1 Points: 6 OAK_WOOD: + Limit: -1 Points: 1 OBSERVER: + Limit: -1 Points: 1 OBSIDIAN: + Limit: -1 Points: 10 ORANGE_BANNER: + Limit: -1 Points: 2 ORANGE_BED: + Limit: -1 Points: 6 ORANGE_CARPET: + Limit: -1 Points: 1 ORANGE_CONCRETE: + Limit: -1 Points: 3 ORANGE_CONCRETE_POWDER: + Limit: -1 Points: 2 ORANGE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 ORANGE_SHULKER_BOX: + Limit: -1 Points: 11 ORANGE_STAINED_GLASS: + Limit: -1 Points: 2 ORANGE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 ORANGE_TERRACOTTA: + Limit: -1 Points: 2 ORANGE_TULIP: + Limit: -1 Points: 1 ORANGE_WALL_BANNER: + Limit: -1 Points: 2 ORANGE_WOOL: + Limit: -1 Points: 2 OXEYE_DAISY: + Limit: -1 Points: 1 PACKED_ICE: + Limit: -1 Points: 5 PEONY: + Limit: -1 Points: 1 PETRIFIED_OAK_SLAB: + Limit: -1 Points: 1 PINK_BANNER: + Limit: -1 Points: 2 PINK_BED: + Limit: -1 Points: 6 PINK_CARPET: + Limit: -1 Points: 1 PINK_CONCRETE: + Limit: -1 Points: 3 PINK_CONCRETE_POWDER: + Limit: -1 Points: 2 PINK_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 PINK_SHULKER_BOX: + Limit: -1 Points: 11 PINK_STAINED_GLASS: + Limit: -1 Points: 2 PINK_STAINED_GLASS_PANE: + Limit: -1 Points: 1 PINK_TERRACOTTA: + Limit: -1 Points: 2 PINK_TULIP: + Limit: -1 Points: 1 PINK_WALL_BANNER: + Limit: -1 Points: 2 PINK_WOOL: + Limit: -1 Points: 2 PISTON: + Limit: -1 Points: 2 PISTON_HEAD: + Limit: -1 Points: 1 PLAYER_HEAD: + Limit: -1 Points: 1 PLAYER_WALL_HEAD: + Limit: -1 Points: 1 PODZOL: + Limit: -1 Points: 2 POLISHED_ANDESITE: + Limit: -1 Points: 1 POLISHED_ANDESITE_SLAB: + Limit: -1 Points: 1 POLISHED_ANDESITE_STAIRS: + Limit: -1 Points: 1 POLISHED_DIORITE: + Limit: -1 Points: 1 POLISHED_DIORITE_SLAB: + Limit: -1 Points: 1 POLISHED_DIORITE_STAIRS: + Limit: -1 Points: 1 POLISHED_GRANITE: + Limit: -1 Points: 1 POLISHED_GRANITE_SLAB: + Limit: -1 Points: 1 POLISHED_GRANITE_STAIRS: + Limit: -1 Points: 1 POPPY: + Limit: -1 Points: 1 POTATOES: + Limit: -1 Points: 1 POTTED_ACACIA_SAPLING: + Limit: -1 Points: 1 POTTED_ALLIUM: + Limit: -1 Points: 1 POTTED_AZURE_BLUET: + Limit: -1 Points: 1 POTTED_BAMBOO: + Limit: -1 Points: 1 POTTED_BIRCH_SAPLING: + Limit: -1 Points: 1 POTTED_BLUE_ORCHID: + Limit: -1 Points: 1 POTTED_BROWN_MUSHROOM: + Limit: -1 Points: 1 POTTED_CACTUS: + Limit: -1 Points: 1 POTTED_CORNFLOWER: + Limit: -1 Points: 1 POTTED_DANDELION: + Limit: -1 Points: 1 POTTED_DARK_OAK_SAPLING: + Limit: -1 Points: 1 POTTED_DEAD_BUSH: + Limit: -1 Points: 1 POTTED_FERN: + Limit: -1 Points: 1 POTTED_JUNGLE_SAPLING: + Limit: -1 Points: 1 POTTED_LILY_OF_THE_VALLEY: + Limit: -1 Points: 1 POTTED_OAK_SAPLING: + Limit: -1 Points: 1 POTTED_ORANGE_TULIP: + Limit: -1 Points: 1 POTTED_OXEYE_DAISY: + Limit: -1 Points: 1 POTTED_PINK_TULIP: + Limit: -1 Points: 1 POTTED_POPPY: + Limit: -1 Points: 1 POTTED_RED_MUSHROOM: + Limit: -1 Points: 1 POTTED_RED_TULIP: + Limit: -1 Points: 1 POTTED_SPRUCE_SAPLING: + Limit: -1 Points: 1 POTTED_WHITE_TULIP: + Limit: -1 Points: 1 POTTED_WITHER_ROSE: + Limit: -1 Points: 1 POWERED_RAIL: + Limit: -1 Points: 2 PRISMARINE: + Limit: -1 Points: 1 PRISMARINE_BRICKS: + Limit: -1 Points: 2 PRISMARINE_BRICK_SLAB: + Limit: -1 Points: 1 PRISMARINE_BRICK_STAIRS: + Limit: -1 Points: 2 PRISMARINE_SLAB: + Limit: -1 Points: 1 PRISMARINE_STAIRS: + Limit: -1 Points: 2 PRISMARINE_WALL: + Limit: -1 Points: 1 PUMPKIN: + Limit: -1 Points: 1 PUMPKIN_STEM: + Limit: -1 Points: 1 PURPLE_BANNER: + Limit: -1 Points: 2 PURPLE_BED: + Limit: -1 Points: 6 PURPLE_CARPET: + Limit: -1 Points: 1 PURPLE_CONCRETE: + Limit: -1 Points: 3 PURPLE_CONCRETE_POWDER: + Limit: -1 Points: 2 PURPLE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 PURPLE_SHULKER_BOX: + Limit: -1 Points: 11 PURPLE_STAINED_GLASS: + Limit: -1 Points: 2 PURPLE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 PURPLE_TERRACOTTA: + Limit: -1 Points: 2 PURPLE_WALL_BANNER: + Limit: -1 Points: 2 PURPLE_WOOL: + Limit: -1 Points: 2 PURPUR_BLOCK: + Limit: -1 Points: 1 PURPUR_PILLAR: + Limit: -1 Points: 1 PURPUR_SLAB: + Limit: -1 Points: 1 PURPUR_STAIRS: + Limit: -1 Points: 2 QUARTZ_BLOCK: + Limit: -1 Points: 1 QUARTZ_PILLAR: + Limit: -1 Points: 1 QUARTZ_SLAB: + Limit: -1 Points: 1 QUARTZ_STAIRS: + Limit: -1 Points: 2 RAIL: + Limit: -1 Points: 1 REDSTONE_BLOCK: + Limit: -1 Points: 10 REDSTONE_LAMP: + Limit: -1 Points: 10 REDSTONE_ORE: + Limit: -1 Points: 1 REDSTONE_TORCH: + Limit: -1 Points: 5 REDSTONE_WALL_TORCH: + Limit: -1 Points: 5 REDSTONE_WIRE: + Limit: -1 Points: 1 RED_BED: + Limit: -1 Points: 6 RED_CARPET: + Limit: -1 Points: 1 RED_CONCRETE: + Limit: -1 Points: 3 RED_CONCRETE_POWDER: + Limit: -1 Points: 2 RED_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 RED_MUSHROOM: + Limit: -1 Points: 1 RED_MUSHROOM_BLOCK: + Limit: -1 Points: 1 RED_NETHER_BRICK_SLAB: + Limit: -1 Points: 1 RED_NETHER_BRICK_STAIRS: + Limit: -1 Points: 1 RED_NETHER_BRICK_WALL: + Limit: -1 Points: 1 RED_NETHER_BRICKS: + Limit: -1 Points: 2 RED_SAND: + Limit: -1 Points: 1 RED_SANDSTONE: + Limit: -1 Points: 1 RED_SANDSTONE_SLAB: + Limit: -1 Points: 1 RED_SANDSTONE_STAIRS: + Limit: -1 Points: 2 RED_SANDSTONE_WALL: + Limit: -1 Points: 1 RED_SHULKER_BOX: + Limit: -1 Points: 11 RED_STAINED_GLASS: + Limit: -1 Points: 2 RED_STAINED_GLASS_PANE: + Limit: -1 Points: 1 RED_TERRACOTTA: + Limit: -1 Points: 2 RED_TULIP: + Limit: -1 Points: 1 RED_WALL_BANNER: + Limit: -1 Points: 2 RED_WOOL: + Limit: -1 Points: 1 REPEATER: + Limit: -1 Points: 6 REPEATING_COMMAND_BLOCK: + Limit: -1 Points: 0 ROSE_BUSH: + Limit: -1 Points: 1 SAND: + Limit: -1 Points: 1 SANDSTONE: + Limit: -1 Points: 1 SANDSTONE_SLAB: + Limit: -1 Points: 1 SANDSTONE_STAIRS: + Limit: -1 Points: 2 SANDSTONE_WALL: + Limit: -1 Points: 1 SCAFFOLDING: + Limit: -1 Points: 1 SEAGRASS: + Limit: -1 Points: 1 SEA_LANTERN: + Limit: -1 Points: 9 SEA_PICKLE: + Limit: -1 Points: 1 SHULKER_BOX: + Limit: -1 Points: 10 SKELETON_SKULL: + Limit: -1 Points: 10 SKELETON_WALL_SKULL: + Limit: -1 Points: 10 SLIME_BLOCK: + Limit: -1 Points: 10 SMITHING_TABLE: + Limit: -1 Points: 4 SMOKER: + Limit: -1 Points: 4 SMOOTH_QUARTZ: + Limit: -1 Points: 1 SMOOTH_QUARTZ_SLAB: + Limit: -1 Points: 1 SMOOTH_QUARTZ_STAIRS: + Limit: -1 Points: 1 SMOOTH_RED_SANDSTONE: + Limit: -1 Points: 1 SMOOTH_SANDSTONE: + Limit: -1 Points: 1 SMOOTH_SANDSTONE_SLAB: + Limit: -1 Points: 1 SMOOTH_SANDSTONE_STAIRS: + Limit: -1 Points: 1 SMOOTH_STONE: + Limit: -1 Points: 1 SMOOTH_STONE_SLAB: + Limit: -1 Points: 1 SNOW: + Limit: -1 Points: 1 SNOW_BLOCK: + Limit: -1 Points: 1 SOUL_SAND: + Limit: -1 Points: 1 SPAWNER: + Limit: -1 Points: 10 SPAWNER_BAT: + Limit: -1 Points: 10 SPAWNER_BLAZE: + Limit: -1 Points: 10 SPAWNER_CAVE_SPIDER: + Limit: -1 Points: 10 SPAWNER_CHICKEN: + Limit: -1 Points: 10 SPAWNER_COD: + Limit: -1 Points: 10 SPAWNER_COW: + Limit: -1 Points: 10 SPAWNER_CREEPER: + Limit: -1 Points: 10 SPAWNER_DOLPHIN: + Limit: -1 Points: 10 SPAWNER_DONKEY: + Limit: -1 Points: 10 SPAWNER_DROWNED: + Limit: -1 Points: 10 SPAWNER_ELDER_GUARDIAN: + Limit: -1 Points: 10 SPAWNER_ENDER_DRAGON: + Limit: -1 Points: 10 SPAWNER_ENDERMAN: + Limit: -1 Points: 10 SPAWNER_ENDERMITE: + Limit: -1 Points: 10 SPAWNER_EVOKER: + Limit: -1 Points: 10 SPAWNER_GHAST: + Limit: -1 Points: 10 SPAWNER_GIANT: + Limit: -1 Points: 10 SPAWNER_GUARDIAN: + Limit: -1 Points: 10 SPAWNER_HORSE: + Limit: -1 Points: 10 SPAWNER_HUSK: + Limit: -1 Points: 10 SPAWNER_ILLUSIONER: + Limit: -1 Points: 10 SPAWNER_IRON_GOLEM: + Limit: -1 Points: 10 SPAWNER_LLAMA: + Limit: -1 Points: 10 SPAWNER_MAGMA_CUBE: + Limit: -1 Points: 10 SPAWNER_MULE: + Limit: -1 Points: 10 SPAWNER_MUSHROOM_COW: + Limit: -1 Points: 10 SPAWNER_OCELOT: + Limit: -1 Points: 10 SPAWNER_PARROT: + Limit: -1 Points: 10 SPAWNER_PHANTOM: + Limit: -1 Points: 10 SPAWNER_PIG: + Limit: -1 Points: 10 SPAWNER_PIG_ZOMBIE: + Limit: -1 Points: 10 SPAWNER_POLAR_BEAR: + Limit: -1 Points: 10 SPAWNER_PUFFERFISH: + Limit: -1 Points: 10 SPAWNER_RABBIT: + Limit: -1 Points: 10 SPAWNER_SALMON: + Limit: -1 Points: 10 SPAWNER_SHEEP: + Limit: -1 Points: 10 SPAWNER_SHULKER: + Limit: -1 Points: 10 SPAWNER_SILVERFISH: + Limit: -1 Points: 10 SPAWNER_SKELETON: + Limit: -1 Points: 10 SPAWNER_SKELETON_HORSE: + Limit: -1 Points: 10 SPAWNER_SLIME: + Limit: -1 Points: 10 SPAWNER_SNOWMAN: + Limit: -1 Points: 10 SPAWNER_SPIDER: + Limit: -1 Points: 10 SPAWNER_SQUID: + Limit: -1 Points: 10 SPAWNER_STRAY: + Limit: -1 Points: 10 SPAWNER_TROPICAL_FISH: + Limit: -1 Points: 10 SPAWNER_TURTLE: + Limit: -1 Points: 10 SPAWNER_VEX: + Limit: -1 Points: 10 SPAWNER_VILLAGER: + Limit: -1 Points: 10 SPAWNER_VINDICATOR: + Limit: -1 Points: 10 SPAWNER_WITCH: + Limit: -1 Points: 10 SPAWNER_WITHER: + Limit: -1 Points: 10 SPAWNER_WITHER_SKELETON: + Limit: -1 Points: 10 SPAWNER_WOLF: + Limit: -1 Points: 10 SPAWNER_ZOMBIE: + Limit: -1 Points: 10 SPAWNER_ZOMBIE_HORSE: + Limit: -1 Points: 10 SPAWNER_ZOMBIE_VILLAGER: + Limit: -1 Points: 10 SPONGE: + Limit: -1 Points: 10 SPRUCE_BUTTON: + Limit: -1 Points: 1 SPRUCE_DOOR: + Limit: -1 Points: 2 SPRUCE_FENCE: + Limit: -1 Points: 2 SPRUCE_FENCE_GATE: + Limit: -1 Points: 4 SPRUCE_LEAVES: + Limit: -1 Points: 0 SPRUCE_LOG: + Limit: -1 Points: 0 SPRUCE_PLANKS: + Limit: -1 Points: 1 SPRUCE_PRESSURE_PLATE: + Limit: -1 Points: 2 SPRUCE_SAPLING: + Limit: -1 Points: 1 SPRUCE_SIGN: + Limit: -1 Points: 6 SPRUCE_SLAB: + Limit: -1 Points: 1 SPRUCE_STAIRS: + Limit: -1 Points: 2 SPRUCE_TRAPDOOR: + Limit: -1 Points: 3 SPRUCE_WALL_SIGN: + Limit: -1 Points: 6 SPRUCE_WOOD: + Limit: -1 Points: 1 STICKY_PISTON: + Limit: -1 Points: 1 STONE: + Limit: -1 Points: 1 STONE_BRICKS: + Limit: -1 Points: 2 STONE_BRICK_SLAB: + Limit: -1 Points: 1 STONE_BRICK_STAIRS: + Limit: -1 Points: 2 STONE_BRICK_WALL: + Limit: -1 Points: 1 STONE_BUTTON: + Limit: -1 Points: 1 STONECUTTER: + Limit: -1 Points: 4 STONE_PRESSURE_PLATE: + Limit: -1 Points: 2 STONE_SLAB: + Limit: -1 Points: 1 STONE_STAIRS: + Limit: -1 Points: 1 STRIPPED_ACACIA_LOG: + Limit: -1 Points: 0 STRIPPED_ACACIA_WOOD: + Limit: -1 Points: 1 STRIPPED_BIRCH_LOG: + Limit: -1 Points: 0 STRIPPED_BIRCH_WOOD: + Limit: -1 Points: 1 STRIPPED_DARK_OAK_LOG: + Limit: -1 Points: 0 STRIPPED_DARK_OAK_WOOD: + Limit: -1 Points: 1 STRIPPED_JUNGLE_LOG: + Limit: -1 Points: 0 STRIPPED_JUNGLE_WOOD: + Limit: -1 Points: 1 STRIPPED_OAK_LOG: + Limit: -1 Points: 0 STRIPPED_OAK_WOOD: + Limit: -1 Points: 1 STRIPPED_SPRUCE_LOG: + Limit: -1 Points: 0 STRIPPED_SPRUCE_WOOD: + Limit: -1 Points: 1 SUGAR_CANE: + Limit: -1 Points: 1 SUNFLOWER: + Limit: -1 Points: 1 SWEET_BERRY_BUSH: + Limit: -1 Points: 1 TALL_GRASS: + Limit: -1 Points: 1 TALL_SEAGRASS: + Limit: -1 Points: 1 TERRACOTTA: + Limit: -1 Points: 2 TNT: + Limit: -1 Points: 5 TORCH: + Limit: -1 Points: 1 TRAPPED_CHEST: + Limit: -1 Points: 10 TRIPWIRE: + Limit: -1 Points: 2 TRIPWIRE_HOOK: + Limit: -1 Points: 2 TUBE_CORAL: + Limit: -1 Points: 1 TUBE_CORAL_BLOCK: + Limit: -1 Points: 1 TUBE_CORAL_FAN: + Limit: -1 Points: 1 TUBE_CORAL_WALL_FAN: + Limit: -1 Points: 1 TURTLE_EGG: + Limit: -1 Points: 1 VINE: + Limit: -1 Points: 1 VOID_AIR: + Limit: -1 Points: 0 WALL_TORCH: + Limit: -1 Points: 1 WET_SPONGE: + Limit: -1 Points: 10 WHEAT: + Limit: -1 Points: 1 WHITE_BANNER: + Limit: -1 Points: 2 WHITE_BED: + Limit: -1 Points: 6 WHITE_CARPET: + Limit: -1 Points: 1 WHITE_CONCRETE: + Limit: -1 Points: 3 WHITE_CONCRETE_POWDER: + Limit: -1 Points: 2 WHITE_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 WHITE_SHULKER_BOX: + Limit: -1 Points: 11 WHITE_STAINED_GLASS: + Limit: -1 Points: 2 WHITE_STAINED_GLASS_PANE: + Limit: -1 Points: 1 WHITE_TERRACOTTA: + Limit: -1 Points: 2 WHITE_TULIP: + Limit: -1 Points: 1 WHITE_WALL_BANNER: + Limit: -1 Points: 2 WHITE_WOOL: + Limit: -1 Points: 3 WITHER_ROSE: + Limit: -1 Points: 1 WITHER_SKELETON_SKULL: + Limit: -1 Points: 10 WITHER_SKELETON_WALL_SKULL: + Limit: -1 Points: 10 YELLOW_BANNER: + Limit: -1 Points: 2 YELLOW_BED: + Limit: -1 Points: 6 YELLOW_CARPET: + Limit: -1 Points: 1 YELLOW_CONCRETE: + Limit: -1 Points: 2 YELLOW_CONCRETE_POWDER: + Limit: -1 Points: 2 YELLOW_GLAZED_TERRACOTTA: + Limit: -1 Points: 5 YELLOW_SHULKER_BOX: + Limit: -1 Points: 11 YELLOW_STAINED_GLASS: + Limit: -1 Points: 2 YELLOW_STAINED_GLASS_PANE: + Limit: -1 Points: 1 YELLOW_TERRACOTTA: + Limit: -1 Points: 2 YELLOW_WALL_BANNER: + Limit: -1 Points: 2 YELLOW_WOOL: + Limit: -1 Points: 2 ZOMBIE_HEAD: + Limit: -1 Points: 1 ZOMBIE_WALL_HEAD: + Limit: -1 Points: 1 \ No newline at end of file From 95d605c02594da78b92eb0caf10228596398af2c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 22:33:14 +0200 Subject: [PATCH 104/366] Spigot 1.16.1 + Biome menu --- pom.xml | 10 +- .../songoda/skyblock/biome/BiomeManager.java | 11 +- .../command/commands/island/BiomeCommand.java | 6 +- .../songoda/skyblock/config/FileManager.java | 6 +- .../skyblock/generator/GeneratorManager.java | 14 +- .../songoda/skyblock/gui/wip/BiomeIcon.java | 25 +- .../songoda/skyblock/gui/wip/GuiBiome.java | 80 ++- .../skyblock/island/IslandManager.java | 35 +- .../com/songoda/skyblock/listeners/Block.java | 34 +- .../com/songoda/skyblock/listeners/Move.java | 58 +- .../songoda/skyblock/listeners/Portal.java | 10 +- .../permissions/listening/FirePermission.java | 18 +- .../listening/PortalPermission.java | 28 +- .../skyblock/tasks/MobNetherWaterTask.java | 29 +- .../skyblock/utils/world/LocationUtil.java | 42 +- .../skyblock/utils/world/block/BlockData.java | 9 + .../utils/world/block/BlockStateType.java | 2 +- .../skyblock/utils/world/block/BlockUtil.java | 49 +- .../utils/world/entity/EntityUtil.java | 40 +- src/main/resources/biomes.yml | 586 ++++++++++-------- src/main/resources/config.yml | 61 +- src/main/resources/language.yml | 6 +- src/main/resources/stackables.yml | 1 + 23 files changed, 671 insertions(+), 489 deletions(-) diff --git a/pom.xml b/pom.xml index 139be75c..5a479c5f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.4-DEV2 + 2.3.4-DEV3 jar UTF-8 @@ -147,9 +147,9 @@ compile - com.destroystokyo.papermc - paper - 1.15.2 + com.destroystokyo.paper + paper-api + 1.16.1-R0.1-SNAPSHOT provided @@ -161,7 +161,7 @@ org.spigotmc spigot - 1.15 + 1.16.1 provided diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 633aa308..d43f3eb9 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -22,9 +22,8 @@ public class BiomeManager { } public void setBiome(Island island, Biome biome) { - Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island); - if (location == null) return; + if (island.getLocation(IslandWorld.Normal, IslandEnvironment.Island) == null) return; if(skyblock.isPaperAsync()){ // We keep it sequentially in order to use less RAM @@ -48,7 +47,13 @@ public class BiomeManager { private void setChunkBiome(Biome biome, Chunk chunk) { for(int xx = 0; xx < 16; xx++){ for(int zz = 0; zz < 16; zz++){ - chunk.getBlock(xx, 0, zz).setBiome(biome); + //if(ServerVersion.isServerVersionBelow(ServerVersion.V1_15)){ + chunk.getBlock(xx, 0, zz).setBiome(biome); + //} else { + // for(int i = 0; i<256; i+=2){ + // chunk.getBlock(xx, i, zz).setBiome(biome); + // } + //} } } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java index ca7003c6..bee983d1 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java @@ -3,12 +3,16 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.gui.bank.GuiBank; +import com.songoda.skyblock.gui.wip.GuiBiome; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.menus.Biome; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.world.WorldManager; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -34,7 +38,7 @@ public class BiomeCommand extends SubCommand { } else if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) && skyblock.getPermissionManager().hasPermission(island,"Biome", IslandRole.Operator)) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - Biome.getInstance().open(player); + skyblock.getGuiManager().showGUI(player, new GuiBiome(skyblock, player, island, IslandWorld.Normal, null, false)); // TODO Nether and End support soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Permission.Message")); diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java index a695a73c..62248fe3 100644 --- a/src/main/java/com/songoda/skyblock/config/FileManager.java +++ b/src/main/java/com/songoda/skyblock/config/FileManager.java @@ -67,7 +67,7 @@ public class FileManager { configFiles.put("language.yml", new File(skyblock.getDataFolder(), "language.yml")); configFiles.put("settings.yml", new File(skyblock.getDataFolder(), "settings.yml")); configFiles.put("upgrades.yml", new File(skyblock.getDataFolder(), "upgrades.yml")); - // configFiles.put("biomes.yml", new File(skyblock.getDataFolder(), "biomes.yml")); + configFiles.put("biomes.yml", new File(skyblock.getDataFolder(), "biomes.yml")); // configFiles.put("menus.yml", new File(skyblock.getDataFolder(), "menus.yml")); configFiles.put("generators.yml", new File(skyblock.getDataFolder(), "generators.yml")); configFiles.put("stackables.yml", new File(skyblock.getDataFolder(), "stackables.yml")); @@ -102,10 +102,10 @@ public class FileManager { } if (configFile.exists()) { - if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("worlds.yml")) { + if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("worlds.yml") || fileName.equals("biomes.yml")) { FileChecker fileChecker; - if (fileName.equals("config.yml")) { + if (fileName.equals("config.yml") || fileName.equals("biomes.yml")) { fileChecker = new FileChecker(skyblock, this, fileName, true); } else { fileChecker = new FileChecker(skyblock, this, fileName, false); diff --git a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java index fc822d1e..28bd5075 100644 --- a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java +++ b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java @@ -37,10 +37,6 @@ public class GeneratorManager { if (configLoad.getString("Generators") == null) return; - CompatibleMaterial[] oreMaterials = new CompatibleMaterial[]{CompatibleMaterial.COAL, CompatibleMaterial.CHARCOAL, CompatibleMaterial.DIAMOND, - CompatibleMaterial.IRON_INGOT, CompatibleMaterial.GOLD_INGOT, CompatibleMaterial.EMERALD}; - Random rnd = new Random(); - for (String generatorList : configLoad.getConfigurationSection("Generators").getKeys(false)) { if (configLoad.getString("Generators." + generatorList + ".Name") == null) continue; @@ -55,10 +51,18 @@ public class GeneratorManager { } } } + + Random rnd = new Random(); + CompatibleMaterial icon; + if(!generatorMaterials.isEmpty()) { + icon = generatorMaterials.get(rnd.nextInt(generatorMaterials.size())).getMaterials(); + } else { + icon = CompatibleMaterial.STONE; + } generatorStorage.add(new Generator(configLoad.getString("Generators." + generatorList + ".Name"), IslandWorld.valueOf(configLoad.getString("Generators." + generatorList + ".World", "Normal")), - oreMaterials[rnd.nextInt(oreMaterials.length)], generatorMaterials, + icon, generatorMaterials, configLoad.getBoolean("Generators." + generatorList + ".Permission"))); } } diff --git a/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java b/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java index 4aaeb20e..071f3bd0 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java @@ -1,13 +1,18 @@ package com.songoda.skyblock.gui.wip; import com.songoda.core.compatibility.CompatibleBiome; +import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.io.File; +import java.util.Map; public class BiomeIcon { public final CompatibleBiome biome; @@ -19,8 +24,15 @@ public class BiomeIcon { public BiomeIcon(SkyBlock plugin, CompatibleBiome biome){ this.biome = biome; - FileConfiguration biomeConfig = plugin.getFileManager().getConfig(new File("biomes.yml")).getFileConfiguration(); - this.displayItem = null; // TODO + FileConfiguration biomeConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(),"biomes.yml")).getFileConfiguration(); + + CompatibleMaterial tempMat = CompatibleMaterial.getMaterial(biomeConfig.getString("Biomes." + biome.name() + ".DisplayItem.Material")); + if(tempMat == null){ + tempMat = CompatibleMaterial.STONE; + } + byte tempData = (byte) biomeConfig.getInt("Biomes." + biome.name() + ".DisplayItem.Data", 0); + + this.displayItem = CompatibleMaterial.getMaterial(tempMat.getMaterial(), tempData).getItem(); ItemMeta im = displayItem.getItemMeta(); if(im != null){ im.setDisplayName(ChatColor.translateAlternateColorCodes('&', biomeConfig.getString("Biomes." + biome.name() + ".DisplayName", biome.name()))); @@ -45,4 +57,13 @@ public class BiomeIcon { this.nether = nether; this.end = end; } + + public void enchant(){ + ItemMeta im = displayItem.getItemMeta(); + if(im != null){ + im.addEnchant(Enchantment.DURABILITY,1, true); + im.addItemFlags(ItemFlag.HIDE_ENCHANTS); + displayItem.setItemMeta(im); + } + } } diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java index 02006aa7..cb97c202 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java @@ -24,6 +24,7 @@ import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -32,6 +33,7 @@ import org.bukkit.inventory.meta.ItemMeta; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Objects; @@ -46,7 +48,7 @@ public class GuiBiome extends Gui { private final boolean admin; public GuiBiome(SkyBlock plugin, Player player, Island island, IslandWorld world, Gui returnGui, boolean admin) { - super(returnGui); + super(6, returnGui); this.plugin = plugin; this.island = island; this.world = world; @@ -58,7 +60,7 @@ public class GuiBiome extends Gui { this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); setDefaultItem(null); - setTitle(TextUtils.formatText(languageLoad.getString("Menu.Input.Title"))); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Biome.Title"))); paint(); } @@ -71,56 +73,63 @@ public class GuiBiome extends Gui { if (inventory != null) inventory.clear(); - setActionForRange(0, 0, 1, 8, null); + setActionForRange(0, 0, 5, 9, null); setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Exit.Displayname"))), (event) -> { soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Bans.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Exit.Displayname"))), (event) -> { soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); event.player.closeInventory(); }); - + + setItem(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, // Info + TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Info.Displayname")), + TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Info.Lore") + .replace("%biome_type", island.getBiomeName())))); + for(int i=9; i<18; i++){ setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); } List biomes = new ArrayList<>(); for(CompatibleBiome biome : CompatibleBiome.getCompatibleBiomes()) { - if(biome.isCompatible() - && player.hasPermission("fabledskyblock.biome." + biome.name().toLowerCase()) - && config.getBoolean("Island.Biome." + world.name() + "." + biome.name(), false)){ + if(biome.isCompatible()){ BiomeIcon icon = new BiomeIcon(plugin, biome); - switch(world){ - case Normal: - if(icon.normal){ - biomes.add(icon); - } - break; - case Nether: - if(icon.nether){ - biomes.add(icon); - } - break; - case End: - if(icon.end){ - biomes.add(icon); - } - break; + if(!icon.permission || player.hasPermission("fabledskyblock.biome." + biome.name().toLowerCase())){ + switch(world){ + case Normal: + if(icon.normal){ + biomes.add(icon); + } + break; + case Nether: + if(icon.nether){ + biomes.add(icon); + } + break; + case End: + if(icon.end){ + biomes.add(icon); + } + break; + } } } } if(biomes.size() > 0){ + biomes.sort(Comparator.comparing(m -> m.biome)); + this.pages = (int) Math.max(1, Math.ceil((double) biomes.size() / 27d)); if (page != 1) setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))), + TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Last.Displayname"))), (event) -> { page--; paint(); @@ -128,14 +137,14 @@ public class GuiBiome extends Gui { if (page != pages) setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))), + TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Next.Displayname"))), (event) -> { page++; paint(); }); - for (int i = 9; i < ((getRows()-1)*9)+9; i++) { - int current = ((page - 1) * 36) - 9; + for (int i = 18; i < ((getRows()-2)*9)+9; i++) { + int current = ((page - 1) * 27) - 18; if (current + i >= biomes.size()) { setItem(i, null); continue; @@ -143,6 +152,10 @@ public class GuiBiome extends Gui { BiomeIcon icon = biomes.get(current + i); if (icon == null) continue; + if(icon.biome.getBiome().equals(island.getBiome())){ + icon.enchant(); + } + setButton(i, icon.displayItem, event -> { if (cooldownManager.hasPlayer(CooldownType.Biome, player) && !player.hasPermission("fabledskyblock.bypass.cooldown")) { CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Biome, player); @@ -169,9 +182,11 @@ public class GuiBiome extends Gui { return; } cooldownManager.createPlayer(CooldownType.Biome, player); - biomeManager.setBiome(island, icon.biome.getBiome()); + Bukkit.getScheduler().runTask(plugin, () -> { + biomeManager.setBiome(island, icon.biome.getBiome()); + island.save(); + }); island.setBiome(icon.biome.getBiome()); - island.save(); soundManager.playSound(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island), CompatibleSound.ENTITY_GENERIC_SPLASH.getSound(), 1.0F, 1.0F); @@ -179,10 +194,11 @@ public class GuiBiome extends Gui { if (!islandManager.isPlayerAtIsland(island, player, IslandWorld.Normal)) { soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_SPLASH.getSound(), 1.0F, 1.0F); } + paint(); }); } } else { - setItem(31, CompatibleMaterial.BARRIER.getItem()); + setItem(31, CompatibleMaterial.BARRIER.getItem()); // TODO } } } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 6422f7b1..fcf00d25 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1137,29 +1137,26 @@ public class IslandManager { } } } - - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { - Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor); - if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - CompletableFuture safeLoc = LocationUtil.getSafeLocation(loc); - if(safeLoc != null){ - loc = safeLoc.join(); - } - } - if(loc != null){ - PaperLib.teleportAsync(player, 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"))); + Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor); + if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { + Location safeLoc = LocationUtil.getSafeLocation(loc); + if(safeLoc != null){ + loc = safeLoc; } + } + if(loc != null){ + PaperLib.teleportAsync(player, 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); diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index e1af24ab..18f85624 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -3,6 +3,7 @@ package com.songoda.skyblock.listeners; import com.google.common.collect.Lists; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.generator.Generator; @@ -215,7 +216,7 @@ public class Block implements Listener { 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)){ + if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)){ skyblock.getMessageManager().sendMessage(player, Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message"))); event.setCancelled(true); @@ -326,24 +327,31 @@ public class Block implements Listener { Collection entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d); if(entities.size() > 0){ for(Entity ent : entities){ + boolean witherSkeleton; - if (NMSUtil.getVersionNumber() > 10) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON); } else { witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER); } - if (ent.getType().equals(EntityType.PIG_ZOMBIE) || - ent.getType().equals(EntityType.BLAZE) || - ent.getType().equals(EntityType.MAGMA_CUBE) || - ent.getType().equals(EntityType.WITHER) || - ent.getType().equals(EntityType.GHAST) || - witherSkeleton) { - if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){ - event.setCancelled(true); - event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f); - event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); + if((((ent instanceof Blaze || ent instanceof MagmaCube) || ent instanceof Wither) || ent instanceof Ghast) || witherSkeleton){ + event.setCancelled(true); + event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f); + event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); + } else { + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ + if(((ent instanceof Piglin || ent instanceof Hoglin) || ent instanceof Strider) || ent instanceof Zoglin) { + event.setCancelled(true); + event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f); + event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); + } + } else { + if(ent instanceof PigZombie) { + event.setCancelled(true); + event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f); + event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); + } } - break; } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index fbdaaaf7..df80784c 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -194,41 +194,37 @@ public class Move implements Listener { } private void teleportPlayerToIslandSpawn(Player player, IslandWorld world, Island island) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - Location loc = null; - 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)) { - CompletableFuture safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main)); - if(safeLoc != null){ - loc = safeLoc.join(); - } - } else { - loc = island.getLocation(world, IslandEnvironment.Main); - LocationUtil.removeWaterFromLoc(skyblock, loc); + Location loc = null; + 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)) { + Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main)); + if(safeLoc != null){ + loc = safeLoc; } } else { - if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - CompletableFuture safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor)); - if(safeLoc != null){ - loc = safeLoc.join(); - } - } else { - loc = island.getLocation(world, IslandEnvironment.Visitor); - } + loc = island.getLocation(world, IslandEnvironment.Main); + LocationUtil.removeWaterFromLoc(skyblock, loc); } - Location finalLoc = loc; - Bukkit.getScheduler().runTask(skyblock, () -> { - if(finalLoc != null){ - PaperLib.teleportAsync(player, finalLoc); - } else { - LocationUtil.teleportPlayerToSpawn(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) - .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message"))); + } else { + if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { + Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor)); + if(safeLoc != null){ + loc = safeLoc; } - }); - }); + } else { + loc = island.getLocation(world, IslandEnvironment.Visitor); + } + } + Location finalLoc = loc; + if(finalLoc != null){ + PaperLib.teleportAsync(player, finalLoc); + } else { + LocationUtil.teleportPlayerToSpawn(player); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message"))); + } } private void teleportPlayerToIslandSpawn(Player player, Island island) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 3874091e..4657f983 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -164,20 +164,18 @@ 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().runTaskLaterAsynchronously(skyblock, () -> { + Bukkit.getScheduler().runTaskLater(skyblock, () -> { Location loc = island.getLocation(toWorldF, spawnEnvironment); - CompletableFuture tempSafeLoc = LocationUtil.getSafeLocation(loc); + Location tempSafeLoc = LocationUtil.getSafeLocation(loc); Location safeLoc = null; if(tempSafeLoc != null) { - safeLoc = tempSafeLoc.join(); + safeLoc = tempSafeLoc; } if(safeLoc != null){ loc = safeLoc; } Location finalLoc = loc; - Bukkit.getScheduler().runTask(skyblock, () -> { - PaperLib.teleportAsync(player, finalLoc); - }); + PaperLib.teleportAsync(player, finalLoc); }, 1L); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); player.setFallDistance(0.0F); diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java index c67880dc..3cdadb2d 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java @@ -8,7 +8,9 @@ import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.player.PlayerInteractEvent; public class FirePermission extends ListeningPermission { @@ -29,7 +31,21 @@ public class FirePermission extends ListeningPermission { Player player = event.getPlayer(); - if (CompatibleMaterial.getMaterial(player.getTargetBlock(null, 5)) == CompatibleMaterial.FIRE) + if (CompatibleMaterial.getMaterial(player.getTargetBlock(null, 5)).equals(CompatibleMaterial.FIRE)) cancelAndMessage(event, player, plugin, messageManager); } + + @PermissionHandler + public void onProjectileHit(BlockIgniteEvent event) { + Player player = null; + if(event.getPlayer() != null){ + player = event.getPlayer(); + } else if(event.getIgnitingEntity() instanceof Projectile && ((Projectile) event.getIgnitingEntity()).getShooter() instanceof Player) { + player = (Player) ((Projectile) event.getIgnitingEntity()).getShooter(); + } + + if(player != null) { + cancelAndMessage(event, player, plugin, messageManager); + } + } } diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index 65769a12..c5fb8811 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -70,22 +70,20 @@ public class PortalPermission extends ListeningPermission { } } - private CompletableFuture getToLocation(Location from, Player player) { - return CompletableFuture.supplyAsync(() -> { - IslandManager islandManager = plugin.getIslandManager(); - Island island = islandManager.getIslandAtLocation(from); - Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); - if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ - CompletableFuture safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - if(safeLoc != null) { - to = safeLoc.join(); - } - if(to == null){ - to = LocationUtil.getSpawnLocation(); - } + private Location getToLocation(Location from, Player player) { + IslandManager islandManager = plugin.getIslandManager(); + Island island = islandManager.getIslandAtLocation(from); + Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); + if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ + Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); + if(safeLoc != null) { + to = safeLoc; } - return to; - }); + if(to == null){ + to = LocationUtil.getSpawnLocation(); + } + } + return to; } } diff --git a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java index ac22f427..f3897214 100644 --- a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.tasks; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; @@ -19,10 +20,7 @@ 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.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; +import org.bukkit.entity.*; import org.bukkit.scheduler.BukkitRunnable; import java.io.File; @@ -57,20 +55,29 @@ public class MobNetherWaterTask extends BukkitRunnable { if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){ for(Entity ent : world.getEntities()) { boolean witherSkeleton; - if (NMSUtil.getVersionNumber() > 10) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON); } else { witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER); } - if (ent.getType().equals(EntityType.PIG_ZOMBIE) || - ent.getType().equals(EntityType.BLAZE) || - ent.getType().equals(EntityType.MAGMA_CUBE) || - ent.getType().equals(EntityType.WITHER) || - ent.getType().equals(EntityType.GHAST) || - witherSkeleton) { + if((((ent instanceof Blaze || ent instanceof MagmaCube) || ent instanceof Wither) || ent instanceof Ghast) || witherSkeleton){ Block block = ent.getLocation().getBlock(); removeWater(world, block); removeWater(world, block.getRelative(BlockFace.UP)); + } else { + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ + if(((ent instanceof Piglin || ent instanceof Hoglin) || ent instanceof Strider) || ent instanceof Zoglin) { + Block block = ent.getLocation().getBlock(); + removeWater(world, block); + removeWater(world, block.getRelative(BlockFace.UP)); + } + } else { + if(ent instanceof PigZombie) { + Block block = ent.getLocation().getBlock(); + removeWater(world, block); + removeWater(world, block.getRelative(BlockFace.UP)); + } + } } } } 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 0b2abe20..4b1ecbd4 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -42,31 +42,29 @@ public final class LocationUtil { } } - public static @Nullable CompletableFuture getSafeLocation(Location loc){ - return CompletableFuture.supplyAsync(() -> { - boolean found = false; - Location locChecked = null; - if(loc != null && loc.getWorld() != null){ - 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); + public static @Nullable Location getSafeLocation(Location loc){ + boolean found = false; + Location locChecked = null; + if(loc != null && loc.getWorld() != null){ + 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){ - 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; - }); + if (found) { + locChecked = locChecked.add(0d,1d,0d); + } else { + locChecked = null; + } + } + return locChecked; } public static @Nonnull Location getDefinitiveLocation(Location loc){ diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java index 02c81bd8..544ca768 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java +++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java @@ -34,6 +34,7 @@ public class BlockData { private String skullOwner = "Notch"; private String skullType = SkullType.PLAYER.toString(); private String facing; + private int charges = 0; private Map inventory = new HashMap<>(); @@ -313,4 +314,12 @@ public class BlockData { public void setExactTeleport(boolean exactTeleport) { this.exactTeleport = exactTeleport; } + + public int getCharges() { + return charges; + } + + public void setCharges(int charges) { + this.charges = charges; + } } diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java index ebfb6f2e..52d6da1c 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java +++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockStateType.java @@ -3,6 +3,6 @@ package com.songoda.skyblock.utils.world.block; public enum BlockStateType { NORMAL, BANNER, BEACON, BREWINGSTAND, COMMANDBLOCK, CHEST, DISPENSER, DROPPER, HOPPER, SHULKERBOX, CREATURESPAWNER, - ENDGATEWAY, FURNACE, JUKEBOX, SIGN, SKULL, DOUBLECHEST, BARREL + ENDGATEWAY, FURNACE, JUKEBOX, SIGN, SKULL, DOUBLECHEST, BARREL, RESPAWN_ANCHOR } \ No newline at end of file diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java index a65b70ce..2a74d19a 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java @@ -9,6 +9,7 @@ import org.bukkit.*; import org.bukkit.block.*; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; +import org.bukkit.block.data.type.RespawnAnchor; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; @@ -212,6 +213,14 @@ public final class BlockUtil extends BlockUtils { blockData.setStateType(BlockStateType.BARREL.toString()); } + + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ + if (blockState instanceof RespawnAnchor) { + RespawnAnchor respawnAnchor = (RespawnAnchor) blockState; + blockData.setCharges(respawnAnchor.getCharges()); + blockData.setStateType(BlockStateType.RESPAWN_ANCHOR.toString()); + } + } } } } @@ -284,7 +293,7 @@ public final class BlockUtil extends BlockUtils { BlockState state = block.getState(); - if (blockTypeState == BlockStateType.BANNER) { + if (blockTypeState.equals(BlockStateType.BANNER)) { Banner banner = (Banner) state; banner.setBaseColor(DyeColor.valueOf(blockData.getBaseColor().toUpperCase())); @@ -293,7 +302,7 @@ public final class BlockUtil extends BlockUtils { banner.addPattern(new Pattern(DyeColor.valueOf(pattern[1].toUpperCase()), PatternType.valueOf(pattern[0].toUpperCase()))); } state.update(); - } else if (blockTypeState == BlockStateType.BEACON) { + } else if (blockTypeState.equals(BlockStateType.BEACON)) { Beacon beacon = (Beacon) state; String[] potionEffect = blockData.getPotionEffect().split(":"); if (!potionEffect[0].equals("null")) { @@ -304,17 +313,17 @@ public final class BlockUtil extends BlockUtils { beacon.setSecondaryEffect(PotionEffectType.getByName(potionEffect[1].toUpperCase())); } state.update(); - } else if (blockTypeState == BlockStateType.BREWINGSTAND && ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) { + } else if (blockTypeState.equals(BlockStateType.BREWINGSTAND) && ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) { BrewingStand brewingStand = (BrewingStand) state; brewingStand.setBrewingTime(blockData.getBrewingTime()); brewingStand.setFuelLevel(blockData.getFuelLevel()); state.update(); - } else if (blockTypeState == BlockStateType.COMMANDBLOCK) { + } else if (blockTypeState.equals(BlockStateType.COMMANDBLOCK)) { CommandBlock commandBlock = (CommandBlock) state; commandBlock.setCommand(blockData.getCommand()); commandBlock.setName(blockData.getCommandBlockName()); state.update(); - } else if (blockTypeState == BlockStateType.CHEST) { + } else if (blockTypeState.equals(BlockStateType.CHEST)) { Chest chest = (Chest) state; for (Integer slotList : blockData.getInventory().keySet()) { @@ -323,7 +332,7 @@ public final class BlockUtil extends BlockUtils { chest.getInventory().setItem(slotList, is); } } - } else if (blockTypeState == BlockStateType.DISPENSER) { + } else if (blockTypeState.equals(BlockStateType.DISPENSER)) { Dispenser dispenser = (Dispenser) state; for (Integer slotList : blockData.getInventory().keySet()) { @@ -332,7 +341,7 @@ public final class BlockUtil extends BlockUtils { dispenser.getInventory().setItem(slotList, is); } } - } else if (blockTypeState == BlockStateType.DROPPER) { + } else if (blockTypeState.equals(BlockStateType.DROPPER)) { Dropper dropper = (Dropper) state; for (Integer slotList : blockData.getInventory().keySet()) { @@ -341,7 +350,7 @@ public final class BlockUtil extends BlockUtils { dropper.getInventory().setItem(slotList, is); } } - } else if (blockTypeState == BlockStateType.HOPPER) { + } else if (blockTypeState.equals(BlockStateType.HOPPER)) { Hopper hopper = (Hopper) state; for (Integer slotList : blockData.getInventory().keySet()) { @@ -350,7 +359,7 @@ public final class BlockUtil extends BlockUtils { hopper.getInventory().setItem(slotList, is); } } - } else if (blockTypeState == BlockStateType.CREATURESPAWNER) { + } else if (blockTypeState.equals(BlockStateType.CREATURESPAWNER)) { CreatureSpawner creatureSpawner = (CreatureSpawner) state; if (blockData.getEntity() != null) { @@ -359,7 +368,7 @@ public final class BlockUtil extends BlockUtils { creatureSpawner.setDelay(blockData.getDelay()); state.update(); - } else if (blockTypeState == BlockStateType.FURNACE) { + } else if (blockTypeState.equals(BlockStateType.FURNACE)) { Furnace furnace = (Furnace) state; furnace.setBurnTime(blockData.getBurnTime()); furnace.setCookTime(blockData.getCookTime()); @@ -372,21 +381,21 @@ public final class BlockUtil extends BlockUtils { furnace.getInventory().setItem(slotList, is); } } - } else if (blockTypeState == BlockStateType.JUKEBOX) { + } else if (blockTypeState.equals(BlockStateType.JUKEBOX)) { Jukebox jukebox = (Jukebox) state; if (blockData.getPlaying() != null) { jukebox.setPlaying(Material.valueOf(blockData.getPlaying().toUpperCase())); } state.update(); - } else if (blockTypeState == BlockStateType.SIGN) { + } else if (blockTypeState.equals(BlockStateType.SIGN)) { Sign sign = (Sign) state; for (int i = 0; i < blockData.getSignLines().length; i++) { sign.setLine(i, ChatColor.translateAlternateColorCodes('&', blockData.getSignLines()[i])); } state.update(); - } else if (blockTypeState == BlockStateType.SKULL) { + } else if (blockTypeState.equals(BlockStateType.SKULL)) { Skull skull = (Skull) state; skull.setRotation(BlockFace.valueOf(blockData.getRotateFace().toUpperCase())); @@ -400,7 +409,7 @@ public final class BlockUtil extends BlockUtils { state.update(); } else { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { - if (blockTypeState == BlockStateType.ENDGATEWAY) { + if (blockTypeState.equals(BlockStateType.ENDGATEWAY)) { EndGateway endGateway = (EndGateway) state; endGateway.setExactTeleport(blockData.isExactTeleport()); @@ -416,7 +425,7 @@ public final class BlockUtil extends BlockUtils { } if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { - if (blockTypeState == BlockStateType.SHULKERBOX) { + if (blockTypeState.equals(BlockStateType.SHULKERBOX)) { ShulkerBox shulkerBox = (ShulkerBox) state; for (Integer slotList : blockData.getInventory().keySet()) { @@ -427,7 +436,7 @@ public final class BlockUtil extends BlockUtils { } } if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)){ - if (blockTypeState == BlockStateType.BARREL) { + if (blockTypeState.equals(BlockStateType.BARREL)) { Barrel barrel = (Barrel) state; for (Integer slotList : blockData.getInventory().keySet()) { @@ -438,6 +447,14 @@ public final class BlockUtil extends BlockUtils { } } } + + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ + if (blockTypeState.equals(BlockStateType.RESPAWN_ANCHOR)) { + RespawnAnchor respawnAnchor = (RespawnAnchor) state; + respawnAnchor.setCharges(blockData.getCharges()); + state.update(); + } + } } } } diff --git a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java index ea550a4f..eb555348 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.utils.world.entity; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.utils.item.ItemStackUtil; import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.block.BlockDegreesType; @@ -496,43 +497,4 @@ public final class EntityUtil { } } } - - public static boolean isMonster(EntityType type) { - if (NMSUtil.getVersionNumber() > 10) { - if(type.equals(EntityType.WITHER_SKELETON)) return true; // TODO In < 11 we have SkeletonType.Wither - } - switch (type) { // TODO Check server versions - case BAT: - case BLAZE: - case CAVE_SPIDER: - case COD: - case CREEPER: - case DROWNED: - case ELDER_GUARDIAN: - case ENDERMAN: - case ENDERMITE: - case EVOKER: - case GHAST: - case HUSK: - case ILLUSIONER: - case MAGMA_CUBE: - case PHANTOM: - case PIG_ZOMBIE: - case RAVAGER: - case SILVERFISH: - case SKELETON: - case SLIME: - case SPIDER: - case STRAY: - case VEX: - case VINDICATOR: - case WITCH: - case WITHER: - case ZOMBIE: - case ZOMBIE_VILLAGER: - return true; - default: - return false; - } - } } diff --git a/src/main/resources/biomes.yml b/src/main/resources/biomes.yml index d4a01b8f..9947bfb6 100644 --- a/src/main/resources/biomes.yml +++ b/src/main/resources/biomes.yml @@ -1,497 +1,567 @@ +# All the Minecraft Biomes +# Use "Data" only on pre - 1.13 +# Normal: true means that the biome is available in the Overworld. +# Nether and The End will come in future updates. + Biomes: BADLANDS: - DisplayName: 'Badlands' - DiplayItem: + DisplayName: '&6Badlands' + DisplayItem: Material: WHITE_TERRACOTTA Data: 0 Permission: true Normal: true - Nether: false - End: false BADLANDS_PLATEAU: - DisplayName: 'Badlands Plateau' - DiplayItem: + DisplayName: '&6Badlands Plateau' + DisplayItem: Material: RED_TERRACOTTA Data: 14 Permission: true Normal: true - Nether: false - End: false BAMBOO_JUNGLE: - DisplayName: 'Bamboo Jungle' - DiplayItem: + DisplayName: '&6Bamboo Jungle' + DisplayItem: Material: BAMBOO Data: 0 Permission: true Normal: true - Nether: false - End: false BAMBOO_JUNGLE_HILLS: - DisplayName: 'Bamboo Jungle Hills' - DiplayItem: - Material: BAMBOO + DisplayName: '&6Bamboo Jungle Hills' + DisplayItem: + Material: SCAFFOLDING Data: 0 Permission: true Normal: true - Nether: false - End: false BASALT_DELTAS: - DisplayName: 'Basalt Deltas' - DiplayItem: + DisplayName: '&6Basalt Deltas' + DisplayItem: Material: BASALT Data: 0 Permission: true Normal: false - Nether: true - End: false BEACH: - DisplayName: 'Beach' + DisplayName: '&6Beach' + DisplayItem: + Material: SAND + Data: 0 Permission: true Normal: true - Nether: false - End: false BIRCH_FOREST: - DisplayName: 'Birch Forest' + DisplayName: '&6Birch Forest' + DisplayItem: + Material: BIRCH_SAPLING + Data: 0 Permission: true Normal: true - Nether: false - End: false BIRCH_FOREST_HILLS: - DisplayName: 'Birch Forest Hills' + DisplayName: '&6Birch Forest Hills' + DisplayItem: + Material: BIRCH_LEAVES + Data: 0 Permission: true Normal: true - Nether: false - End: false COLD_OCEAN: - DisplayName: 'Cold Ocean' + DisplayName: '&6Cold Ocean' + DisplayItem: + Material: SEAGRASS + Data: 0 Permission: true Normal: true - Nether: false - End: false CRIMSON_FOREST: - DisplayName: 'Crimson Forest' + DisplayName: '&6Crimson Forest' + DisplayItem: + Material: WEEPING_VINES + Data: 0 Permission: true Normal: false - Nether: true - End: false DARK_FOREST: - DisplayName: 'Dark Forest' + DisplayName: '&6Dark Forest' + DisplayItem: + Material: DARK_OAK_SAPLING + Data: 0 Permission: true Normal: true - Nether: false - End: false DARK_FOREST_HILLS: - DisplayName: 'Dark Forest Hills' + DisplayName: '&6Dark Forest Hills' + DisplayItem: + Material: DARK_OAK_LEAVES + Data: 0 Permission: true Normal: true - Nether: false - End: false DEEP_COLD_OCEAN: - DisplayName: 'Deep Cold Ocean' + DisplayName: '&6Deep Cold Ocean' + DisplayItem: + Material: COD + Data: 0 Permission: true Normal: true - Nether: false - End: false DEEP_FROZEN_OCEAN: - DisplayName: 'Deep Frozen Ocean' + DisplayName: '&6Deep Frozen Ocean' + DisplayItem: + Material: ICE + Data: 0 Permission: true Normal: true - Nether: false - End: false DEEP_LUKEWARM_OCEAN: - DisplayName: 'Deep Lukewarm Ocean' + DisplayName: '&6Deep Lukewarm Ocean' + DisplayItem: + Material: PUFFERFISH + Data: 0 Permission: true Normal: true - Nether: false - End: false DEEP_OCEAN: - DisplayName: 'Deep Ocean' + DisplayName: '&6Deep Ocean' + DisplayItem: + Material: GRAVEL + Data: 0 Permission: true Normal: true - Nether: false - End: false DEEP_WARM_OCEAN: - DisplayName: 'Deep Warm Ocean' + DisplayName: '&6Deep Warm Ocean' + DisplayItem: + Material: TROPICAL_FISH + Data: 0 Permission: true Normal: true - Nether: false - End: false DESERT: - DisplayName: 'Desert' + DisplayName: '&6Desert' + DisplayItem: + Material: CACTUS + Data: 0 Permission: true Normal: true - Nether: false - End: false DESERT_HILLS: - DisplayName: 'Desert Hills' + DisplayName: '&6Desert Hills' + DisplayItem: + Material: RED_SAND + Data: 0 Permission: true Normal: true - Nether: false - End: false DESERT_LAKES: - DisplayName: 'Desert Lakes' + DisplayName: '&6Desert Lakes' + DisplayItem: + Material: SANDSTONE + Data: 0 Permission: true Normal: true - Nether: false - End: false END_BARRENS: - DisplayName: 'End Barrens' + DisplayName: '&6End Barrens' + DisplayItem: + Material: END_STONE + Data: 0 Permission: true Normal: false - Nether: false - End: end END_HIGHLANDS: - DisplayName: 'End HighLands' + DisplayName: '&6End HighLands' + DisplayItem: + Material: END_STONE_BRICKS + Data: 0 Permission: true Normal: false - Nether: false - End: true END_MIDLANDS: - DisplayName: 'End Midlands' + DisplayName: '&6End Midlands' + DisplayItem: + Material: PURPUR_BLOCK + Data: 0 Permission: true Normal: false - Nether: false - End: end ERODED_BADLANDS: - DisplayName: 'Eroded Badlands' + DisplayName: '&6Eroded Badlands' + DisplayItem: + Material: PINK_TERRACOTTA + Data: 0 Permission: true Normal: true - Nether: false - End: false FLOWER_FOREST: - DisplayName: 'Flower Forest' + DisplayName: '&6Flower Forest' + DisplayItem: + Material: SUNFLOWER + Data: 0 Permission: true Normal: true - Nether: false - End: false FOREST: - DisplayName: 'Forest' + DisplayName: '&6Forest' + DisplayItem: + Material: APPLE + Data: 0 Permission: true Normal: true - Nether: false - End: false FROZEN_OCEAN: - DisplayName: 'Frozen Ocean' + DisplayName: '&6Frozen Ocean' + DisplayItem: + Material: ICE + Data: 0 Permission: true Normal: true - Nether: false - End: false FROZEN_RIVER: - DisplayName: 'Frozen River' + DisplayName: '&6Frozen River' + DisplayItem: + Material: COD + Data: 0 Permission: true Normal: true - Nether: false - End: false GIANT_SPRUCE_TAIGA: - DisplayName: 'Giant Spruce Taiga' + DisplayName: '&6Giant Spruce Taiga' + DisplayItem: + Material: SPRUCE_LOG + Data: 0 Permission: true Normal: true - Nether: false - End: false GIANT_SPRUCE_TAIGA_HILLS: - DisplayName: 'Giant Spruce Taiga Hills' + DisplayName: '&6Giant Spruce Taiga Hills' + DisplayItem: + Material: SPRUCE_LEAVES + Data: 0 Permission: true Normal: true - Nether: false - End: false GIANT_TREE_TAIGA: DisplayName: 'Giant Tree Taiga' + DisplayItem: + Material: SPRUCE_SAPLING + Data: 0 Permission: true Normal: true - Nether: false - End: false GIANT_TREE_TAIGA_HILLS: - DisplayName: 'Giant Tree Taiga Hills' + DisplayName: '&6Giant Tree Taiga Hills' + DisplayItem: + Material: SPRUCE_WOOD + Data: 0 Permission: true Normal: true - Nether: false - End: false GRAVELLY_MOUNTAINS: - DisplayName: 'Gravelly Mountains' + DisplayName: '&6Gravelly Mountains' + DisplayItem: + Material: GRAVEL + Data: 0 Permission: true Normal: true - Nether: false - End: false ICE_SPIKES: - DisplayName: 'Ice Spikes' + DisplayName: '&6Ice Spikes' + DisplayItem: + Material: PACKED_ICE + Data: 0 Permission: true Normal: true - Nether: false - End: false JUNGLE: - DisplayName: 'Jungle' + DisplayName: '&6Jungle' + DisplayItem: + Material: VINES + Data: 0 Permission: true Normal: true - Nether: false - End: false JUNGLE_EDGE: - DisplayName: 'Jungle Edge' + DisplayName: '&6Jungle Edge' + DisplayItem: + Material: JUNGLE_TREE_LOG + Data: 0 Permission: true Normal: true - Nether: false - End: false JUNGLE_HILLS: - DisplayName: 'Jungle Hills' + DisplayName: '&6Jungle Hills' + DisplayItem: + Material: JUNGLE_TREE_SAPLING + Data: 0 Permission: true Normal: true - Nether: false - End: false LUKEWARM_OCEAN: - DisplayName: 'Lukewarm Ocean' + DisplayName: '&6Lukewarm Ocean' + DisplayItem: + Material: KELP + Data: 0 Permission: true Normal: true - Nether: false - End: false MODIFIED_BADLANDS_PLATEAU: - DisplayName: 'Modified Badlands Plateau' + DisplayName: '&6Modified Badlands Plateau' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false MODIFIED_GRAVELLY_MOUNTAINS: - DisplayName: 'Modified Gravelly Mountains' + DisplayName: '&6Modified Gravelly Mountains' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false MODIFIED_JUNGLE: - DisplayName: 'Modified Jungle' + DisplayName: '&6Modified Jungle' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false MODIFIED_JUNGLE_EDGE: - DisplayName: 'Modified Jungle Edge' + DisplayName: '&6Modified Jungle Edge' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false MODIFIED_WOODED_BADLANDS_PLATEAU: - DisplayName: 'Modified Wooden Badlands Plateau' + DisplayName: '&6Modified Wooden Badlands Plateau' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false MOUNTAINS: - DisplayName: 'Mountains' + DisplayName: '&6Mountains' + DisplayItem: + Material: STONE + Data: 0 Permission: true Normal: true - Nether: false - End: false MOUNTAIN_EDGE: - DisplayName: 'Mountain Edge' + DisplayName: '&6Mountain Edge' + DisplayItem: + Material: DIORITE + Data: 0 Permission: true Normal: true - Nether: false - End: false MUSHROOM_FIELDS: - DisplayName: 'Mushroom Fields' + DisplayName: '&6Mushroom Fields' + DisplayItem: + Material: RED_MUSHROOM + Data: 0 Permission: true Normal: true - Nether: false - End: false MUSHROOM_FIELD_SHORE: - DisplayName: 'Mushroom Field Shore' + DisplayName: '&6Mushroom Field Shore' + DisplayItem: + Material: BROWN_MUSHROOM + Data: 0 Permission: true Normal: true - Nether: false - End: false # PRE-1.16 NETHER: - DisplayName: 'Nether' + DisplayName: '&6Nether' + DisplayItem: + Material: NETHERRACK + Data: 0 Permission: true Normal: false - Nether: true - End: false NETHER_WASTES: - DisplayName: 'Nether Wastes' + DisplayName: '&6Nether Wastes' + DisplayItem: + Material: NETHER_WART + Data: 0 Permission: true Normal: false - Nether: true - End: false OCEAN: - DisplayName: 'Ocean' + DisplayName: '&6Ocean' + DisplayItem: + Material: SEA_LANTERN + Data: 0 Permission: true Normal: true - Nether: false - End: false PLAINS: - DisplayName: 'Plains' + DisplayName: '&6Plains' + DisplayItem: + Material: GRASS_BLOCK + Data: 0 Permission: true Normal: true - Nether: false - End: false RIVER: - DisplayName: 'River' + DisplayName: '&6River' + DisplayItem: + Material: SUGAR_CANE + Data: 0 Permission: true Normal: true - Nether: false - End: false SAVANNA: - DisplayName: 'Savanna' + DisplayName: '&6Savanna' + DisplayItem: + Material: GRASS + Data: 0 Permission: true Normal: true - Nether: false - End: false SAVANNA_PLATEAU: - DisplayName: 'Savanna Plateau' + DisplayName: '&6Savanna Plateau' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false SHATTERED_SAVANNA: - DisplayName: 'Shattered Savanna' + DisplayName: '&6Shattered Savanna' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false SHATTERED_SAVANNA_PLATEAU: - DisplayName: 'Shattered Savanna Plateau' + DisplayName: '&6Shattered Savanna Plateau' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false SMALL_END_ISLANDS: - DisplayName: 'Small End Island' + DisplayName: '&6Small End Island' + DisplayItem: + Material: PURPUR_PILLAR + Data: 0 Permission: true Normal: false - Nether: false - End: true SNOWY_BEACH: - DisplayName: 'Snowy Beach' + DisplayName: '&6Snowy Beach' + DisplayItem: + Material: RABBIT_FOOT + Data: 0 Permission: true Normal: true - Nether: false - End: false SNOWY_MOUNTAINS: - DisplayName: 'Snowy Mountains' + DisplayName: '&6Snowy Mountains' + DisplayItem: + Material: SNOW_BLOCK + Data: 0 Permission: true Normal: true - Nether: false - End: false SNOWY_TAIGA: - DisplayName: 'Snowy Taiga' + DisplayName: '&6Snowy Taiga' + DisplayItem: + Material: SPRUCE_SAPLING + Data: 0 Permission: true Normal: true - Nether: false - End: false SNOWY_TAIGA_HILLS: - DisplayName: 'Snowy Taiga Hills' + DisplayName: '&6Snowy Taiga Hills' + DisplayItem: + Material: SNOWBALL + Data: 0 Permission: true Normal: true - Nether: false - End: false SNOWY_TAIGA_MOUNTAINS: - DisplayName: 'Snowy Taiga Mountains' + DisplayName: '&6Snowy Taiga Mountains' + DisplayItem: + Material: SWEET_BERRIES + Data: 0 Permission: true Normal: true - Nether: false - End: false SNOWY_TUNDRA: - DisplayName: 'Snowy Tundra' + DisplayName: '&6Snowy Tundra' + DisplayItem: + Material: SNOW + Data: 0 Permission: true Normal: true - Nether: false - End: false SOUL_SAND_VALLEY: - DisplayName: 'Soul Sand Valley' + DisplayName: '&6Soul Sand Valley' + DisplayItem: + Material: SOULSAND + Data: 0 Permission: true Normal: false - Nether: true - End: false STONE_SHORE: - DisplayName: 'Stone Shore' + DisplayName: '&6Stone Shore' + DisplayItem: + Material: CLAY + Data: 0 Permission: true Normal: true - Nether: false - End: false SUNFLOWER_PLAINS: - DisplayName: 'Sunflower Plains' + DisplayName: '&6Sunflower Plains' + DisplayItem: + Material: SUNFLOWER + Data: 0 Permission: true Normal: true - Nether: false - End: false SWAMP: - DisplayName: 'Swamp' + DisplayName: '&6Swamp' + DisplayItem: + Material: LILYPAD + Data: 0 Permission: true Normal: true - Nether: false - End: false SWAMP_HILLS: - DisplayName: 'Swamp Hills' + DisplayName: '&6Swamp Hills' + DisplayItem: + Material: SLIME_BLOCK + Data: 0 Permission: true Normal: true - Nether: false - End: false TAIGA: - DisplayName: 'Taiga' + DisplayName: '&6Taiga' + DisplayItem: + Material: SPRUCE_WOOD + Data: 0 Permission: true Normal: true - Nether: false - End: false TAIGA_HILLS: - DisplayName: 'Taiga Hills' + DisplayName: '&6Taiga Hills' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false TAIGA_MOUNTAINS: - DisplayName: 'Taiga Mountains' + DisplayName: '&6Taiga Mountains' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false TALL_BIRCH_FOREST: - DisplayName: 'Tall Birch Forest' + DisplayName: '&6Tall Birch Forest' + DisplayItem: + Material: BIRCH_LOG + Data: 0 Permission: true Normal: true - Nether: false - End: false TALL_BIRCH_HILLS: - DisplayName: 'Tall Birch Hills' + DisplayName: '&6Tall Birch Hills' + DisplayItem: + Material: BIRCH_PLANKS + Data: 0 Permission: true Normal: true - Nether: false - End: false THE_END: - DisplayName: 'The End' + DisplayName: '&6The End' + DisplayItem: + Material: CHORUS_FRUIT + Data: 0 Permission: true Normal: false - Nether: false - End: true THE_VOID: - DisplayName: 'The Void' + DisplayName: '&6The Void' + DisplayItem: + Material: BEDROCK + Data: 0 Permission: true Normal: false - Nether: false - End: false WARM_OCEAN: - DisplayName: 'Warm Ocean' + DisplayName: '&6Warm Ocean' + DisplayItem: + Material: BRAIN_CORAL + Data: 0 Permission: true Normal: true - Nether: false - End: false WARPED_FOREST: - DisplayName: 'Warped Forest' + DisplayName: '&6Warped Forest' + DisplayItem: + Material: WARPED_STEM + Data: 0 Permission: true Normal: false - Nether: true - End: false WOODED_BADLANDS_PLATEAU: - DisplayName: 'Wooded Badlands Plateau' + DisplayName: '&6Wooded Badlands Plateau' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false WOODED_HILLS: - DisplayName: 'Wooded Hills' + DisplayName: '&6Wooded Hills' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false + Normal: false WOODED_MOUNTAINS: - DisplayName: 'Wooded Mountains' + DisplayName: '&6Wooded Mountains' + DisplayItem: + Material: STONE + Data: 0 Permission: true - Normal: true - Nether: false - End: false \ No newline at end of file + Normal: false \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e192acda..cb9a5d86 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -182,10 +182,6 @@ Island: Type: Plains Cooldown: Time: 900 - # If the Nether/End biomes should be allowed in the overworld - AllowOtherWorldlyBiomes: - Nether: true - End: true Weather: Default: # The weather and time will operate the same weather and time as the world. @@ -355,6 +351,7 @@ Island: BlazeImmuneToWaterInNether: false Restrict: # Blocks that can be placed only if the island has nether unlocked + # You may add/remove as many as you want NetherBlocks: NETHERRACK: true SOUL_SAND: true @@ -377,7 +374,63 @@ Island: NETHER_WART_BLOCK: true WITHER_SKELETON_SKULL: true WITHER_ROSE: true + CRIMSON_NYLIUM: true + WARPED_NYLIUM: true + CRIMSON_PLANKS: true + WARPED_PLANKS: true + NETHER_GOLD_ORE: true + CRIMSTON_STEM: true + WARPED_STEM: true + STRIPPED_CRIMSON_STEM: true + STRIPPED_WARPED_STEM: true + STRIPPED_CRIMSON_HYPHAE: true + STRIPPED_WARPED_HYPHAE: true + CRIMSON_HYPHAE: true + WARPED_HYPHAE: true + CRIMSON_FUNGUS: true + WARPED_FUNGUS: true + CRIMSON_ROOTS: true + WARPED_ROOTS: true + NETHER_SPROUTS: true + WEEPING_VINES: true + TWISTING_VINES: true + SOUL_OIL: true + BASALT: true + POLISHED_BASALT: true + SOUL_TORCH: true + CRIMSON_TRAPDOOR: true + WARPED_TRAPDOOR: true + CHAIN: true + CRIMSON_FENCE_GATE: true + WARPED_FENCE_GATE: true + CRACKED_NETHER_BRICKS: true + BLACKSTONE_WALL: true + POLISHED_BLACKSTONE_WALL: true + POLISHED_BLACKSTONE_BRICK_WALL: true + CRIMSON_BUTTON: true + WARPED_BUTTON: true + POLISHED_BLACKSTONE_BUTTON: true + SOUL_CAMPFIRE: true + SHROOMLIGHT: true + LODESTONE: true + NETHERITE_BLOCK: true + ANCIENT_DEBRIS: true + CRYING_OBSIDIAN: true + BLACKSTONE: true + BLACKSTONE_SLAB: true + BLACKSTONE_STAIRS: true + GLIDED_BLACKSTONE: true + POLISHED_BLACKSTONE: true + POLISHED_BLACKSTONE_SLAB: true + POLISHED_BLACKSTONE_STAIRS: true + CHISELED_POLISHED_BLACKSTONE: true + POLISHED_BLACKSTONE_BRICKS: true + POLISHED_BLACKSTONE_BRICK_SLAB: true + POLISHED_BLACKSTONE_BRICK_STAIRS: true + CRACKED_POLISHED_BLACKSTONE_BRICKS: true + RESPAWN_ANCHOR: true # Blocks that can be placed only if the island has The End unlocked + # You may add/remove as many as you want EndBlocks: END_STONE: true END_STONE_BRICKS: true diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 92928327..ae0437b4 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -2574,8 +2574,6 @@ Menu: Item: Exit: Displayname: '&cExit Biome Selection' - Barrier: - Displayname: '&cSelect a Biome' Info: Displayname: '&bCurrent Biome' Lore: @@ -2589,6 +2587,10 @@ Menu: Lore: - '&7Click to Set!' Displayname: '&aBiome: &e%biome_type' + Next: + Displayname: '&aNext Page >' + Previous: + Displayname: '&a< Previous Page' Title: '&8Select a Biome' Information: Categories: diff --git a/src/main/resources/stackables.yml b/src/main/resources/stackables.yml index 77198f3a..a65bb44a 100644 --- a/src/main/resources/stackables.yml +++ b/src/main/resources/stackables.yml @@ -3,3 +3,4 @@ Stackables: - IRON_BLOCK - GOLD_BLOCK - EMERALD_BLOCK + - NETHERITE_BLOCK From 85a75e03b2462617e4bacd616fe6340c93a93a9d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 22:55:37 +0200 Subject: [PATCH 105/366] Added more Nether blocks --- src/main/resources/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index cb9a5d86..991e048c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -401,6 +401,8 @@ Island: CRIMSON_TRAPDOOR: true WARPED_TRAPDOOR: true CHAIN: true + CRIMSON_DOOR: true + WARPED_DOOR: true CRIMSON_FENCE_GATE: true WARPED_FENCE_GATE: true CRACKED_NETHER_BRICKS: true @@ -410,6 +412,7 @@ Island: CRIMSON_BUTTON: true WARPED_BUTTON: true POLISHED_BLACKSTONE_BUTTON: true + SOUL_LANTERN: true SOUL_CAMPFIRE: true SHROOMLIGHT: true LODESTONE: true From da1ad104659a7abf4bdc62aef3dd1ea11d0e0031 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 22:55:48 +0200 Subject: [PATCH 106/366] Use SongodaCore 2.3.38 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5a479c5f..bb7b7c1f 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ com.songoda SongodaCore - LATEST + 2.3.38 compile From 501812e45b392b7cb594c550e955ee0aa55f5014 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 25 Jun 2020 23:09:07 +0200 Subject: [PATCH 107/366] Fix lore loading bug --- .../songoda/skyblock/gui/wip/GuiBiome.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java index cb97c202..cc986c21 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java @@ -3,20 +3,15 @@ package com.songoda.skyblock.gui.wip; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.gui.AnvilGui; import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiUtils; -import com.songoda.core.hooks.EconomyManager; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.bank.BankManager; -import com.songoda.skyblock.bank.Transaction; import com.songoda.skyblock.biome.BiomeManager; 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.gui.bank.GuiBankSelector; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandManager; @@ -27,15 +22,9 @@ import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.io.File; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; +import java.util.*; public class GuiBiome extends Gui { private final SkyBlock plugin; @@ -87,10 +76,13 @@ public class GuiBiome extends Gui { event.player.closeInventory(); }); + List lore = languageLoad.getStringList("Menu.Biome.Item.Info.Lore"); + for (ListIterator i = lore.listIterator(); i.hasNext(); ) { + i.set(TextUtils.formatText(i.next().replace("%biome_type", island.getBiomeName()))); + } + setItem(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, // Info - TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Info.Displayname")), - TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Info.Lore") - .replace("%biome_type", island.getBiomeName())))); + TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Info.Displayname")), lore)); for(int i=9; i<18; i++){ setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); From 10368f909bec4c6be0dc0b3cc97c62fb882310c0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 19:51:08 +0200 Subject: [PATCH 108/366] Auto disable on unsupported versions --- src/main/java/com/songoda/skyblock/SkyBlock.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 088914c8..cd4bf877 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -3,6 +3,7 @@ package com.songoda.skyblock; import com.songoda.core.SongodaCore; import com.songoda.core.SongodaPlugin; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.configuration.Config; import com.songoda.core.gui.GuiManager; import com.songoda.core.hooks.EconomyManager; @@ -110,14 +111,19 @@ public class SkyBlock extends SongodaPlugin { @Override public void onPluginEnable() { - - paper = false; + if(ServerVersion.isServerVersionAbove(ServerVersion.V1_16)) { + this.getLogger().warning("This Minecraft version is not supported. Disabling..."); + getServer().getPluginManager().disablePlugin(this); + return; + } + try { Class.forName("com.destroystokyo.paper.PaperConfig"); paper = true; paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); this.getLogger().info("Enabling Paper hooks"); } catch (ClassNotFoundException ignored) { + paper = false; PaperLib.suggestPaper(this); } From 898dd64d7a8c3d000841f8451f7aea12b89f45ad Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 19:51:19 +0200 Subject: [PATCH 109/366] Wait for CMIEInjector --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0f607091..cec453a8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,7 +6,7 @@ description: A unique SkyBlock plugin author: Songoda authors: [Fabrimat] softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, - EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence, CoreProtect] + EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector] loadbefore: [Multiverse-Core, ProtocolLib] commands: island: From 6730c53fa116330e0aaf507c4379e5af34d647f5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 19:51:41 +0200 Subject: [PATCH 110/366] Added ECO and BANK to challenges --- .../challenge/challenge/Challenge.java | 132 +++++++++++++----- .../challenge/player/PlayerManager.java | 6 +- src/main/resources/challenges.yml | 12 +- 3 files changed, 114 insertions(+), 36 deletions(-) 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 6a3c26b7..8eefc22b 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -1,12 +1,9 @@ package com.songoda.skyblock.challenge.challenge; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.regex.Pattern; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.island.Island; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -19,17 +16,20 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; -import com.songoda.skyblock.api.SkyBlockAPI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.regex.Pattern; public class Challenge { - private ChallengeCategory category; - private int id; - private String name; - private int maxTimes; - private boolean showInChat; + private final ChallengeCategory category; + private final int id; + private final String name; + private final int maxTimes; + private final boolean showInChat; private List> requires; private List> rewards; - private ItemChallenge item; + private final ItemChallenge item; public Challenge(ChallengeCategory category, int id, String name, int maxTimes, boolean showInChat, List requires, List rewards, ItemChallenge item) { @@ -55,7 +55,7 @@ public class Challenge { String arg1 = str.substring(idx + 1); try { Type t = Type.valueOf(arg0); - this.requires.add(new Peer(t, t.convert(arg1))); + this.requires.add(new Peer<>(t, t.convert(arg1))); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Invalid line : " + str + " : " + ex.getMessage()); } catch (Exception ex) { @@ -71,7 +71,7 @@ public class Challenge { String arg1 = str.substring(idx + 1); try { Type t = Type.valueOf(arg0); - this.rewards.add(new Peer(t, t.convert(arg1))); + this.rewards.add(new Peer<>(t, t.convert(arg1))); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Invalid line : " + str + ": " + ex.getMessage()); } catch (Exception ex) { @@ -114,7 +114,7 @@ public class Challenge { return item; } - public static enum Type { + public enum Type { ITEM { // An item @@ -122,7 +122,7 @@ public class Challenge { * Convert the value to a useable ItemStack */ @Override - public Object convert(String value) throws IllegalArgumentException { + public ItemStack convert(String value) throws IllegalArgumentException { if (value == null || "".equalsIgnoreCase(value.trim())) throw new IllegalArgumentException("Value is empty or null"); int index = value.indexOf(' '); @@ -195,7 +195,7 @@ public class Challenge { // A command to execute @Override - public Object convert(String value) throws IllegalArgumentException { + public String convert(String value) throws IllegalArgumentException { // Here we don't have to convert the value because the value is the command if (value == null || "".equalsIgnoreCase(value)) throw new IllegalArgumentException("Value is empty or null"); @@ -224,7 +224,7 @@ public class Challenge { // The level of island of a player @Override - public Object convert(String value) throws IllegalArgumentException { + public Integer convert(String value) throws IllegalArgumentException { // Convert the value to an Integer representing the minimum level of island // required if (value == null || "".equalsIgnoreCase(value)) @@ -262,7 +262,7 @@ public class Challenge { NEAR { @Override - public Object convert(String value) throws IllegalArgumentException { + public Peer convert(String value) throws IllegalArgumentException { // We returns the entity type and the number of entity required if (value == null || "".equalsIgnoreCase(value)) throw new IllegalArgumentException("Value is empty or null"); @@ -320,7 +320,7 @@ public class Challenge { private Pattern space = Pattern.compile(" "); @Override - public Object convert(String value) throws IllegalArgumentException { + public Peer> convert(String value) throws IllegalArgumentException { // We returns the potion required if (value == null || "".equalsIgnoreCase(value)) throw new IllegalArgumentException("Value is empty or null"); @@ -336,9 +336,6 @@ public class Challenge { throw new IllegalArgumentException( "\"" + split[0] + "\" isn't a correct Minecraft PotionType (value = \"" + value + "\")"); } - if (pt == null) - throw new IllegalArgumentException( - "\"" + split[0] + "\" isn't a correct Minecraft PotionType (value = \"" + value + "\")"); // The data int data; try { @@ -356,7 +353,7 @@ public class Challenge { throw new IllegalArgumentException( "\"" + split[2] + "\" isn't a correct number (value = \"" + value + "\")"); } - return new Peer>(pt, new Peer<>(data, amount)); + return new Peer<>(pt, new Peer<>(data, amount)); } @Override @@ -441,11 +438,6 @@ public class Challenge { *
  • 7 = lingering extended
  • *
  • 8 = lingering ++
  • * - * - * @param is - * @param type - * @param data - * @return */ private boolean isSame(ItemStack is, PotionType type, int data) { if (data <= 2 && is.getType() != Material.POTION) @@ -462,9 +454,85 @@ public class Challenge { return false; else if ((data == 1 || data == 4 || data == 7) && !pd.isExtended()) return false; - else if ((data == 2 || data == 5 || data == 8) && !pd.isUpgraded()) - return false; - return true; + else return (data != 2 && data != 5 && data != 8) || pd.isUpgraded(); + } + }, + ECO { + @Override + public Double convert(String value) throws IllegalArgumentException { + if (value == null || "".equalsIgnoreCase(value)) + throw new IllegalArgumentException("Value is empty or null"); + try { + return Double.parseDouble(value); + } catch (NumberFormatException ex) { + throw new IllegalArgumentException( + "\"" + value + "\" isn't a correct number (value = \"" + value + "\")"); + } + } + + @Override + public boolean has(Player p, Object obj) { + if (obj instanceof Number) { + return EconomyManager.getBalance(p) >= ((Number) obj).doubleValue(); + } + return false; + } + + @Override + public void executeRequire(Player p, Object obj) { + if (obj instanceof Number && ((Number) obj).doubleValue() > 0) { + EconomyManager.withdrawBalance(p, ((Number) obj).doubleValue()); + } + } + + @Override + public void executeReward(Player p, Object obj) { + if (obj instanceof Number && ((Number) obj).doubleValue() > 0) { + EconomyManager.deposit(p, ((Number) obj).doubleValue()); + } + } + }, + BANK { + @Override + public Double convert(String value) throws IllegalArgumentException { + if (value == null || "".equalsIgnoreCase(value)) + throw new IllegalArgumentException("Value is empty or null"); + try { + return Double.parseDouble(value); + } catch (NumberFormatException ex) { + throw new IllegalArgumentException( + "\"" + value + "\" isn't a correct number (value = \"" + value + "\")"); + } + } + + @Override + public boolean has(Player p, Object obj) { + Island is = SkyBlock.getInstance().getIslandManager().getIsland(p); + + if (is != null && obj instanceof Number && ((Number) obj).doubleValue() > 0) { + return is.getBankBalance() >= ((Number) obj).doubleValue(); + } + return false; + } + + @Override + public void executeRequire(Player p, Object obj) { + Island is = SkyBlock.getInstance().getIslandManager().getIsland(p); + BankManager bankManager = SkyBlock.getInstance().getBankManager(); + + if (is != null && obj instanceof Number && ((Number) obj).doubleValue() > 0) { + bankManager.withdraw(p, is, ((Number) obj).doubleValue(), false); + } + } + + @Override + public void executeReward(Player p, Object obj) { + Island is = SkyBlock.getInstance().getIslandManager().getIsland(p); + BankManager bankManager = SkyBlock.getInstance().getBankManager(); + + if (is != null && obj instanceof Number) { + bankManager.deposit(p, is, ((Number) obj).doubleValue(), false); + } } }; 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 47a822e5..4cd66833 100644 --- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java +++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java @@ -173,10 +173,12 @@ public class PlayerManager { done.put(c, count + 1); addChallenge(uuid, c); // Take items - for (Peer peer : c.getRequires()) + for (Peer peer : c.getRequires()) { peer.getKey().executeRequire(p, peer.getValue()); - for (Peer peer : c.getRewards()) + } + for (Peer peer : c.getRewards()) { peer.getKey().executeReward(p, peer.getValue()); + } // Ok, send message String broadcast = ChatColor.translateAlternateColorCodes('&', SkyBlock.getInstance().getFileManager() diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index f7b0e6c0..e8ebd97e 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -324,12 +324,15 @@ challenges: # LEVEL: ==> the player's island needs to be at least level # NEAR: ==> of must be next to the player # POTION: + # BANK: + # ECO: # data must be: 0 = normal potion, 1 = extended, 2 = ++, 3 = splash, 4 = splash extended, 5 = splash ++, 6 = lingering, 7 = lingering extended, 8 = lingering ++ require: - 'ITEM:cobblestone 128' # The reward # ITEM: means the player will have when the challenge is done # CMD: means a command will be executed by the console when the challenge is done + # BANK: reward: - 'CMD:eco give {player} 100' - 'ITEM:iron_ingot 20' @@ -565,7 +568,8 @@ challenges: - 'ITEM:cake 5' - 'ITEM:pumpkin_pie 16' reward: - - 'CMD:eco give {player} 300' + - 'CMD:eco give {player} 150' + - 'BANK:150' - 'ITEM:diamond 10' - 'ITEM:cow_spawn_egg 1' maxtimes: 1 @@ -583,7 +587,8 @@ challenges: - '&c&lRewards:' - '&e- 10 diamonds' - '&e- 1 cow spawn egg' - - '&e- 300 $' + - '&e- 150 $' + - '&e- 150 $ to the bank island' '2': id: 2 name: '&2Hunter' @@ -1077,6 +1082,7 @@ challenges: name: '&2The Neighbours' require: - 'NEAR:villager 10' + - 'BANK:100' reward: - 'CMD:eco give {player} 1000' - 'ITEM:diamond_block 16' @@ -1091,6 +1097,7 @@ challenges: lore: - '&c&lFor this challenge, you''ll need:' - '&e- Have 10 villagers in your proximity' + - '&e- 100 $ in the island bank' - '&c&lRewards:' - '&e- 16 diamond blocks' - '&e- 1000 $' @@ -1820,6 +1827,7 @@ challenges: id: 8 name: '&4THE IMPOSSIBLE CHALLENGE' require: + - 'ECO:10000' - 'ITEM:bedrock 64' reward: - 'CMD:eco give {player} 0' From 9c2a7161e632604ac6a1122a32607c94bc01fbee Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 19:56:16 +0200 Subject: [PATCH 111/366] Added explanations to the new challenges types --- src/main/resources/challenges.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index e8ebd97e..8678e94e 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -324,15 +324,15 @@ challenges: # LEVEL: ==> the player's island needs to be at least level # NEAR: ==> of must be next to the player # POTION: - # BANK: - # ECO: + # BANK: requires amount from the island's bank + # ECO: requires amount from the player's balance # data must be: 0 = normal potion, 1 = extended, 2 = ++, 3 = splash, 4 = splash extended, 5 = splash ++, 6 = lingering, 7 = lingering extended, 8 = lingering ++ require: - 'ITEM:cobblestone 128' # The reward # ITEM: means the player will have when the challenge is done # CMD: means a command will be executed by the console when the challenge is done - # BANK: + # BANK: gives amount to the island's bank reward: - 'CMD:eco give {player} 100' - 'ITEM:iron_ingot 20' From d3ee17d0378ed2562c63572f3959f1eb8806afb5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 21:14:28 +0200 Subject: [PATCH 112/366] Fixed comment in challenges --- src/main/resources/challenges.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index 8678e94e..4a8f052d 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -324,9 +324,9 @@ challenges: # LEVEL: ==> the player's island needs to be at least level # NEAR: ==> of must be next to the player # POTION: + # data must be: 0 = normal potion, 1 = extended, 2 = ++, 3 = splash, 4 = splash extended, 5 = splash ++, 6 = lingering, 7 = lingering extended, 8 = lingering ++ # BANK: requires amount from the island's bank # ECO: requires amount from the player's balance - # data must be: 0 = normal potion, 1 = extended, 2 = ++, 3 = splash, 4 = splash extended, 5 = splash ++, 6 = lingering, 7 = lingering extended, 8 = lingering ++ require: - 'ITEM:cobblestone 128' # The reward From a41b7d27b412b92de1d0afa2c4cbd3dc8dc314f6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 21:14:40 +0200 Subject: [PATCH 113/366] Update ItemStackUtil --- .../com/songoda/skyblock/utils/item/ItemStackUtil.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java index 87eee00b..c608c4da 100644 --- a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java @@ -2,8 +2,10 @@ package com.songoda.skyblock.utils.item; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Material; +import org.bukkit.Server; import org.bukkit.inventory.ItemStack; import java.io.*; @@ -24,10 +26,11 @@ public final class ItemStackUtil { Object NBTTagCompound = NMSUtil.getNMSClass("NBTCompressedStreamTools") .getMethod("a", DataInputStream.class).invoke(null, dataInputStream); Object craftItemStack; - - if (NMSUtil.getVersionNumber() > 12) { + + assert NMSItemStackClass != null; + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { craftItemStack = NMSItemStackClass.getMethod("a", NBTTagCompoundClass).invoke(null, NBTTagCompound); - } else if (NMSUtil.getVersionNumber() > 10) { + } else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { craftItemStack = NMSItemStackClass.getConstructor(NBTTagCompoundClass).newInstance(NBTTagCompound); } else { craftItemStack = NMSItemStackClass.getMethod("createStack", NBTTagCompoundClass).invoke(null, From b1be709c3c203461dcaf17922302b40d525d542b Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 21:22:56 +0200 Subject: [PATCH 114/366] Add option to ignore Item lore in challenges --- .../challenge/challenge/Challenge.java | 53 +++++++++++++------ src/main/resources/config.yml | 6 ++- 2 files changed, 41 insertions(+), 18 deletions(-) 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 8eefc22b..8da500e4 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -5,6 +5,7 @@ import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.utils.item.ItemStackUtil; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -16,6 +17,7 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -149,35 +151,55 @@ public class Challenge { @Override public boolean has(Player p, Object obj) { - // Check if player has specific item in his inventory - ItemStack is = (ItemStack) obj; - return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount()); + boolean ignoreLore = SkyBlock.getInstance().getFileManager() + .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false); + if(obj instanceof ItemStack){ + // Check if player has specific item in his inventory + ItemStack is = (ItemStack) obj; + if(ignoreLore){ + return p.getInventory().contains(is.getType(), is.getAmount()); + } + return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount()); + } + return false; } @Override public void executeRequire(Player p, Object obj) { + boolean ignoreLore = SkyBlock.getInstance().getFileManager() + .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false); + 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().getContents()) { - if(jis != null && jis.isSimilar(is)) { - if(jis.getAmount() <= toRemove) { - toRemove -= jis.getAmount(); - jis.setAmount(0); + if(jis != null) { + boolean isItem; + if(ignoreLore){ + isItem = jis.getType().equals(is.getType()); } else { - jis.setAmount(jis.getAmount() - toRemove); - toRemove = 0; + isItem = jis.isSimilar(is); + } + + if(isItem) { + if(jis.getAmount() <= toRemove) { + toRemove -= jis.getAmount(); + jis.setAmount(0); + } else { + jis.setAmount(jis.getAmount() - toRemove); + toRemove = 0; + } + } + if(toRemove <= 0) { + p.updateInventory(); + break; } - } - if(toRemove <= 0) { - p.updateInventory(); - break; } } } - // TODO LOG } @Override @@ -188,7 +210,6 @@ public class Challenge { .addItem(new ItemStack(is.getType(), is.getAmount())); for (ItemStack restIs : rest.values()) p.getWorld().dropItem(p.getLocation(), restIs); - // TODO LOG } }, CMD { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 991e048c..adc86264 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -331,8 +331,10 @@ 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 + # Whether challenges should be per-island or per-player + PerIsland: false + # Whether to ignore item lore in requirements + IgnoreItemLore: false Teleport: # Enable or disable Fall damage FallDamage: true From 8602836406161dc75821dae9449335440c4fe034 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 27 Jun 2020 04:53:59 +0200 Subject: [PATCH 115/366] Disabled /is biome in 1.16 and trying to resolve with a thread pool --- .../java/com/songoda/skyblock/SkyBlock.java | 12 +- .../skyblock/api/biome/BiomeManager.java | 2 +- .../songoda/skyblock/biome/BiomeManager.java | 141 ++++++++++++++---- .../skyblock/blockscanner/ChunkLoader.java | 27 +++- .../commands/admin/SetBiomeCommand.java | 11 +- .../command/commands/island/BiomeCommand.java | 17 ++- .../songoda/skyblock/gui/wip/GuiBiome.java | 5 +- .../skyblock/island/IslandManager.java | 19 +-- .../skyblock/levelling/IslandScan.java | 2 +- .../com/songoda/skyblock/menus/Biome.java | 2 +- .../world/generator/VoidGenerator.java | 50 ++++++- src/main/resources/language.yml | 4 + 12 files changed, 221 insertions(+), 71 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index cd4bf877..68f4f84b 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -3,6 +3,7 @@ package com.songoda.skyblock; import com.songoda.core.SongodaCore; import com.songoda.core.SongodaPlugin; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerProject; import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.configuration.Config; import com.songoda.core.gui.GuiManager; @@ -117,13 +118,10 @@ public class SkyBlock extends SongodaPlugin { return; } - try { - Class.forName("com.destroystokyo.paper.PaperConfig"); - paper = true; + if(paper = ServerProject.isServer(ServerProject.PAPER)){ paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); this.getLogger().info("Enabling Paper hooks"); - } catch (ClassNotFoundException ignored) { - paper = false; + } else { PaperLib.suggestPaper(this); } @@ -229,6 +227,10 @@ public class SkyBlock extends SongodaPlugin { @Override public void onPluginDisable() { + if (this.biomeManager != null) { + this.biomeManager.onDisable(); + } + if (this.userCacheManager != null) { this.userCacheManager.onDisable(); } diff --git a/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java index b97192fc..c73ad556 100644 --- a/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java @@ -19,6 +19,6 @@ public class BiomeManager { Preconditions.checkArgument(island != null, "Cannot set biome to null island"); Preconditions.checkArgument(biome != null, "Cannot set biome to null biome"); - this.biomeManager.setBiome(island.getIsland(), biome); + this.biomeManager.setBiome(island.getIsland(), biome, null); } } diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index d43f3eb9..58388f41 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -2,78 +2,143 @@ package com.songoda.skyblock.biome; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; -import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.utils.version.NMSUtil; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; import org.bukkit.block.Biome; import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; public class BiomeManager { private final SkyBlock skyblock; + private final List updatingIslands; + private final List pools; public BiomeManager(SkyBlock skyblock) { this.skyblock = skyblock; + this.updatingIslands = new ArrayList<>(); + this.pools = new ArrayList<>(); + } + + public boolean isUpdating(Island island) { + return updatingIslands.contains(island); + } + + public void addUpdatingIsland(Island island) { + updatingIslands.add(island); + } + + public void removeUpdatingIsland(Island island) { + updatingIslands.remove(island); } - public void setBiome(Island island, Biome biome) { + public void setBiome(Island island, Biome biome, CompleteTask task) { + addUpdatingIsland(island); if (island.getLocation(IslandWorld.Normal, IslandEnvironment.Island) == null) return; if(skyblock.isPaperAsync()){ // We keep it sequentially in order to use less RAM + ExecutorService threadPool = Executors.newFixedThreadPool(4); + pools.add(threadPool); ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { Chunk chunk = asyncChunk.join(); - setChunkBiome(biome, chunk); - updateBiomePacket(island, chunk); - }); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there + setChunkBiome3D(island, biome, chunk, threadPool); + } else { + setChunkBiome2D(island, biome, chunk); + } + }, (island1 -> { + removeUpdatingIsland(island1); + if(task != null) { + task.onCompleteUpdate(); + } + threadPool.shutdown(); + pools.remove(threadPool); + })); } else { - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - syncChunks.forEach(chunk -> { - setChunkBiome(biome, chunk); - updateBiomePacket(island, chunk); - }); - }); - }); + ExecutorService threadPool = Executors.newFixedThreadPool(4); + pools.add(threadPool); + ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there + setChunkBiome3D(island, biome, syncChunk, threadPool); + } else { + setChunkBiome2D(island, biome, syncChunk); + } + }, (island1 -> { + removeUpdatingIsland(island1); + if(task != null) { + task.onCompleteUpdate(); + } + threadPool.shutdown(); + pools.remove(threadPool); + })); } } - private void setChunkBiome(Biome biome, Chunk chunk) { + private void setChunkBiome2D(Island island, Biome biome, Chunk chunk) { for(int xx = 0; xx < 16; xx++){ for(int zz = 0; zz < 16; zz++){ - //if(ServerVersion.isServerVersionBelow(ServerVersion.V1_15)){ - chunk.getBlock(xx, 0, zz).setBiome(biome); - //} else { - // for(int i = 0; i<256; i+=2){ - // chunk.getBlock(xx, i, zz).setBiome(biome); - // } - //} + if(!chunk.getWorld().getBiome(xx, zz).equals(biome)){ + chunk.getWorld().setBiome(xx, zz, biome); + } } } + updateBiomePacket(island, chunk); + } + + private void setChunkBiome3D(Island island, Biome biome, Chunk chunk, ExecutorService pool) { + for(int i = 0; i<256; i+=16){ + int finalI = i; + pool.execute(() -> { + for(int x = 0; x < 16; x++){ + for(int z = 0; z < 16; z++){ + for(int y = 0; y<16; y++){ + chunk.getWorld().setBiome(x, y * finalI, z, biome); + if(!chunk.getWorld().getBiome(x, y * finalI, z).equals(biome)){ + } + } + } + } + }); + } + updateBiomePacket(island, chunk); } - private Class packetPlayOutMapChunkClass; - private Class chunkClass; + private void updateBiomePacket(Island island, Chunk chunk) { - if (packetPlayOutMapChunkClass == null) { - packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk"); - chunkClass = NMSUtil.getNMSClass("Chunk"); - } - + Class packetPlayOutMapChunkClass; + Class chunkClass; + + packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk"); + chunkClass = NMSUtil.getNMSClass("Chunk"); + for (Player player : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) { try { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { - NMSUtil.sendPacket(player, - packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(player - .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk), - 65535)); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { + NMSUtil.sendPacket(player, + packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class, boolean.class).newInstance(player + .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk), + 65535, true)); + } else { + NMSUtil.sendPacket(player, + packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(player + .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk), + 65535)); + } } else { NMSUtil.sendPacket(player, packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class) @@ -86,4 +151,14 @@ public class BiomeManager { } } } + + public void onDisable() { + for(ExecutorService pool : pools){ + pool.shutdownNow(); + } + } + + public interface CompleteTask { + void onCompleteUpdate(); + } } diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java index 4c8dcb24..ebe7d7fb 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -24,21 +24,25 @@ public class ChunkLoader extends BukkitRunnable { private boolean chunkForChunk; private boolean paper; private World world; + private Island island; private int x; private int z; private int minZ; private int maxX; private int maxZ; private int chunkPerTick; + private CompleteTask completeTask; - private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkForChunkScannerTask chunkTask) { + private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkForChunkScannerTask chunkTask, CompleteTask complete) { chunkPerTick = SkyBlock.getInstance().getFileManager() .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25); + this.completeTask = complete; this.chunkTask = chunkTask; this.chunkForChunk = chunkForChunk; this.paper = paper; + this.island = island; Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island); if (islandLocation == null) return; @@ -64,14 +68,16 @@ public class ChunkLoader extends BukkitRunnable { } } - private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkScannerTask generalTask) { + private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkScannerTask generalTask, CompleteTask complete) { chunkPerTick = SkyBlock.getInstance().getFileManager() .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25); - + + this.completeTask = complete; this.generalTask = generalTask; this.chunkForChunk = chunkForChunk; this.paper = paper; + this.island = island; Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island); if (islandLocation == null) return; @@ -129,18 +135,21 @@ public class ChunkLoader extends BukkitRunnable { if(generalTask != null) { generalTask.onComplete(asyncPositions, syncPositions); } + if(completeTask != null) { + completeTask.onComplete(island); + } this.cancel(); return; } } } - public static void startChunkLoading(Island island, IslandWorld islandWorld, boolean paper, ChunkScannerTask task){ - new ChunkLoader(island, islandWorld, paper, false, task); + public static void startChunkLoading(Island island, IslandWorld islandWorld, boolean paper, ChunkScannerTask task, CompleteTask complete){ + new ChunkLoader(island, islandWorld, paper, false, task, complete); } - public static void startChunkLoadingPerChunk(Island island, IslandWorld islandWorld, boolean paper, ChunkForChunkScannerTask task){ - new ChunkLoader(island, islandWorld, paper, true, task); + public static void startChunkLoadingPerChunk(Island island, IslandWorld islandWorld, boolean paper, ChunkForChunkScannerTask task, CompleteTask complete){ + new ChunkLoader(island, islandWorld, paper, true, task, complete); } public interface ChunkScannerTask { @@ -154,4 +163,8 @@ public class ChunkLoader extends BukkitRunnable { void onChunkComplete(CompletableFuture asyncChunk, Chunk syncChunk); } + + public interface CompleteTask { + void onComplete(Island island); + } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java index 3ac41cc8..41e4c508 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.command.commands.admin; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.biome.BiomeManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; @@ -43,7 +44,11 @@ public class SetBiomeCommand extends SubCommand { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - + + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ + messageManager.sendMessage(sender, "&bSkyBlock &8| &6Warning&8: &eThis feature is not supported on this Minecraft version yet. Use at your own risk."); + } + if (args.length == 2) { String biomeName = args[1].toUpperCase().trim(); @@ -76,7 +81,7 @@ public class SetBiomeCommand extends SubCommand { } else { if (islandManager.containsIsland(islandOwnerUUID)) { Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); - biomeManager.setBiome(island, biome.getBiome()); + biomeManager.setBiome(island, biome.getBiome(), null); island.setBiome(biome.getBiome()); } else { islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); @@ -86,7 +91,7 @@ public class SetBiomeCommand extends SubCommand { configLoad.getString("Command.Island.Admin.SetBiome.Island.Data.Message")); soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { - biomeManager.setBiome(island, biome.getBiome()); + biomeManager.setBiome(island, biome.getBiome(), null); island.setBiome(biome.getBiome()); } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java index bee983d1..54cb630d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java @@ -1,6 +1,8 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.compatibility.ServerVersion; +import com.songoda.skyblock.biome.BiomeManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.gui.bank.GuiBank; @@ -26,20 +28,31 @@ public class BiomeCommand extends SubCommand { MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); SoundManager soundManager = skyblock.getSoundManager(); + BiomeManager biomeManager = skyblock.getBiomeManager(); Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ + messageManager.sendMessage(player, "&bSkyBlock &8| &cError&8: &eThis feature is not available on this Minecraft version yet."); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + return; + } if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) && skyblock.getPermissionManager().hasPermission(island,"Biome", IslandRole.Operator)) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - skyblock.getGuiManager().showGUI(player, new GuiBiome(skyblock, player, island, IslandWorld.Normal, null, false)); // TODO Nether and End support - soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); + if(biomeManager.isUpdating(island)){ + messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.InProgress.Message")); + soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + } else { + skyblock.getGuiManager().showGUI(player, new GuiBiome(skyblock, player, island, IslandWorld.Normal, null, false)); // TODO Nether and End support + soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); + } } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Permission.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java index cc986c21..92d1101e 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java @@ -175,7 +175,10 @@ public class GuiBiome extends Gui { } cooldownManager.createPlayer(CooldownType.Biome, player); Bukkit.getScheduler().runTask(plugin, () -> { - biomeManager.setBiome(island, icon.biome.getBiome()); + biomeManager.setBiome(island, icon.biome.getBiome(), () -> { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Biome.Completed.Message")); + soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F); + }); island.save(); }); island.setBiome(icon.biome.getBiome()); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index fcf00d25..8676aa78 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -4,6 +4,7 @@ import com.bekvon.bukkit.residence.Residence; import com.bekvon.bukkit.residence.containers.Flags; import com.bekvon.bukkit.residence.protection.ClaimedResidence; import com.google.common.base.Preconditions; +import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; @@ -272,23 +273,23 @@ public class IslandManager { player.setFallDistance(0.0F); }, configLoad.getInt("Island.Creation.TeleportTimeout") * 20); - String biomeName = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase(); - SBiome sBiome; + /*String biomeName = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase(); + CompatibleBiome cBiome; try { - sBiome = SBiome.valueOf(biomeName); + cBiome = CompatibleBiome.valueOf(biomeName); } catch (Exception ex) { - sBiome = SBiome.PLAINS; + cBiome = CompatibleBiome.PLAINS; } - Biome biome = sBiome.getBiome(); + Biome biome = cBiome.getBiome(); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { - skyblock.getBiomeManager().setBiome(island, biome); + skyblock.getBiomeManager().setBiome(island, biome, null); if (structure.getCommands() != null) { for (String commandList : structure.getCommands()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); } } - }, 20L); + }, 20L);*/ // Recalculate island level after 5 seconds if (configLoad.getBoolean("Island.Levelling.ScanAutomatically")) @@ -662,7 +663,7 @@ public class IslandManager { } snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); ChunkDeleteSplitter.startDeletion(snapshots); - }); + }, null); } else { ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { Bukkit.getScheduler().runTask(skyblock, () -> { @@ -671,7 +672,7 @@ public class IslandManager { snapshots.put(world, list); ChunkDeleteSplitter.startDeletion(snapshots); }); - }); + }, null); } } diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java index 5cbec2a5..0a2805d4 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -209,7 +209,7 @@ public final class IslandScan extends BukkitRunnable { snapshots.put(skyblock.getWorldManager().getWorld(world), syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); } task.onComplete(); - }); + }, null); } private interface PopulateTask { diff --git a/src/main/java/com/songoda/skyblock/menus/Biome.java b/src/main/java/com/songoda/skyblock/menus/Biome.java index 47a0c4a1..bfa1be90 100644 --- a/src/main/java/com/songoda/skyblock/menus/Biome.java +++ b/src/main/java/com/songoda/skyblock/menus/Biome.java @@ -136,7 +136,7 @@ public class Biome { SBiome selectedBiomeType = SBiome.getFromGuiIcon(is.getType(), is.getData().getData()); cooldownManager.createPlayer(CooldownType.Biome, player); - biomeManager.setBiome(island, selectedBiomeType.getBiome()); + biomeManager.setBiome(island, selectedBiomeType.getBiome(), null); island.setBiome(selectedBiomeType.getBiome()); island.save(); diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index f59e3e38..0cba2905 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -1,30 +1,42 @@ package com.songoda.skyblock.world.generator; -import java.io.File; -import java.util.Arrays; -import java.util.List; -import java.util.Random; - +import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.IslandWorld; import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.island.IslandWorld; +import javax.annotation.Nonnull; +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.Random; public class VoidGenerator extends ChunkGenerator { @Override - public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) { + public @Nonnull ChunkData generateChunkData(@Nonnull World world, @Nonnull Random random, int chunkX, int chunkZ, @Nonnull BiomeGrid biomeGrid) { final ChunkData chunkData = createChunkData(world); final SkyBlock skyblock = SkyBlock.getInstance(); final Configuration configLoad = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); + + /*if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there + setChunkBiome3D(CompatibleBiome.valueOf(configLoad + .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(), biomeGrid); + } else { + setChunkBiome2D(CompatibleBiome.valueOf(configLoad + .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(), biomeGrid); + }*/ + for (IslandWorld worldList : IslandWorld.values()) { if (world.getEnvironment() == World.Environment.NETHER @@ -71,4 +83,26 @@ public class VoidGenerator extends ChunkGenerator { } } } + + private void setChunkBiome3D(Biome biome, BiomeGrid grid) { + for(int x = 0; x < 16; x++){ + for(int z = 0; z < 16; z++){ + for(int y = 0; y<256; y++){ + if(!grid.getBiome(x, y, z).equals(biome)){ + grid.setBiome(x, y, z, biome); + } + } + } + } + } + + private void setChunkBiome2D(Biome biome, BiomeGrid grid) { + for(int x = 0; x < 16; x++){ + for(int z = 0; z < 16; z++){ + if(!grid.getBiome(x, z).equals(biome)){ + grid.setBiome(x, z, biome); + } + } + } + } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index ae0437b4..c05cd6e0 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -830,6 +830,10 @@ Command: Message: '&f&oOpens the Island Biome menu.' Permission: Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to change your Island''s biome.' + InProgress: + Message: '&bSkyBlock &8| &cError&8: &eA biome update is still in progress for this Island.' + Completed: + Message: '&bSkyBlock &8| &aInfo&8: &eThe biome update is now complete' Owner: Message: '&bSkyBlock &8| &cError&8: &eYou are not an Island Owner.' Visitors: From 96952170d537222d5e767c44918784b64d04c8e6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 27 Jun 2020 19:56:28 +0200 Subject: [PATCH 116/366] Removed Paper suggestion --- src/main/java/com/songoda/skyblock/SkyBlock.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 68f4f84b..dffe2fc5 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -121,8 +121,6 @@ public class SkyBlock extends SongodaPlugin { if(paper = ServerProject.isServer(ServerProject.PAPER)){ paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); this.getLogger().info("Enabling Paper hooks"); - } else { - PaperLib.suggestPaper(this); } // Run Songoda Updater From 3a038f1a037b2bb24aae0230eab28df15dd23563 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 29 Jun 2020 19:16:29 +0200 Subject: [PATCH 117/366] Allow use of biome features in 1.16 with a warning --- .../java/com/songoda/skyblock/SkyBlock.java | 4 -- .../songoda/skyblock/biome/BiomeManager.java | 58 ++++++------------- .../commands/admin/SetBiomeCommand.java | 3 + .../command/commands/island/BiomeCommand.java | 5 +- .../world/generator/VoidGenerator.java | 12 ++-- 5 files changed, 30 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index dffe2fc5..15f0a3eb 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -225,10 +225,6 @@ public class SkyBlock extends SongodaPlugin { @Override public void onPluginDisable() { - if (this.biomeManager != null) { - this.biomeManager.onDisable(); - } - if (this.userCacheManager != null) { this.userCacheManager.onDisable(); } diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 58388f41..c32e20d9 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -15,20 +15,15 @@ import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; public class BiomeManager { private final SkyBlock skyblock; private final List updatingIslands; - private final List pools; public BiomeManager(SkyBlock skyblock) { this.skyblock = skyblock; this.updatingIslands = new ArrayList<>(); - this.pools = new ArrayList<>(); } public boolean isUpdating(Island island) { @@ -50,12 +45,10 @@ public class BiomeManager { if(skyblock.isPaperAsync()){ // We keep it sequentially in order to use less RAM - ExecutorService threadPool = Executors.newFixedThreadPool(4); - pools.add(threadPool); ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { Chunk chunk = asyncChunk.join(); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(island, biome, chunk, threadPool); + setChunkBiome3D(island, biome, chunk); } else { setChunkBiome2D(island, biome, chunk); } @@ -64,25 +57,23 @@ public class BiomeManager { if(task != null) { task.onCompleteUpdate(); } - threadPool.shutdown(); - pools.remove(threadPool); })); } else { - ExecutorService threadPool = Executors.newFixedThreadPool(4); - pools.add(threadPool); - ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(island, biome, syncChunk, threadPool); - } else { - setChunkBiome2D(island, biome, syncChunk); - } + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + for(Chunk chunk : syncChunks){ + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there + setChunkBiome3D(island, biome, chunk); + } else { + setChunkBiome2D(island, biome, chunk); + } + } + }); }, (island1 -> { removeUpdatingIsland(island1); if(task != null) { task.onCompleteUpdate(); } - threadPool.shutdown(); - pools.remove(threadPool); })); } } @@ -98,20 +89,15 @@ public class BiomeManager { updateBiomePacket(island, chunk); } - private void setChunkBiome3D(Island island, Biome biome, Chunk chunk, ExecutorService pool) { - for(int i = 0; i<256; i+=16){ - int finalI = i; - pool.execute(() -> { - for(int x = 0; x < 16; x++){ - for(int z = 0; z < 16; z++){ - for(int y = 0; y<16; y++){ - chunk.getWorld().setBiome(x, y * finalI, z, biome); - if(!chunk.getWorld().getBiome(x, y * finalI, z).equals(biome)){ - } - } + private void setChunkBiome3D(Island island, Biome biome, Chunk chunk) { + for(int x = 0; x < 16; x++){ + for(int z = 0; z < 16; z++){ + //for(int y = 0; y<256; y++){ + if(!chunk.getWorld().getBiome(x, 0, z).equals(biome)){ + chunk.getWorld().setBiome(x, 0, z, biome); } - } - }); + //} + } } updateBiomePacket(island, chunk); } @@ -152,12 +138,6 @@ public class BiomeManager { } } - public void onDisable() { - for(ExecutorService pool : pools){ - pool.shutdownNow(); - } - } - public interface CompleteTask { void onCompleteUpdate(); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java index 41e4c508..888785ec 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java @@ -47,6 +47,9 @@ public class SetBiomeCommand extends SubCommand { if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ messageManager.sendMessage(sender, "&bSkyBlock &8| &6Warning&8: &eThis feature is not supported on this Minecraft version yet. Use at your own risk."); + if(sender instanceof Player) { + soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } } if (args.length == 2) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java index 54cb630d..bd0bcd4a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java @@ -34,11 +34,10 @@ public class BiomeCommand extends SubCommand { FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); - + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ - messageManager.sendMessage(player, "&bSkyBlock &8| &cError&8: &eThis feature is not available on this Minecraft version yet."); + messageManager.sendMessage(player, "&bSkyBlock &8| &6Warning&8: &eThis feature is not supported on this Minecraft version yet. Use at your own risk."); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return; } if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Owner.Message")); diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index 0cba2905..934d1556 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -29,13 +29,13 @@ public class VoidGenerator extends ChunkGenerator { final Configuration configLoad = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); - /*if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there setChunkBiome3D(CompatibleBiome.valueOf(configLoad .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(), biomeGrid); } else { setChunkBiome2D(CompatibleBiome.valueOf(configLoad .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(), biomeGrid); - }*/ + } for (IslandWorld worldList : IslandWorld.values()) { @@ -87,11 +87,11 @@ public class VoidGenerator extends ChunkGenerator { private void setChunkBiome3D(Biome biome, BiomeGrid grid) { for(int x = 0; x < 16; x++){ for(int z = 0; z < 16; z++){ - for(int y = 0; y<256; y++){ - if(!grid.getBiome(x, y, z).equals(biome)){ - grid.setBiome(x, y, z, biome); + //for(int y = 0; y<256; y++){ + if(!grid.getBiome(x, 0, z).equals(biome)){ + grid.setBiome(x, 0, z, biome); } - } + //} } } } From 2b538606c2aba226f2405c1d9510f2883a9ae685 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 29 Jun 2020 21:42:28 +0200 Subject: [PATCH 118/366] Restored biome updating on island creation --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 8676aa78..1b5c0e79 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -273,7 +273,7 @@ public class IslandManager { player.setFallDistance(0.0F); }, configLoad.getInt("Island.Creation.TeleportTimeout") * 20); - /*String biomeName = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase(); + String biomeName = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase(); CompatibleBiome cBiome; try { cBiome = CompatibleBiome.valueOf(biomeName); @@ -289,7 +289,7 @@ public class IslandManager { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); } } - }, 20L);*/ + }, 20L); // Recalculate island level after 5 seconds if (configLoad.getBoolean("Island.Levelling.ScanAutomatically")) From 709cb44616d65520a2cdd5e924725813678dc2c8 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 29 Jun 2020 21:52:24 +0200 Subject: [PATCH 119/366] 2.3.4-DEV4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bb7b7c1f..5f26ac6b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.4-DEV3 + 2.3.4-DEV4 jar UTF-8 From f3f3e484d74f60ac48738cd04c1ea46ac3755060 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 30 Jun 2020 22:36:57 +0200 Subject: [PATCH 120/366] 2.3.4-RC1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f26ac6b..4df3ae9b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.4-DEV4 + 2.3.4-RC1 jar UTF-8 From 214756e41e0eb9f578bfb761ade40d912f8fdbf7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 30 Jun 2020 23:01:52 +0200 Subject: [PATCH 121/366] Fix for stacked Dragon egg teleporting --- .../java/com/songoda/skyblock/listeners/Interact.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 4d5aaeab..d5976759 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -164,7 +164,13 @@ public class Interact implements Listener { } else { heldType = CompatibleMaterial.AIR; } - + + if (stackableManager != null && block != null && stackableManager.isStacked(block.getLocation())) { + if(blockType.equals(CompatibleMaterial.DRAGON_EGG)){ + event.setCancelled(true); + } + } + if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType && !player.isSneaking() && skyblock.getPermissionManager().hasPermission(player, island, "Place") && (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission") From 27b9f8ba662fd4acc528d15c0e4bf48d868723e0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 05:15:20 +0200 Subject: [PATCH 122/366] Fixed water not being removed on island deletion --- .../skyblock/biome/ChunkBiomeSplitter.java | 85 ------------------- .../skyblock/blockscanner/BlockScanner.java | 12 +-- .../island/removal/ChunkDeleteSplitter.java | 2 +- .../skyblock/levelling/IslandScan.java | 6 +- 4 files changed, 11 insertions(+), 94 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java diff --git a/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java b/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java deleted file mode 100644 index 08419927..00000000 --- a/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.songoda.skyblock.biome; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.blockscanner.BlockInfo; -import com.songoda.skyblock.blockscanner.BlockScanner; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.ChunkSnapshot; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.CompletableFuture; - -public class ChunkBiomeSplitter extends BukkitRunnable { - - private final Map> snapshots; - private Queue blocks; - private final Biome biome; - private Chunk lastChunk; - private ChunkBiomeTask task; - - private ChunkBiomeSplitter(Map> snapshots, Biome biome, ChunkBiomeTask task) { - this.task = task; - this.snapshots = snapshots; - this.biome = biome; - lastChunk = null; - start(); - } - - private void start() { - Bukkit.getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> { - BlockScanner.startScanner(snapshots, true, true, true, (blocks) -> { - this.blocks = blocks; - this.runTaskTimer(SkyBlock.getInstance(), 2L, 2L); - }); - }); - } - - @Override - public void run() { - - int updateAmount = 0; - - for (Iterator it = blocks.iterator(); it.hasNext();) { - - if (updateAmount == 3500) break; - - final BlockInfo pair = it.next(); - final Block block = pair.getWorld().getBlockAt(pair.getX(), pair.getY(), pair.getZ()); - - if(!block.getChunk().equals(lastChunk)){ - lastChunk = block.getChunk(); - task.onChunkComplete(lastChunk); - } - - block.setBiome(biome); - - updateAmount++; - it.remove(); - } - - Bukkit.broadcastMessage("Amount: " + blocks.size() + " Empty: " + blocks.isEmpty()); - - if (blocks.isEmpty()) { - super.cancel(); - } - } - - public static void startUpdating(Map> snapshots, Biome biome, ChunkBiomeTask task) { - new ChunkBiomeSplitter(snapshots, biome, task); - } - - public interface ChunkBiomeTask { - - void onChunkComplete(Chunk chunk); - - } - -} diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index 4caf43c3..5f8034f6 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -58,11 +58,13 @@ public final class BlockScanner extends BukkitRunnable { private final int threadCount; private final Queue blocks; private final ScannerTasks tasks; - + private boolean ignoreLiquids; + private boolean ignoreLiquidsY; private boolean ignoreAir; - private BlockScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + private BlockScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + this.ignoreLiquidsY = ignoreLiquidsY; this.ignoreLiquids = ignoreLiquids; this.ignoreAir = ignoreAir; this.blocks = new ConcurrentLinkedQueue<>(); @@ -99,7 +101,7 @@ public final class BlockScanner extends BukkitRunnable { if(ignoreY){ startY = 255; } else { - startY = !ignoreLiquids && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0; + startY = !ignoreLiquidsY && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0; } for (List sub : parts) { @@ -161,12 +163,12 @@ public final class BlockScanner extends BukkitRunnable { cancel(); } - public static void startScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + public static void startScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null"); if (tasks == null) throw new IllegalArgumentException("tasks cannot be null"); - final BlockScanner scanner = new BlockScanner(snapshots, ignoreLiquids, ignoreAir, ignoreY, tasks); + final BlockScanner scanner = new BlockScanner(snapshots, ignoreLiquids, ignoreLiquidsY, ignoreAir, ignoreY, tasks); scanner.runTaskTimer(SkyBlock.getInstance(), 5, 5); } diff --git a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java index 1c3f7491..318b728b 100644 --- a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java +++ b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java @@ -27,7 +27,7 @@ public class ChunkDeleteSplitter extends BukkitRunnable { } private void start() { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, false, true, true, false, (blocks) -> { this.blocks = blocks; this.runTaskTimer(SkyBlock.getInstance(), 20, 20); }); diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java index 0a2805d4..f41b88b9 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -82,7 +82,7 @@ public final class IslandScan extends BukkitRunnable { populate(snapshots, IslandWorld.Nether, skyblock.isPaperAsync(), () -> { if (hasEnd) { populate(snapshots, IslandWorld.End, skyblock.isPaperAsync(), () -> { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); @@ -90,7 +90,7 @@ public final class IslandScan extends BukkitRunnable { }); }); } else { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); @@ -99,7 +99,7 @@ public final class IslandScan extends BukkitRunnable { } }); } else { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); From d91b0f276808b499058d4ed030e56303a0825033 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 05:15:30 +0200 Subject: [PATCH 123/366] Fixed error on leaf decay --- .../songoda/skyblock/permission/PermissionManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index d006d820..3e600359 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -260,10 +260,11 @@ public class PermissionManager { } public boolean hasPermission(Location location, String permission, IslandRole islandRole) { - if (location == null) - return false; - return plugin.getIslandManager().getIslandAtLocation(location) - .hasPermission(islandRole, getPermission(permission)); + Island island = plugin.getIslandManager().getIslandAtLocation(location); + if(island != null) { + return island.hasPermission(islandRole, getPermission(permission)); + } + return true; // Return true as there is no island, we don't have to modify the normal world behavior } public boolean hasPermission(Island island, String permission, IslandRole islandRole) { From 746137b8f212fcf981dc83043b202b026930a0b5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 05:17:01 +0200 Subject: [PATCH 124/366] Fixed error in storage permission --- .../listening/StoragePermission.java | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java index 454ed98e..684ac8b3 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java @@ -28,37 +28,39 @@ public class StoragePermission extends ListeningPermission { @PermissionHandler public void onInteract(PlayerInteractEvent event) { - if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) - return; - - CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock()); - Player player = event.getPlayer(); - - switch (material){ - case CHEST: - case TRAPPED_CHEST: - case DROPPER: - case DISPENSER: - case SHULKER_BOX: - case BLACK_SHULKER_BOX: - case BLUE_SHULKER_BOX: - case BROWN_SHULKER_BOX: - case CYAN_SHULKER_BOX: - case GRAY_SHULKER_BOX: - case GREEN_SHULKER_BOX: - case LIGHT_BLUE_SHULKER_BOX: - case LIGHT_GRAY_SHULKER_BOX: - case LIME_SHULKER_BOX: - case MAGENTA_SHULKER_BOX: - case ORANGE_SHULKER_BOX: - case PURPLE_SHULKER_BOX: - case PINK_SHULKER_BOX: - case RED_SHULKER_BOX: - case YELLOW_SHULKER_BOX: - case WHITE_SHULKER_BOX: - case BARREL: - cancelAndMessage(event, player, plugin, messageManager); + if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock()); + Player player = event.getPlayer(); + + if (material != null) { + switch (material) { + case CHEST: + case TRAPPED_CHEST: + case DROPPER: + case DISPENSER: + case SHULKER_BOX: + case BLACK_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: + case LIME_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case PINK_SHULKER_BOX: + case RED_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case WHITE_SHULKER_BOX: + case BARREL: + cancelAndMessage(event, player, plugin, messageManager); + } + } } + } @PermissionHandler From 45a00b1eefc92f7dbf941453e38a0d9c48c3b3c3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 05:39:55 +0200 Subject: [PATCH 125/366] Fixed WorldBorder reducing of 1 block on tp --- .../com/songoda/skyblock/island/IslandManager.java | 2 +- .../com/songoda/skyblock/utils/world/WorldBorder.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 1b5c0e79..22e871d4 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1532,7 +1532,7 @@ public class IslandManager { } for (Player all : getPlayersAtIsland(island)) { - WorldBorder.send(all, island.getBorderColor(), island.getSize()+2, island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island)); + WorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island)); } } } diff --git a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java b/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java index 60ec614b..11be9ac7 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java +++ b/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java @@ -1,8 +1,11 @@ package com.songoda.skyblock.utils.world; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import com.songoda.core.compatibility.ServerVersion; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -35,16 +38,17 @@ public final class WorldBorder { } public static void send(Player player, Color color, double size, Location centerLocation) { + size +=2; try { if (centerLocation == null || centerLocation.getWorld() == null) return; - + if (size % 2 == 1) size++; Object worldBorder = worldBorderClass.getConstructor().newInstance(); - if (NMSUtil.getVersionNumber() >= 9) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { Object craftWorld = craftWorldClass.cast(centerLocation.getWorld()); Method getHandleMethod = craftWorld.getClass().getMethod("getHandle"); Object worldServer = getHandleMethod.invoke(craftWorld); @@ -73,7 +77,7 @@ public final class WorldBorder { Object packet = packetPlayOutWorldBorderConstructor.newInstance(worldBorder, Enum.valueOf((Class) packetPlayOutWorldBorderEnumClass, "INITIALIZE")); NMSUtil.sendPacket(player, packet); - } catch (Exception e) { + } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { e.printStackTrace(); } } From cf5bc5a12ce50c67699b7c0ab80fe06a1991b569 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 06:14:24 +0200 Subject: [PATCH 126/366] Trying to fix remove from water lag --- .../skyblock/command/commands/island/TeleportCommand.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 aecf938a..cb83a120 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 @@ -111,8 +111,10 @@ public class TeleportCommand extends SubCommand { Bukkit.getServer().getScheduler().runTask(skyblock, () -> { Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); - LocationUtil.removeWaterFromLoc(skyblock, loc); - PaperLib.teleportAsync(player, loc); + PaperLib.getChunkAtAsync(loc).thenRun((() -> { + LocationUtil.removeWaterFromLoc(skyblock, loc); + PaperLib.teleportAsync(player, loc); + })); if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ player.setFallDistance(0.0F); From 39d129e85f45affcce194cead53ac3c7992e9f40 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 14:44:18 +0200 Subject: [PATCH 127/366] Comments in biome updating --- .../com/songoda/skyblock/biome/BiomeManager.java | 13 +++++++------ .../skyblock/world/generator/VoidGenerator.java | 11 ++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index c32e20d9..1ff62dc4 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -48,7 +48,7 @@ public class BiomeManager { ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { Chunk chunk = asyncChunk.join(); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(island, biome, chunk); + setChunkBiome2D(island, biome, chunk); // 2D for the moment } else { setChunkBiome2D(island, biome, chunk); } @@ -63,7 +63,7 @@ public class BiomeManager { Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { for(Chunk chunk : syncChunks){ if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(island, biome, chunk); + setChunkBiome2D(island, biome, chunk); // 2D for the moment } else { setChunkBiome2D(island, biome, chunk); } @@ -89,14 +89,15 @@ public class BiomeManager { updateBiomePacket(island, chunk); } + // Do not use - Too laggy private void setChunkBiome3D(Island island, Biome biome, Chunk chunk) { for(int x = 0; x < 16; x++){ for(int z = 0; z < 16; z++){ - //for(int y = 0; y<256; y++){ - if(!chunk.getWorld().getBiome(x, 0, z).equals(biome)){ - chunk.getWorld().setBiome(x, 0, z, biome); + for(int y = 0; y<256; y++){ + if(!chunk.getWorld().getBiome(x, y, z).equals(biome)){ + chunk.getWorld().setBiome(x, y, z, biome); } - //} + } } } updateBiomePacket(island, chunk); diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index 934d1556..d02ce517 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -30,7 +30,7 @@ public class VoidGenerator extends ChunkGenerator { final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there - setChunkBiome3D(CompatibleBiome.valueOf(configLoad + setChunkBiome2D(CompatibleBiome.valueOf(configLoad // 2D for the moment .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(), biomeGrid); } else { setChunkBiome2D(CompatibleBiome.valueOf(configLoad @@ -84,14 +84,15 @@ public class VoidGenerator extends ChunkGenerator { } } + // Do not use - Too laggy private void setChunkBiome3D(Biome biome, BiomeGrid grid) { for(int x = 0; x < 16; x++){ for(int z = 0; z < 16; z++){ - //for(int y = 0; y<256; y++){ - if(!grid.getBiome(x, 0, z).equals(biome)){ - grid.setBiome(x, 0, z, biome); + for(int y = 0; y<256; y++){ + if(!grid.getBiome(x, y, z).equals(biome)){ + grid.setBiome(x, y, z, biome); } - //} + } } } } From a1f4606a7e5eb2b530c46dcba7da0ef01803907c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 14:53:26 +0200 Subject: [PATCH 128/366] Added some Nonnull notations and update NMS version check --- .../com/songoda/skyblock/utils/world/LocationUtil.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 4b1ecbd4..04bfb6b2 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.utils.world; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -36,16 +37,16 @@ public final class LocationUtil { Location tempLoc = LocationUtil.getDefinitiveLocation(loc); if(tempLoc.getBlock().getType().equals(Material.WATER)){ tempLoc.getBlock().setType(Material.AIR); - } else if(NMSUtil.getVersionNumber() > 13){ + } else if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ LocationUtil113.removeWaterLoggedFromLocation(tempLoc); } } } - public static @Nullable Location getSafeLocation(Location loc){ + public static @Nullable Location getSafeLocation(@Nonnull Location loc){ boolean found = false; Location locChecked = null; - if(loc != null && loc.getWorld() != null){ + if(loc.getWorld() != null){ locChecked = loc.clone(); loc.getWorld().loadChunk(loc.getWorld().getChunkAt(loc)); for(int i=loc.getBlockY(); i>=0 && !found; i--){ @@ -67,7 +68,7 @@ public final class LocationUtil { return locChecked; } - public static @Nonnull Location getDefinitiveLocation(Location loc){ + public static @Nonnull Location getDefinitiveLocation(@Nonnull Location loc){ Location locWorking = loc.clone(); for(int i=locWorking.getBlockY(); i>=0; i--){ if(!locWorking.getBlock().isEmpty()){ From 0c72ce94d45175fadaebcd495a3c2a2bbb1cf505 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 14:53:32 +0200 Subject: [PATCH 129/366] 2.3.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4df3ae9b..4b07788a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.4-RC1 + 2.3.4 jar UTF-8 From 25326e5713447d4ca1c5151468b4ffa5185d4fa9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 2 Jul 2020 15:54:34 +0200 Subject: [PATCH 130/366] Update SongodaCore --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4b07788a..aa7f51ba 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ com.songoda SongodaCore - 2.3.38 + 2.3.40 compile From d7c668d1c4aa45d5e550fae1c2ce2d8eb96730a7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 05:37:54 +0200 Subject: [PATCH 131/366] Fixed async error on tp --- src/main/java/com/songoda/skyblock/listeners/Join.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index 9733fdc1..b0ed53f8 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -61,8 +61,10 @@ public class Join implements Listener { if (configLoad.getBoolean("Island.Join.Spawn")) { LocationUtil.teleportPlayerToSpawn(player); } else if (configLoad.getBoolean("Island.Join.Island") && island != null) { - PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); - player.setFallDistance(0.0F); + Bukkit.getScheduler().runTask(skyblock, () -> { + PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); + player.setFallDistance(0.0F); + }); teleportedToIsland = true; } From b091c065a88429d0c434dd94b1f2a13b9b9fa766 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 05:38:36 +0200 Subject: [PATCH 132/366] Fixed NullPointer clicking air with flint and steel --- .../permission/permissions/listening/FirePermission.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java index 3cdadb2d..8acd6da6 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java @@ -31,7 +31,8 @@ public class FirePermission extends ListeningPermission { Player player = event.getPlayer(); - if (CompatibleMaterial.getMaterial(player.getTargetBlock(null, 5)).equals(CompatibleMaterial.FIRE)) + CompatibleMaterial targetMaterial = CompatibleMaterial.getMaterial(player.getTargetBlock(null, 5)); + if (targetMaterial != null && targetMaterial.equals(CompatibleMaterial.FIRE)) cancelAndMessage(event, player, plugin, messageManager); } From 6a98d62f6533b7411d0a16b564f033db9f0d1b8a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 14:46:07 +0200 Subject: [PATCH 133/366] Fix biomes not working --- .../songoda/skyblock/biome/BiomeManager.java | 67 +++++++++++++++---- .../commands/admin/SetBiomeCommand.java | 18 +++-- .../command/commands/island/BiomeCommand.java | 5 +- .../gui/{wip => biome}/BiomeIcon.java | 2 +- .../skyblock/gui/{wip => biome}/GuiBiome.java | 10 +-- .../skyblock/island/IslandManager.java | 4 +- .../world/generator/VoidGenerator.java | 21 +++--- src/main/resources/language.yml | 5 ++ 8 files changed, 92 insertions(+), 40 deletions(-) rename src/main/java/com/songoda/skyblock/gui/{wip => biome}/BiomeIcon.java (98%) rename src/main/java/com/songoda/skyblock/gui/{wip => biome}/GuiBiome.java (94%) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 1ff62dc4..8efd726c 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -10,20 +10,28 @@ import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.block.Biome; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import java.io.File; import java.lang.reflect.InvocationTargetException; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; public class BiomeManager { private final SkyBlock skyblock; private final List updatingIslands; + private final FileConfiguration language; + private final int runEveryX; public BiomeManager(SkyBlock skyblock) { this.skyblock = skyblock; this.updatingIslands = new ArrayList<>(); + this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration(); + this.runEveryX = language.getInt("Command.Island.Biome.Progress.Display-Every-X-Updates"); } public boolean isUpdating(Island island) { @@ -45,13 +53,33 @@ public class BiomeManager { if(skyblock.isPaperAsync()){ // We keep it sequentially in order to use less RAM + int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d)); + AtomicInteger progress = new AtomicInteger(); + ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { Chunk chunk = asyncChunk.join(); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome2D(island, biome, chunk); // 2D for the moment + setChunkBiome3D(island, biome, chunk); // 2D for the moment } else { setChunkBiome2D(island, biome, chunk); } + + progress.getAndIncrement(); + + if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") && + progress.get() == 1 || progress.get() == chunkAmount || progress.get() % runEveryX == 0){ + final double percent = ((double) progress.get() / (double) chunkAmount) * 100; + + String message = language.getString("Command.Island.Biome.Progress.Message"); + message = message.replace("%current_updated_chunks%", String.valueOf(progress.get())); + message = message.replace("%max_chunks%", String.valueOf(chunkAmount)); + message = message.replace("%percent_whole%", String.valueOf((int) percent)); + message = message.replace("%percent%", NumberFormat.getInstance().format(percent)); + + for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { + skyblock.getMessageManager().sendMessage(player, message); + } + } }, (island1 -> { removeUpdatingIsland(island1); if(task != null) { @@ -61,12 +89,29 @@ public class BiomeManager { } else { ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + int progress = 0; for(Chunk chunk : syncChunks){ if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome2D(island, biome, chunk); // 2D for the moment + setChunkBiome3D(island, biome, chunk); // 2D for the moment } else { setChunkBiome2D(island, biome, chunk); } + progress++; + + if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") && + progress == 1 || progress == syncChunks.size() || progress % runEveryX == 0){ + final double percent = ((double) progress / (double) syncChunks.size()) * 100; + + String message = language.getString("Command.Island.Biome.Progress.Message"); + message = message.replace("%current_updated_chunks%", String.valueOf(progress)); + message = message.replace("%max_chunks%", String.valueOf(syncChunks.size())); + message = message.replace("%percent_whole%", String.valueOf((int) percent)); + message = message.replace("%percent%", NumberFormat.getInstance().format(percent)); + + for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { + skyblock.getMessageManager().sendMessage(player, message); + } + } } }); }, (island1 -> { @@ -79,11 +124,9 @@ public class BiomeManager { } private void setChunkBiome2D(Island island, Biome biome, Chunk chunk) { - for(int xx = 0; xx < 16; xx++){ - for(int zz = 0; zz < 16; zz++){ - if(!chunk.getWorld().getBiome(xx, zz).equals(biome)){ - chunk.getWorld().setBiome(xx, zz, biome); - } + for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){ + for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){ + chunk.getWorld().setBiome(x, z, biome); } } updateBiomePacket(island, chunk); @@ -91,12 +134,10 @@ public class BiomeManager { // Do not use - Too laggy private void setChunkBiome3D(Island island, Biome biome, Chunk chunk) { - for(int x = 0; x < 16; x++){ - for(int z = 0; z < 16; z++){ - for(int y = 0; y<256; y++){ - if(!chunk.getWorld().getBiome(x, y, z).equals(biome)){ - chunk.getWorld().setBiome(x, y, z, biome); - } + for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){ + for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){ + for(int y = 0; y < chunk.getWorld().getMaxHeight(); ++y) { + chunk.getWorld().setBiome(x, y, z, biome); } } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java index 888785ec..38c17d48 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.command.commands.admin; +import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.biome.BiomeManager; @@ -11,6 +12,7 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.utils.StringUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.utils.version.SBiome; import org.bukkit.Bukkit; @@ -55,10 +57,10 @@ public class SetBiomeCommand extends SubCommand { if (args.length == 2) { String biomeName = args[1].toUpperCase().trim(); - SBiome biome = null; - for (SBiome sbiome : SBiome.values()) { - if (sbiome.isAvailable() && sbiome.name().equals(biomeName)) { - biome = sbiome; + CompatibleBiome biome = null; + for (CompatibleBiome cbiome : CompatibleBiome.values()) { + if (cbiome.isCompatible() && cbiome.name().equals(biomeName)) { + biome = cbiome; break; } } @@ -94,15 +96,17 @@ public class SetBiomeCommand extends SubCommand { configLoad.getString("Command.Island.Admin.SetBiome.Island.Data.Message")); soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { - biomeManager.setBiome(island, biome.getBiome(), null); - island.setBiome(biome.getBiome()); + CompatibleBiome finalBiome = biome; + biomeManager.setBiome(island, biome.getBiome(), () -> { + island.setBiome(finalBiome.getBiome()); + }); } } messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.SetBiome.Set.Message") .replace("%player", targetPlayerName) - .replace("%biome", biome.getFormattedBiomeName())); + .replace("%biome", StringUtil.capitalizeWord(biome.getBiome().name().replaceAll("_", " ")))); soundManager.playSound(sender, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); } } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java index bd0bcd4a..7dc23ed8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java @@ -5,16 +5,13 @@ import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.biome.BiomeManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.gui.bank.GuiBank; -import com.songoda.skyblock.gui.wip.GuiBiome; +import com.songoda.skyblock.gui.biome.GuiBiome; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.island.IslandWorld; -import com.songoda.skyblock.menus.Biome; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.world.WorldManager; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java similarity index 98% rename from src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java rename to src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java index 071f3bd0..ca793778 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/BiomeIcon.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.gui.wip; +package com.songoda.skyblock.gui.biome; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java similarity index 94% rename from src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java rename to src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java index 92d1101e..f848d880 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java @@ -1,4 +1,4 @@ -package com.songoda.skyblock.gui.wip; +package com.songoda.skyblock.gui.biome; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; @@ -176,12 +176,14 @@ public class GuiBiome extends Gui { cooldownManager.createPlayer(CooldownType.Biome, player); Bukkit.getScheduler().runTask(plugin, () -> { biomeManager.setBiome(island, icon.biome.getBiome(), () -> { - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Biome.Completed.Message")); - soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F); + if(languageLoad.getBoolean("Command.Island.Biome.Completed.Should-Display-Message")){ + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Biome.Completed.Message")); + soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F); + } }); + island.setBiome(icon.biome.getBiome()); island.save(); }); - island.setBiome(icon.biome.getBiome()); soundManager.playSound(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island), CompatibleSound.ENTITY_GENERIC_SPLASH.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 22e871d4..627c2ac4 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -282,14 +282,14 @@ public class IslandManager { } Biome biome = cBiome.getBiome(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { + /*Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { skyblock.getBiomeManager().setBiome(island, biome, null); if (structure.getCommands() != null) { for (String commandList : structure.getCommands()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); } } - }, 20L); + }, 20L);*/ // Recalculate island level after 5 seconds if (configLoad.getBoolean("Island.Levelling.ScanAutomatically")) diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index d02ce517..ccfb8400 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -4,7 +4,11 @@ import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; +import io.papermc.lib.PaperLib; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Biome; @@ -29,12 +33,13 @@ public class VoidGenerator extends ChunkGenerator { final Configuration configLoad = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); + Biome biome = CompatibleBiome.valueOf(configLoad // 2D for the moment + .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there - setChunkBiome2D(CompatibleBiome.valueOf(configLoad // 2D for the moment - .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(), biomeGrid); + setChunkBiome3D(biome, biomeGrid, world); } else { - setChunkBiome2D(CompatibleBiome.valueOf(configLoad - .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(), biomeGrid); + setChunkBiome2D(biome, biomeGrid); } @@ -85,13 +90,11 @@ public class VoidGenerator extends ChunkGenerator { } // Do not use - Too laggy - private void setChunkBiome3D(Biome biome, BiomeGrid grid) { + private void setChunkBiome3D(Biome biome, BiomeGrid grid, World world) { for(int x = 0; x < 16; x++){ for(int z = 0; z < 16; z++){ - for(int y = 0; y<256; y++){ - if(!grid.getBiome(x, y, z).equals(biome)){ - grid.setBiome(x, y, z, biome); - } + for(int y = 0; y < world.getMaxHeight(); ++y) { + grid.setBiome(z, y, z, biome); } } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index c05cd6e0..b62e7ec4 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -834,8 +834,13 @@ Command: Message: '&bSkyBlock &8| &cError&8: &eA biome update is still in progress for this Island.' Completed: Message: '&bSkyBlock &8| &aInfo&8: &eThe biome update is now complete' + Should-Display-Message: true Owner: Message: '&bSkyBlock &8| &cError&8: &eYou are not an Island Owner.' + Progress: + Message: '&fUpdated &a%current_updated_chunks%&f/&b%max_chunks% &fchunks ( &a%percent%&f%&f )' + Should-Display-Message: true + Display-Every-X-Updates: 20 Visitors: Info: Message: '&f&oOpens the Island Visitors menu.' From a58e0d9ae0042773da14e62c579c0db94845661f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 14:46:26 +0200 Subject: [PATCH 134/366] Simplify code --- src/main/java/com/songoda/skyblock/SkyBlock.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 15f0a3eb..7b68a213 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -19,8 +19,6 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.confirmation.ConfirmationTask; import com.songoda.skyblock.cooldown.CooldownManager; import com.songoda.skyblock.generator.GeneratorManager; -import com.songoda.skyblock.permission.PermissionManager; -import com.songoda.skyblock.tasks.HologramTask; import com.songoda.skyblock.invite.InviteManager; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.reward.RewardManager; @@ -33,6 +31,7 @@ import com.songoda.skyblock.menus.admin.Creator; import com.songoda.skyblock.menus.admin.Generator; import com.songoda.skyblock.menus.admin.Levelling; import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.placeholder.PlaceholderManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.playtime.PlaytimeTask; @@ -40,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.HologramTask; import com.songoda.skyblock.tasks.MobNetherWaterTask; import com.songoda.skyblock.upgrade.UpgradeManager; import com.songoda.skyblock.usercache.UserCacheManager; @@ -47,7 +47,6 @@ import com.songoda.skyblock.visit.VisitManager; import com.songoda.skyblock.visit.VisitTask; import com.songoda.skyblock.world.WorldManager; import com.songoda.skyblock.world.generator.VoidGenerator; -import io.papermc.lib.PaperLib; import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtectAPI; import org.bukkit.Bukkit; @@ -208,7 +207,8 @@ public class SkyBlock extends SongodaPlugin { pluginManager.registerEvents(new Piston(this), this); pluginManager.registerEvents(new FallBreak(this), this); - if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this); + if (pluginManager.isPluginEnabled("EpicSpawners")) + pluginManager.registerEvents(new EpicSpawners(this), this); if (pluginManager.isPluginEnabled("UltimateStacker")) pluginManager.registerEvents(new UltimateStacker(this), this); From 1f508a7225ef63b08ed4ac2f0bdc83ba801a81f4 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 14:46:51 +0200 Subject: [PATCH 135/366] Removed useless code --- src/main/java/com/songoda/skyblock/levelling/IslandScan.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java index f41b88b9..333c86e7 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -28,7 +28,6 @@ import java.util.stream.Collectors; public final class IslandScan extends BukkitRunnable { private static final NumberFormat FORMATTER = NumberFormat.getInstance(); - ; private final Set doubleBlocks; private final Island island; From 9a3b800f5fc0f621ffd1a109c326032253f1fbec Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 14:47:03 +0200 Subject: [PATCH 136/366] Added more APIs for levels --- .../songoda/skyblock/api/island/IslandLevel.java | 12 +++++++++++- .../skyblock/api/levelling/LevellingManager.java | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java index b41bb99f..b2ac2c1e 100644 --- a/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java @@ -1,8 +1,9 @@ package com.songoda.skyblock.api.island; import com.google.common.base.Preconditions; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import org.bukkit.Location; import org.bukkit.Material; public class IslandLevel { @@ -116,4 +117,13 @@ public class IslandLevel { public Island getIsland() { return handle; } + + /** + * Update the island level for a determined location + * @param location + */ + public void updateLevel(Location location){ + Preconditions.checkArgument(location != null, "Cannot update level of a null island"); + SkyBlock.getInstance().getLevellingManager().updateLevel(this.handle.getIsland(), location); + } } diff --git a/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java b/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java index 5d9a9bf8..018d552f 100644 --- a/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java +++ b/src/main/java/com/songoda/skyblock/api/levelling/LevellingManager.java @@ -1,8 +1,12 @@ package com.songoda.skyblock.api.levelling; import com.google.common.base.Preconditions; +import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.api.island.Island; import com.songoda.skyblock.levelling.IslandLevelManager; +import com.songoda.skyblock.levelling.calculator.Calculator; +import com.songoda.skyblock.levelling.calculator.CalculatorRegistry; +import org.bukkit.Material; public class LevellingManager { @@ -19,4 +23,15 @@ public class LevellingManager { Preconditions.checkArgument(island != null, "Cannot calculate points to null island"); this.levellingManager.startScan(null, island.getIsland()); } + + /** + * Register a new material calculator for a determined material + * @param calculator + * @param material + */ + public void registerCalculator(Calculator calculator, Material material){ + Preconditions.checkArgument(calculator != null, "Cannot use a null calculator"); + Preconditions.checkArgument(material != null, "Cannot use a null material"); + CalculatorRegistry.registerCalculator(calculator, CompatibleMaterial.getMaterial(material)); + } } From e332b8aea985ba2392dc04a43dd0bc4175cb8504 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 15:08:53 +0200 Subject: [PATCH 137/366] Removed warning on biome command --- .../skyblock/command/commands/admin/SetBiomeCommand.java | 7 ------- .../skyblock/command/commands/island/BiomeCommand.java | 6 +----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java index 38c17d48..fc59b64d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java @@ -46,13 +46,6 @@ public class SetBiomeCommand extends SubCommand { Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ - messageManager.sendMessage(sender, "&bSkyBlock &8| &6Warning&8: &eThis feature is not supported on this Minecraft version yet. Use at your own risk."); - if(sender instanceof Player) { - soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } - } if (args.length == 2) { String biomeName = args[1].toUpperCase().trim(); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java index 7dc23ed8..4e569499 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java @@ -31,11 +31,7 @@ public class BiomeCommand extends SubCommand { FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); - - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ - messageManager.sendMessage(player, "&bSkyBlock &8| &6Warning&8: &eThis feature is not supported on this Minecraft version yet. Use at your own risk."); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } + if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); From 2b41236439ba9a6070d901fd01db3736346a6cba Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 3 Jul 2020 15:21:11 +0200 Subject: [PATCH 138/366] Fix for old Paper versions --- src/main/java/com/songoda/skyblock/SkyBlock.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 7b68a213..70e52f07 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -118,7 +118,12 @@ public class SkyBlock extends SongodaPlugin { } if(paper = ServerProject.isServer(ServerProject.PAPER)){ - paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); + try { + Bukkit.spigot().getClass().getMethod("getPaperConfig"); + paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); + } catch (NoSuchMethodException ignored) { + paperAsync = false; + } this.getLogger().info("Enabling Paper hooks"); } From ed02954230cb96428679a36799bf2070c6c214da Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 06:27:29 +0200 Subject: [PATCH 139/366] Removed WildStacker dependency --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index cec453a8..7954dbcd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,7 +6,7 @@ description: A unique SkyBlock plugin author: Songoda authors: [Fabrimat] softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, - EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector] + EpicSpawners, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector] loadbefore: [Multiverse-Core, ProtocolLib] commands: island: From 2a514b5467980c69af2599f24f94a70a353a8d18 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 06:29:24 +0200 Subject: [PATCH 140/366] Back to latest Core version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa7f51ba..90d10a5f 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ com.songoda SongodaCore - 2.3.40 + LATEST compile From 4456c5f356585720b89d23b2864375f6773c4a10 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 07:09:16 +0200 Subject: [PATCH 141/366] New ChatSpy admin command --- .../skyblock/command/CommandManager.java | 3 +- .../commands/admin/ChatSpyCommand.java | 61 +++++++++++++++++++ .../com/songoda/skyblock/listeners/Chat.java | 16 ++++- .../skyblock/playerdata/PlayerData.java | 13 ++++ src/main/resources/language.yml | 14 +++++ 5 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index 97778834..84ef286a 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -116,7 +116,8 @@ public class CommandManager implements CommandExecutor, TabCompleter { new com.songoda.skyblock.command.commands.admin.UpgradeCommand(), new StackableCommand(), new AdminBank(), - new SetMaxMembers() + new SetMaxMembers(), + new ChatSpyCommand() ); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java new file mode 100644 index 00000000..cc397517 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java @@ -0,0 +1,61 @@ +package com.songoda.skyblock.command.commands.admin; + +import com.songoda.skyblock.command.SubCommand; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.playerdata.PlayerData; +import com.songoda.skyblock.playerdata.PlayerDataManager; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; + +public class ChatSpyCommand extends SubCommand { + + @Override + public void onCommandByPlayer(Player player, String[] args) { + MessageManager messageManager = skyblock.getMessageManager(); + PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + FileManager fileManager = skyblock.getFileManager(); + + FileManager.Config language = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration languageLoad = language.getFileConfiguration(); + + PlayerData playerData = playerDataManager.getPlayerData(player); + if(playerData != null) { + if(playerData.isChatSpy()){ + playerData.setChatSpy(false); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Disabled.Message")); + } else { + playerData.setChatSpy(true); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Enabled.Message")); + } + } + } + + @Override + public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { + sender.sendMessage("SkyBlock | Error: You must be a player to perform that command."); + } + + @Override + public String getName() { + return "chatspy"; + } + + @Override + public String getInfoMessagePath() { + return "Command.Island.Admin.ChatSpy.Info.Message"; + } + + @Override + public String[] getAliases() { + return new String[]{"spychat", "spy"}; + } + + @Override + public String[] getArguments() { + return new String[0]; + } +} diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index 9ea6a431..573a90d2 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -11,6 +11,7 @@ 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.utils.player.OfflinePlayer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; @@ -88,7 +89,20 @@ public class Chat implements Listener { String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName()))) .replace("%message", islandChatEvent.getMessage()); - targetPlayer.sendMessage(message); + messageManager.sendMessage(targetPlayer, message); + } + + for(Player targetPlayer : Bukkit.getServer().getOnlinePlayers()){ + if(targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) { + PlayerData pd = playerDataManager.getPlayerData(targetPlayer); + if(pd != null && pd.isChatSpy()) { + String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, + islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName()))) + .replace("%islandOwner", new OfflinePlayer(island.getOwnerUUID()).getName()) + .replace("%message", islandChatEvent.getMessage()); + messageManager.sendMessage(targetPlayer, message); + } + } } if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index e72addcd..9490d12f 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -33,6 +33,8 @@ public class PlayerData { private Object sort; private Area area; + + private boolean chatSpy; private boolean chat; private boolean preview; @@ -52,6 +54,8 @@ public class PlayerData { area = new Area(); + chatSpy = getConfig().getFileConfiguration().getBoolean("ChatSpy", false); + chat = false; preview = false; transactions = new ArrayList<>(); @@ -307,4 +311,13 @@ public class PlayerData { public List getTransactions() { return transactions; } + + public boolean isChatSpy() { + return chatSpy; + } + + public void setChatSpy(boolean chatSpy) { + this.chatSpy = chatSpy; + getConfig().getFileConfiguration().set("ChatSpy", chatSpy); + } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index b62e7ec4..6812a057 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -176,6 +176,13 @@ Command: Message: 'Succesfully removed %ammount% from %player%''s island' SuccesDeposit: Message: 'Succesfully added %ammount% to %player%''s island' + ChatSpy: + Info: + Message: '&f&oToggle island chat spy.' + Enabled: + Message: '&bSkyBlock &8| &aInfo&8: &eChat spy enabled.' + Disabled: + Message: '&bSkyBlock &8| &aInfo&8: &eChat spy disabled.' Reload: Info: Message: '&f&oReload all loaded files.' @@ -3542,6 +3549,13 @@ Island: Message: '&8[&bSkyBlock &8| &dChat&8] %role &e%player&8: &f%message' Untoggled: Message: '&bSkyBlock &8| &aInfo&8: &eThe Island chat has been untoggled because there are no Island Members online. Chat messages will now be visible for all players.' + Spy: + Format: + Role: + Member: '&a[Member]' + Operator: '&b[Operator]' + Owner: '&c[Owner]' + Message: '&8[&bSkyBlock &8| &dChatSpy&8] [&7%islandOwner&8] &e%player&8: &f%message' SpawnProtection: Break: Message: '&bSkyBlock &8| &cError&8: &eYou cannot break the spawn point of the Island.' From 8fedcb00c2ed10de349034324a7204077d740822 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 07:10:39 +0200 Subject: [PATCH 142/366] Fix errors in admin bank and added tab completition --- .../skyblock/command/commands/admin/AdminBank.java | 10 +++++----- .../java/com/songoda/skyblock/gui/bank/GuiBank.java | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index 09cd258a..2fdf72eb 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -49,15 +49,15 @@ public class AdminBank extends SubCommand { switch (args[0].toLowerCase()) { case "balance": - if (args.length <2) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); - }else { + if (args.length >= 3) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID()))))); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); } return; case "deposit": if (args.length >= 3) { - islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(args[1])).getUniqueId())).addToBank(Double.parseDouble(args[2])); + islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2])); messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); }else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); @@ -154,6 +154,6 @@ public class AdminBank extends SubCommand { @Override public String[] getArguments() { - return new String[0]; + return new String[]{"withdraw", "deposit", "balance", "open"}; } } diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java index 370d5bda..bab25d1f 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java @@ -36,7 +36,6 @@ import java.util.stream.Collectors; public class GuiBank extends Gui { private final SkyBlock plugin; - private final BankManager bankManager; private final SoundManager soundManager; private final Island island; private final FileConfiguration languageLoad; @@ -45,15 +44,16 @@ public class GuiBank extends Gui { public GuiBank(SkyBlock plugin, Island island, Gui returnGui, boolean admin) { super(2, returnGui); this.plugin = plugin;; - this.bankManager = plugin.getBankManager(); this.soundManager = plugin.getSoundManager(); this.island = island; this.admin = admin; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); - setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); - setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Title"))); - paint(); + if(island != null) { + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Title"))); + paint(); + } } @Override From 642c64981a8cdbcc4d394c9e156a7be418cb53c2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 07:35:52 +0200 Subject: [PATCH 143/366] Added more config to Generator player permission check --- .../com/songoda/skyblock/listeners/Block.java | 55 ++++++++++++------- src/main/resources/config.yml | 5 ++ 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 18f85624..8d53e1fa 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -552,11 +552,13 @@ public class Block implements Listener { WorldManager worldManager = skyblock.getWorldManager(); IslandLevelManager islandLevelManager = skyblock.getLevellingManager(); + FileConfiguration config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); + if (!worldManager.isIslandWorld(block.getWorld())) return; // Check ice/snow forming if (block.getType() == Material.ICE || block.getType() == Material.SNOW) { - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.IceAndSnow")) + if (!config.getBoolean("Island.Weather.IceAndSnow")) event.setCancelled(true); return; } @@ -594,37 +596,52 @@ public class Block implements Listener { Collections.reverse(generators); // Use the highest generator available + boolean ignoreVisitors = config.getBoolean("Island.Generator.IgnoreVisitors", false); + // Filter valid players on the island. - Set possiblePlayers = new HashSet<>(); + List possiblePlayers = new ArrayList<>(); for (Player player : Bukkit.getOnlinePlayers()) { 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.getVisit().getVisitors().contains(player.getUniqueId()) && - player.hasPermission("fabledskyblock.generator.anywhere")); + player.hasPermission("fabledskyblock.generator.anywhere") && + !ignoreVisitors); if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) { possiblePlayers.add(player); } } - - // Find highest generator available - for (Generator generator : generators) { - for (Player player : possiblePlayers) { - if (generator.isPermission()) { - if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) { - continue; + + if(!possiblePlayers.isEmpty()){ + boolean nearestPlayer = config.getBoolean("Island.Generator.CheckOnlyNearestPlayer", false); + + if(nearestPlayer){ + possiblePlayers.sort(Comparator.comparingDouble(a -> a.getLocation().distance(block.getLocation()))); + } + + double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation()); + // Find highest generator available + for (Generator generator : generators) { + for (Player player : possiblePlayers) { + if(player.getLocation().distance(block.getLocation()) > distance){ + break; + } + if (generator.isPermission()) { + if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) { + continue; + } + } + + if(worldManager.getIslandWorld(event.getBlock().getWorld()).equals(generator.getIsWorld())){ + org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block); + state.setType(genState.getType()); + + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) state.setData(genState.getData()); + islandLevelManager.updateLevel(island, genState.getLocation()); + return; } - } - - 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()); - islandLevelManager.updateLevel(island, genState.getLocation()); - return; } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index adc86264..ba339c40 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -319,6 +319,11 @@ Island: Enable: true Generator: Enable: true + # Check permissions of all the online player in the island or just + # the nearest player to the generator + CheckOnlyNearestPlayer: false + # Ignore visitors in permission check, also who has "fabledskyblock.generator.anywhere" permission + IgnoreVisitors: false Stackable: Enable: true # fabledskyblock.stackables From 35b98f5c3be6f7582402c4be21bb8e474dddfdeb Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 10:48:23 +0200 Subject: [PATCH 144/366] Island whitelist --- .../commands/island/TeleportCommand.java | 6 ++- .../commands/island/VisitorsCommand.java | 3 -- .../com/songoda/skyblock/island/Island.java | 43 ++++++++++++++++--- .../skyblock/island/IslandManager.java | 6 +-- .../com/songoda/skyblock/listeners/Move.java | 2 +- .../songoda/skyblock/listeners/Teleport.java | 2 +- .../com/songoda/skyblock/menus/Visit.java | 6 ++- 7 files changed, 53 insertions(+), 15 deletions(-) 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 cb83a120..d5f6af4c 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 @@ -62,14 +62,18 @@ public class TeleportCommand extends SubCommand { if (visitManager.hasIsland(islandOwnerUUID)) { Visit visit = visitManager.getIsland(islandOwnerUUID); boolean isCoopPlayer = false; + boolean isWhitelistedPlayer = false; if (islandManager.containsIsland(islandOwnerUUID)) { if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isCoopPlayer(player.getUniqueId())) { isCoopPlayer = true; } + if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isPlayerWhitelisted(player.getUniqueId())) { + isWhitelistedPlayer = true; + } } - if (isCoopPlayer || player.hasPermission("fabledskyblock.bypass") || player.hasPermission("fabledskyblock.bypass.*") || player.hasPermission("fabledskyblock.*") || visit.isOpen()) { + if (isCoopPlayer || isWhitelistedPlayer || player.hasPermission("fabledskyblock.bypass") || player.hasPermission("fabledskyblock.bypass.*") || player.hasPermission("fabledskyblock.*") || visit.isOpen()) { if (!islandManager.containsIsland(islandOwnerUUID)) { islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java index 69949996..ffe3b492 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java @@ -30,9 +30,6 @@ public class VisitorsCommand extends SubCommand { if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Visitors.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (!island.isOpen()) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Visitors.Closed.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (islandManager.getVisitorsAtIsland(island).size() == 0) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Visitors.Visitors.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 2340d574..30aceaed 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -10,7 +10,6 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.BasicPermission; -import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.upgrade.Upgrade; @@ -26,7 +25,6 @@ import org.bukkit.WeatherType; import org.bukkit.block.Biome; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import org.bukkit.util.Vector; import java.io.File; import java.io.IOException; @@ -39,9 +37,10 @@ public class Island { private final SkyBlock skyblock; private final com.songoda.skyblock.api.island.Island apiWrapper; - private Map> islandPermissions = new HashMap<>(); - private List islandLocations = new ArrayList<>(); - private Map coopPlayers = new HashMap<>(); + private final Map> islandPermissions = new HashMap<>(); + private final List islandLocations = new ArrayList<>(); + private final Map coopPlayers = new HashMap<>(); + private final Set whitelistedPlayers = new HashSet<>(); private UUID islandUUID; private UUID ownerUUID; @@ -188,6 +187,12 @@ public class Island { islandPermissions.put(roleList, permissions); } + + if (configLoad.getString("Whitelist") != null) { + for (String whitelistedUUID : configLoad.getStringList("Whitelist")) { + whitelistedPlayers.add(UUID.fromString(whitelistedUUID)); + } + } } else { FileConfiguration configLoad = config.getFileConfiguration(); @@ -841,6 +846,8 @@ public class Island { Config config = fileManager .getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); + + config.getFileConfiguration().set("Whitelist", whitelistedPlayers); try { config.getFileConfiguration().save(config.getFile()); @@ -926,5 +933,31 @@ public class Island { public com.songoda.skyblock.api.island.Island getAPIWrapper() { return apiWrapper; } + + public void addWhitelistedPlayer(UUID uuid) { + this.whitelistedPlayers.add(uuid); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + } + + public boolean isPlayerWhitelisted(UUID uuid) { + return this.whitelistedPlayers.contains(uuid); + } + + public void removeWhitelistedPlayer(UUID uuid) { + this.whitelistedPlayers.remove(uuid); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + } + + public void addWhitelistedPlayer(Player player) { + this.addWhitelistedPlayer(player.getUniqueId()); + } + + public boolean isPlayerWhitelisted(Player player) { + return this.isPlayerWhitelisted(player.getUniqueId()); + } + + public void removeWhitelistedPlayer(Player player) { + this.removeWhitelistedPlayer(player.getUniqueId()); + } } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 627c2ac4..a631ab50 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1189,9 +1189,9 @@ public class IslandManager { islandOwnerPlayerName = islandOwnerPlayer.getName(); } - for (UUID visitorList : getVisitorsAtIsland(island)) { - if (!island.isCoopPlayer(visitorList)) { - Player targetPlayer = Bukkit.getServer().getPlayer(visitorList); + for (UUID visitor : getVisitorsAtIsland(island)) { + if (!island.isCoopPlayer(visitor) && !island.isPlayerWhitelisted(visitor)) { + Player targetPlayer = Bukkit.getServer().getPlayer(visitor); LocationUtil.teleportPlayerToSpawn(targetPlayer); messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", islandOwnerPlayerName)); } diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index df80784c..682ae6d0 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -179,7 +179,7 @@ public class Move implements Listener { return; } - if(loadedIsland.isOpen()){ + if(loadedIsland.isOpen() || loadedIsland.isPlayerWhitelisted(player)){ loadedIsland.getVisit().addVisitor(player.getUniqueId()); return; } diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index 5b39d75f..faac4882 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -98,7 +98,7 @@ public class Teleport implements Listener { if (island != null) { if (!island.getOwnerUUID().equals(playerData.getOwner())) { if (!player.hasPermission("fabledskyblock.bypass") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) { - if (!island.isOpen() && !island.isCoopPlayer(player.getUniqueId())) { + if (!island.isOpen() && !island.isCoopPlayer(player.getUniqueId()) && !island.isPlayerWhitelisted(player)) { event.setCancelled(true); messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Plugin.Message")); diff --git a/src/main/java/com/songoda/skyblock/menus/Visit.java b/src/main/java/com/songoda/skyblock/menus/Visit.java index c8b30301..9cdc4a9a 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visit.java +++ b/src/main/java/com/songoda/skyblock/menus/Visit.java @@ -145,6 +145,7 @@ public class Visit { if (visitManager.hasIsland(targetPlayerUUID)) { com.songoda.skyblock.visit.Visit visit = visitManager.getIsland(targetPlayerUUID); boolean isCoopPlayer = false; + boolean isWhitelistedPlayer = false; org.bukkit.OfflinePlayer offlinePlayer = Bukkit.getServer() .getOfflinePlayer(targetPlayerUUID); @@ -152,9 +153,12 @@ public class Visit { if (islandManager.getIsland(offlinePlayer).isCoopPlayer(player.getUniqueId())) { isCoopPlayer = true; } + if (islandManager.getIsland(offlinePlayer).isPlayerWhitelisted(player.getUniqueId())) { + isWhitelistedPlayer = true; + } } - if (isCoopPlayer || player.hasPermission("fabledskyblock.bypass") + if (isCoopPlayer || isWhitelistedPlayer || player.hasPermission("fabledskyblock.bypass") || player.hasPermission("fabledskyblock.bypass.*") || player.hasPermission("fabledskyblock.*") || visit.isOpen()) { if (!islandManager.containsIsland(targetPlayerUUID)) { From 20ef7b95e5ee947eef31ceea173f8a37de75da92 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 10:48:40 +0200 Subject: [PATCH 145/366] Removed ban permission check on kickall command --- .../skyblock/command/commands/island/KickAllCommand.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 4f2f9251..e0f8d686 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 @@ -50,8 +50,7 @@ public class KickAllCommand extends SubCommand { Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitorList); if (targetPlayer != null && - (targetPlayer.hasPermission("fabledskyblock.bypass.ban") || - targetPlayer.hasPermission("fabledskyblock.bypass.kick"))) + (targetPlayer.hasPermission("fabledskyblock.bypass.kick"))) continue; IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), From 1a50f151288d9e4a4125a4e0ca29475a2dccdaf8 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 15:28:21 +0200 Subject: [PATCH 146/366] Reformat AdminBank --- .../command/commands/admin/AdminBank.java | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index 2fdf72eb..f9cee773 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -44,57 +44,56 @@ public class AdminBank extends SubCommand { if (args.length < 1) { skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); - return; - } - - switch (args[0].toLowerCase()) { - case "balance": - if (args.length >= 3) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID()))))); - } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); - } - return; - case "deposit": - if (args.length >= 3) { - islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2])); - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); - }else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); - } - return; - case "withdraw": - if (args.length >= 3) { - islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2])); - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); - }else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); - } - return; - case "open": - if(args.length == 2){ - Player targetPlayer = Bukkit.getServer().getPlayer(args[1]); - UUID islandOwnerUUID; - - if (targetPlayer == null) { - OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[1]); - islandOwnerUUID = targetPlayerOffline.getOwner(); + } else { + switch (args[0].toLowerCase()) { + case "balance": + if (args.length >= 3) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID()))))); } else { - islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner(); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); } - - island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); - } - if (island != null){ - skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); - } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message")); + return; + case "deposit": + if (args.length >= 3) { + islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2])); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); + }else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); + } + return; + case "withdraw": + if (args.length >= 3) { + islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2])); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); + }else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); + } + return; + case "open": + if(args.length == 2){ + Player targetPlayer = Bukkit.getServer().getPlayer(args[1]); + UUID islandOwnerUUID; + + if (targetPlayer == null) { + OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[1]); + islandOwnerUUID = targetPlayerOffline.getOwner(); + } else { + islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner(); + } + + island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); + } + if (island != null){ + skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } + break; + default: + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); - } - break; - default: - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } } } From 11c72f9256a7efe08654303d2c4f7f769c13567a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 4 Jul 2020 15:28:30 +0200 Subject: [PATCH 147/366] Per-Island Chat Spy --- .../commands/admin/ChatSpyCommand.java | 64 ++++++++++++++++++- .../com/songoda/skyblock/listeners/Chat.java | 2 +- .../skyblock/playerdata/PlayerData.java | 56 +++++++++++++++- .../skyblock/utils/player/OfflinePlayer.java | 20 +++--- 4 files changed, 129 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java index cc397517..a77f5521 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java @@ -1,28 +1,90 @@ package com.songoda.skyblock.command.commands.admin; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.gui.bank.GuiBank; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.utils.player.OfflinePlayer; +import org.bukkit.Bukkit; 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 ChatSpyCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + MessageManager messageManager = skyblock.getMessageManager(); + IslandManager islandManager = skyblock.getIslandManager(); FileManager fileManager = skyblock.getFileManager(); + SoundManager soundManager = skyblock.getSoundManager(); FileManager.Config language = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration languageLoad = language.getFileConfiguration(); PlayerData playerData = playerDataManager.getPlayerData(player); + + if (args.length < 1) { + toggleSpy(player, messageManager, languageLoad, playerData); + } else { + switch (args[0].toLowerCase()) { + case "toggle": + toggleSpy(player, messageManager, languageLoad, playerData); + break; + case "global": + if(!playerData.isGlobalChatSpy()){ + playerData.enableGlobalChatSpy(); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } + break; + case "add": + if(args.length > 2){ + Island island = islandManager.getIslandByPlayer(new OfflinePlayer(UUID.fromString(args[1])).getBukkitOfflinePlayer()); + if(island != null) { + playerData.addChatSpyIsland(island); + } + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } + break; + case "remove": + if(args.length > 2){ + Island island = islandManager.getIslandByPlayer(new OfflinePlayer(UUID.fromString(args[1])).getBukkitOfflinePlayer()); + if(island != null) { + playerData.removeChatSpyIsland(island); + } + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } + break; + case "list": + + break; + default: + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + break; + } + } + } + + private void toggleSpy(Player player, MessageManager messageManager, FileConfiguration languageLoad, PlayerData playerData) { if(playerData != null) { if(playerData.isChatSpy()){ playerData.setChatSpy(false); diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index 573a90d2..fb984512 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -95,7 +95,7 @@ public class Chat implements Listener { for(Player targetPlayer : Bukkit.getServer().getOnlinePlayers()){ if(targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) { PlayerData pd = playerDataManager.getPlayerData(targetPlayer); - if(pd != null && pd.isChatSpy()) { + if(pd != null && pd.isChatSpy() && (pd.isGlobalChatSpy() || pd.isChatSpyIsland(island))) { String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName()))) .replace("%islandOwner", new OfflinePlayer(island.getOwnerUUID()).getName()) diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 9490d12f..291e033d 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -5,6 +5,7 @@ import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.bank.Transaction; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.confirmation.Confirmation; +import com.songoda.skyblock.island.Island; import com.songoda.skyblock.menus.MenuType; import com.songoda.skyblock.utils.structure.Area; @@ -17,7 +18,8 @@ import java.io.IOException; import java.util.*; public class PlayerData { - + + private final SkyBlock skyblock; private UUID uuid; private UUID islandOwnerUUID; private UUID ownershipUUID; @@ -35,6 +37,7 @@ public class PlayerData { private Area area; private boolean chatSpy; + private Set spiedIslands; private boolean chat; private boolean preview; @@ -44,6 +47,8 @@ public class PlayerData { private List transactions; public PlayerData(Player player) { + this.skyblock = SkyBlock.getInstance(); + uuid = player.getUniqueId(); islandOwnerUUID = null; @@ -55,6 +60,12 @@ public class PlayerData { area = new Area(); chatSpy = getConfig().getFileConfiguration().getBoolean("ChatSpy", false); + + if (getConfig().getFileConfiguration().getString("ChatSpiedIslands") != null) { + for (String islandUUID : getConfig().getFileConfiguration().getStringList("ChatSpiedIslands")) { + spiedIslands.add(UUID.fromString(islandUUID)); + } + } chat = false; preview = false; @@ -270,7 +281,7 @@ public class PlayerData { } } - public void save() { + public synchronized void save() { transactions = BankManager.getInstance().getTransactionList(getPlayerUUID()); Config config = getConfig(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -288,6 +299,10 @@ public class PlayerData { }else { configLoad.set("Bank.Transactions.Size", 0); } + + configLoad.set("ChatSpy", chatSpy); + configLoad.set("ChatSpiedIslands", spiedIslands); + try { configLoad.save(config.getFile()); } catch (IOException e) { @@ -318,6 +333,41 @@ public class PlayerData { public void setChatSpy(boolean chatSpy) { this.chatSpy = chatSpy; - getConfig().getFileConfiguration().set("ChatSpy", chatSpy); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + } + + public void addChatSpyIsland(UUID uuid) { + spiedIslands.add(uuid); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + } + + public boolean isChatSpyIsland(UUID uuid) { + return spiedIslands.contains(uuid); + } + + public void removeChatSpyIsland(UUID uuid) { + spiedIslands.remove(uuid); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + } + + public void addChatSpyIsland(Island island) { + this.addChatSpyIsland(island.getOwnerUUID()); + } + + public boolean isChatSpyIsland(Island island) { + return this.isChatSpyIsland(island.getOwnerUUID()); + } + + public void removeChatSpyIsland(Island island) { + this.removeChatSpyIsland(island.getOwnerUUID()); + } + + public boolean isGlobalChatSpy() { + return spiedIslands.isEmpty(); + } + + public void enableGlobalChatSpy() { + spiedIslands.clear(); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); } } diff --git a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java index 9219e68e..5a26bf33 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java +++ b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java @@ -12,6 +12,7 @@ import java.util.UUID; public class OfflinePlayer { private UUID uuid; + org.bukkit.OfflinePlayer bukkitOfflinePlayer; private String name; private String memberSince; @@ -24,12 +25,11 @@ public class OfflinePlayer { public OfflinePlayer(String name) { SkyBlock skyblock = SkyBlock.getInstance(); UserCacheManager userCacheManager = skyblock.getUserCacheManager(); + + bukkitOfflinePlayer = Bukkit.getServer().getOfflinePlayer(name); - @SuppressWarnings("deprecation") - org.bukkit.OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(name); - - this.name = offlinePlayer.getName(); - this.uuid = offlinePlayer.getUniqueId(); + this.name = bukkitOfflinePlayer.getName(); + this.uuid = bukkitOfflinePlayer.getUniqueId(); if (this.uuid == null && userCacheManager.hasUser(name)) { this.uuid = userCacheManager.getUser(name); @@ -50,10 +50,10 @@ public class OfflinePlayer { public OfflinePlayer(UUID uuid) { SkyBlock skyblock = SkyBlock.getInstance(); UserCacheManager userCacheManager = skyblock.getUserCacheManager(); + + bukkitOfflinePlayer = Bukkit.getServer().getOfflinePlayer(uuid); - org.bukkit.OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(uuid); - - this.name = offlinePlayer.getName(); + this.name = bukkitOfflinePlayer.getName(); this.uuid = uuid; if (this.name == null && userCacheManager.hasUser(uuid)) { @@ -103,4 +103,8 @@ public class OfflinePlayer { public int getPlaytime() { return playtime; } + + public org.bukkit.OfflinePlayer getBukkitOfflinePlayer() { + return bukkitOfflinePlayer; + } } From 3b5bc25caaa18f6424e0b933021410f9a4c0e3c9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 5 Jul 2020 05:37:31 +0200 Subject: [PATCH 148/366] Added owner option check to generators --- .../com/songoda/skyblock/listeners/Block.java | 48 +++++++++++++------ src/main/resources/config.yml | 3 ++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 8d53e1fa..41e39c87 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -621,32 +621,50 @@ public class Block implements Listener { possiblePlayers.sort(Comparator.comparingDouble(a -> a.getLocation().distance(block.getLocation()))); } + boolean onlyOwner = config.getBoolean("Island.Generator.CheckOnlyOwnerPermissions", false); + double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation()); // Find highest generator available for (Generator generator : generators) { - for (Player player : possiblePlayers) { - if(player.getLocation().distance(block.getLocation()) > distance){ - break; + if(onlyOwner && skyblock.getVaultPermission() != null) { + OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); + if(skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || + skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || + skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { + if (applyGenerator(event, block, worldManager, islandLevelManager, island, state, generatorManager, generator)) + return; } - if (generator.isPermission()) { - if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) { - continue; + } else { + for (Player player : possiblePlayers) { + if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){ + break; } - } - - if(worldManager.getIslandWorld(event.getBlock().getWorld()).equals(generator.getIsWorld())){ - org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block); - state.setType(genState.getType()); - - if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) state.setData(genState.getData()); - islandLevelManager.updateLevel(island, genState.getLocation()); - return; + if (generator.isPermission()) { + if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) { + continue; + } + } + + if (applyGenerator(event, block, worldManager, islandLevelManager, island, state, generatorManager, generator)) + return; } } } } } + + private boolean applyGenerator(BlockFormEvent event, org.bukkit.block.Block block, WorldManager worldManager, IslandLevelManager islandLevelManager, Island island, BlockState state, GeneratorManager generatorManager, Generator generator) { + if(worldManager.getIslandWorld(event.getBlock().getWorld()).equals(generator.getIsWorld())){ + BlockState genState = generatorManager.generateBlock(generator, block); + state.setType(genState.getType()); + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) state.setData(genState.getData()); + islandLevelManager.updateLevel(island, genState.getLocation()); + return true; + } + return false; + } + @EventHandler public void onBlockBurn(BlockBurnEvent event) { org.bukkit.block.Block block = event.getBlock(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ba339c40..2bfe64fb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -319,6 +319,9 @@ Island: Enable: true Generator: Enable: true + # Check only the island owner's permissions + # it requires Vault installed + CheckOnlyOwnerPermissions: false # Check permissions of all the online player in the island or just # the nearest player to the generator CheckOnlyNearestPlayer: false From 14f211bd80149586ae95322933c624e72919a3a1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 5 Jul 2020 05:38:02 +0200 Subject: [PATCH 149/366] Added Vault perms dependency --- src/main/java/com/songoda/skyblock/SkyBlock.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 70e52f07..b64589fe 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -49,6 +49,7 @@ import com.songoda.skyblock.world.WorldManager; import com.songoda.skyblock.world.generator.VoidGenerator; import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtectAPI; +import net.milkbowl.vault.permission.Permission; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.event.HandlerList; @@ -94,7 +95,8 @@ public class SkyBlock extends SongodaPlugin { private PermissionManager permissionManager; private CoreProtectAPI coreProtectAPI; - + private Permission vaultPermission; + private boolean paper; private boolean paperAsync; @@ -222,7 +224,11 @@ public class SkyBlock extends SongodaPlugin { pluginManager.registerEvents(new Creator(), this); this.getCommand("skyblock").setExecutor(new SkyBlockCommand()); - + + if (pluginManager.isPluginEnabled("Vault")) { + this.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider(); + } + this.coreProtectAPI = loadCoreProtect(); SkyBlockAPI.setImplementation(INSTANCE); @@ -445,4 +451,8 @@ public class SkyBlock extends SongodaPlugin { public boolean isPaperAsync() { return paperAsync; } + + public Permission getVaultPermission() { + return vaultPermission; + } } From 05e7a0e2d523df076c57eea54fb4891950d08b66 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 5 Jul 2020 05:51:20 +0200 Subject: [PATCH 150/366] Added message for ChatSpy --- .../commands/admin/ChatSpyCommand.java | 37 ++++++++++++++----- .../skyblock/playerdata/PlayerData.java | 4 ++ src/main/resources/language.yml | 21 +++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java index a77f5521..6974a548 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java @@ -18,6 +18,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; +import java.util.Set; import java.util.UUID; public class ChatSpyCommand extends SubCommand { @@ -45,39 +46,57 @@ public class ChatSpyCommand extends SubCommand { case "global": if(!playerData.isGlobalChatSpy()){ playerData.enableGlobalChatSpy(); - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.GlobalEnabled.Message")); } else { - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.GlobalAlreadyEnabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); } break; case "add": if(args.length > 2){ - Island island = islandManager.getIslandByPlayer(new OfflinePlayer(UUID.fromString(args[1])).getBukkitOfflinePlayer()); + OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]); + Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer()); if(island != null) { playerData.addChatSpyIsland(island); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Add.Message")); + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.NullIsland.Message")); } } else { - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.InvalidArgNumber.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); } break; case "remove": if(args.length > 2){ - Island island = islandManager.getIslandByPlayer(new OfflinePlayer(UUID.fromString(args[1])).getBukkitOfflinePlayer()); + OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]); + Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer()); if(island != null) { playerData.removeChatSpyIsland(island); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Remove.Message")); + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.NullIsland.Message")); } } else { - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.InvalidArgNumber.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); } break; case "list": - + Set uuidSet = playerData.getChatSpyIslands(); + if(!uuidSet.isEmpty()){ + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.Start.Message")); + for(UUID uuid : uuidSet) { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.List.Message") + .replace("%owner", new OfflinePlayer(uuid).getName())); + } + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.End.Message")); + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.Empty.Message")); + } break; default: - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.Bank.Unexpected.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.InvalidArgNumber.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); break; } @@ -118,6 +137,6 @@ public class ChatSpyCommand extends SubCommand { @Override public String[] getArguments() { - return new String[0]; + return new String[]{"toggle", "global", "add", "remove", "list"}; } } diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 291e033d..c878f9cf 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -350,6 +350,10 @@ public class PlayerData { Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); } + public Set getChatSpyIslands() { + return new HashSet<>(spiedIslands); + } + public void addChatSpyIsland(Island island) { this.addChatSpyIsland(island.getOwnerUUID()); } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 6812a057..3c40d9cc 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -183,6 +183,27 @@ Command: Message: '&bSkyBlock &8| &aInfo&8: &eChat spy enabled.' Disabled: Message: '&bSkyBlock &8| &aInfo&8: &eChat spy disabled.' + GlobalEnabled: + Message: '&bSkyBlock &8| &aInfo&8: &eEnabled global chat spy.' + GlobalAlreadyEnabled: + Message: '&bSkyBlock &8| &cError&8: &eGlobal chat spy already enabled.' + Add: + Message: '&bSkyBlock &8| &aInfo&8: &eAdded %owner''s island to chat spy.' + Remove: + Message: '&bSkyBlock &8| &aInfo&8: &eRemoved %owner''s island to chat spy.' + NullIsland: + Message: '&bSkyBlock &8| &cError&8: &ePlayer does not have an island.' + InvalidArgNumber: + Message: '&bSkyBlock &8| &cError&8: &eInvalid arguments number.' + List: + Start: + Message: '&bSkyBlock &8| &aInfo&8: &eCurrently spied island''s chats:' + List: + Message: '&a- &e%owner' + End: + Message: '&a---------' + Empty: + Message: '&bSkyBlock &8| &aInfo&8: &eYou are not spying on any island''s chat. Global mode is enabled.' Reload: Info: Message: '&f&oReload all loaded files.' From 4448dd2a6f94387c1bf1fe960834ddb986b7f083 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 5 Jul 2020 10:35:41 +0200 Subject: [PATCH 151/366] Added Whitelist status with API --- .../api/event/island/IslandOpenEvent.java | 7 +- .../event/island/IslandStatusChangeEvent.java | 41 +++++ .../songoda/skyblock/api/island/Island.java | 9 +- .../skyblock/api/island/IslandStatus.java | 7 + .../songoda/skyblock/api/utils/APIUtil.java | 26 +++ .../command/commands/island/CloseCommand.java | 3 +- .../commands/island/ConfirmCommand.java | 7 +- .../command/commands/island/CoopCommand.java | 8 +- .../commands/island/KickAllCommand.java | 3 +- .../command/commands/island/KickCommand.java | 27 ++- .../command/commands/island/OpenCommand.java | 5 +- .../commands/island/PublicCommand.java | 30 ++-- .../commands/island/TeleportCommand.java | 14 +- .../command/commands/island/VoteCommand.java | 13 +- .../gui/permissions/GuiPermissions.java | 37 ++-- .../com/songoda/skyblock/island/Island.java | 55 ++++-- .../skyblock/island/IslandManager.java | 37 +++- .../songoda/skyblock/island/IslandStatus.java | 7 + .../com/songoda/skyblock/listeners/Move.java | 3 +- .../songoda/skyblock/listeners/Teleport.java | 5 +- .../songoda/skyblock/menus/ControlPanel.java | 14 +- .../songoda/skyblock/menus/Information.java | 3 +- .../com/songoda/skyblock/menus/Settings.java | 160 ++++++++++++------ .../com/songoda/skyblock/menus/Visit.java | 8 +- .../placeholder/PlaceholderManager.java | 3 +- .../playerdata/PlayerDataManager.java | 8 +- .../com/songoda/skyblock/visit/Visit.java | 25 +-- .../songoda/skyblock/visit/VisitManager.java | 13 +- src/main/resources/config.yml | 4 +- src/main/resources/language.yml | 18 +- 30 files changed, 427 insertions(+), 173 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/api/event/island/IslandStatusChangeEvent.java create mode 100644 src/main/java/com/songoda/skyblock/api/island/IslandStatus.java create mode 100644 src/main/java/com/songoda/skyblock/island/IslandStatus.java diff --git a/src/main/java/com/songoda/skyblock/api/event/island/IslandOpenEvent.java b/src/main/java/com/songoda/skyblock/api/event/island/IslandOpenEvent.java index 9af50890..5ff44b97 100644 --- a/src/main/java/com/songoda/skyblock/api/event/island/IslandOpenEvent.java +++ b/src/main/java/com/songoda/skyblock/api/event/island/IslandOpenEvent.java @@ -4,17 +4,20 @@ import com.songoda.skyblock.api.island.Island; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +@Deprecated public class IslandOpenEvent extends IslandEvent implements Cancellable { private static final HandlerList HANDLERS = new HandlerList(); private final boolean open; private boolean cancelled = false; - + + @Deprecated public IslandOpenEvent(Island island, boolean open) { super(island); this.open = open; } - + + @Deprecated public boolean isOpen() { return open; } diff --git a/src/main/java/com/songoda/skyblock/api/event/island/IslandStatusChangeEvent.java b/src/main/java/com/songoda/skyblock/api/event/island/IslandStatusChangeEvent.java new file mode 100644 index 00000000..cc60daed --- /dev/null +++ b/src/main/java/com/songoda/skyblock/api/event/island/IslandStatusChangeEvent.java @@ -0,0 +1,41 @@ +package com.songoda.skyblock.api.event.island; + +import com.songoda.skyblock.api.island.Island; +import com.songoda.skyblock.api.island.IslandStatus; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +public class IslandStatusChangeEvent extends IslandEvent implements Cancellable { + + private static final HandlerList HANDLERS = new HandlerList(); + private final IslandStatus status; + private boolean cancelled = false; + + public IslandStatusChangeEvent(Island island, IslandStatus status) { + super(island); + this.status = status; + } + + public IslandStatus getStatus() { + return status; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @Override + public HandlerList getHandlers() { + return HANDLERS; + } + + public HandlerList getHandlerList() { + return HANDLERS; + } +} diff --git a/src/main/java/com/songoda/skyblock/api/island/Island.java b/src/main/java/com/songoda/skyblock/api/island/Island.java index 2173931c..67323db3 100644 --- a/src/main/java/com/songoda/skyblock/api/island/Island.java +++ b/src/main/java/com/songoda/skyblock/api/island/Island.java @@ -7,6 +7,7 @@ import com.songoda.skyblock.api.utils.APIUtil; import com.songoda.skyblock.api.visit.Visit; import com.songoda.skyblock.island.IslandCoop; import com.songoda.skyblock.island.IslandPermission; +import com.songoda.skyblock.island.IslandStatus; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.WeatherType; @@ -372,12 +373,14 @@ public class Island { /** * @return true of conditions met, false otherwise */ + @Deprecated public boolean isOpen() { - return handle.isOpen(); + return handle.getStatus().equals(IslandStatus.OPEN); } - + + @Deprecated public void setOpen(boolean open) { - this.handle.setOpen(open); + this.handle.setStatus(open ? IslandStatus.OPEN : IslandStatus.CLOSED); } /** diff --git a/src/main/java/com/songoda/skyblock/api/island/IslandStatus.java b/src/main/java/com/songoda/skyblock/api/island/IslandStatus.java new file mode 100644 index 00000000..ebc78b32 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/api/island/IslandStatus.java @@ -0,0 +1,7 @@ +package com.songoda.skyblock.api.island; + +public enum IslandStatus { + OPEN, + CLOSED, + WHITELISTED +} diff --git a/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java b/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java index a1136354..dd4106cb 100644 --- a/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java +++ b/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java @@ -57,6 +57,32 @@ public final class APIUtil { return null; } + + public static com.songoda.skyblock.island.IslandStatus toImplementation(IslandStatus status) { + switch (status) { + case OPEN: + return com.songoda.skyblock.island.IslandStatus.OPEN; + case CLOSED: + return com.songoda.skyblock.island.IslandStatus.CLOSED; + case WHITELISTED: + return com.songoda.skyblock.island.IslandStatus.WHITELISTED; + } + + return null; + } + + public static IslandStatus fromImplementation(com.songoda.skyblock.island.IslandStatus status) { + switch (status) { + case OPEN: + return IslandStatus.OPEN; + case CLOSED: + return IslandStatus.CLOSED; + case WHITELISTED: + return IslandStatus.WHITELISTED; + } + + return null; + } public static com.songoda.skyblock.island.IslandRole toImplementation(IslandRole role) { switch (role) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java index 117e1bd8..cb4cfd28 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java @@ -6,6 +6,7 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.command.ConsoleCommandSender; @@ -33,7 +34,7 @@ public class CloseCommand extends SubCommand { } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) && skyblock.getPermissionManager().hasPermission(island,"Visitor", IslandRole.Operator))) { - if (island.isOpen()) { + if (island.getStatus().equals(IslandStatus.OPEN) || island.getStatus().equals(IslandStatus.WHITELISTED)) { islandManager.closeIsland(island); messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Closed.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java index 1d11a8c8..c92b0c2a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java @@ -10,6 +10,7 @@ import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; @@ -106,11 +107,11 @@ public class ConfirmCommand extends SubCommand { .getString("Command.Island.Confirmation.Ownership.Member.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } - } else if (confirmation == Confirmation.Reset) { + } else if (confirmation.equals(Confirmation.Reset)) { playerData.setConfirmation(null); playerData.setConfirmationTime(0); - } else if (confirmation == Confirmation.Deletion) { - if (island.isOpen()) { + } else if (confirmation.equals(Confirmation.Deletion)) { + if (island.getStatus().equals(IslandStatus.OPEN)) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Deletion.Open.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java index a93e36dc..5ae35b0a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java @@ -4,10 +4,7 @@ import com.songoda.core.compatibility.CompatibleSound; 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.IslandCoop; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.*; import com.songoda.skyblock.menus.Coop; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.PermissionManager; @@ -85,7 +82,8 @@ public class CoopCommand extends SubCommand { } else if (island.isCoopPlayer(targetPlayerUUID)) { if (targetPlayer != null) { if (islandManager.getVisitorsAtIsland(island).contains(targetPlayerUUID)) { - if (!island.isOpen()) { + if (!(island.getStatus().equals(IslandStatus.OPEN) || + (island.getStatus().equals(IslandStatus.WHITELISTED) && island.isPlayerWhitelisted(player)))) { LocationUtil.teleportPlayerToSpawn(targetPlayer); messageManager.sendMessage(targetPlayer, 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 e0f8d686..804dc59e 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 @@ -8,6 +8,7 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.world.LocationUtil; @@ -39,7 +40,7 @@ public class KickAllCommand extends SubCommand { } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) && skyblock.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator))) { - if (island.isOpen()) { + if (!island.getStatus().equals(IslandStatus.CLOSED)) { Set islandVisitors = islandManager.getVisitorsAtIsland(island); if (islandVisitors.size() == 0) { 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 ee2be148..924810a1 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 @@ -6,6 +6,7 @@ import java.util.Set; import java.util.UUID; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.permission.PermissionManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -84,7 +85,7 @@ public class KickCommand extends SubCommand { } else if (island.getOwnerUUID().equals(targetPlayerUUID)) { messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID)) { + } else if (!island.getStatus().equals(IslandStatus.CLOSED) && islandVisitors.contains(targetPlayerUUID)) { if (island.isCoopPlayer(targetPlayerUUID)) { messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -205,19 +206,27 @@ public class KickCommand extends SubCommand { } } } else { - if (island.isOpen()) { - messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Open.Message")); - } else { - messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Closed.Message")); + switch (island.getStatus()){ + case OPEN: + case WHITELISTED: + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Open.Message")); + break; + case CLOSED: + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Closed.Message")); + break; } soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } } else { - if (island.isOpen()) { - messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Open.Message")); - } else { - messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Closed.Message")); + switch (island.getStatus()){ + case OPEN: + case WHITELISTED: + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Open.Message")); + break; + case CLOSED: + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Closed.Message")); + break; } soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java index 9e7fef50..ea7ae61d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java @@ -6,6 +6,7 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.sound.SoundManager; @@ -35,11 +36,11 @@ public class OpenCommand extends SubCommand { } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Visitor", IslandRole.Operator))) { - if (island.isOpen()) { + if (island.getStatus().equals(IslandStatus.OPEN)) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Already.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { - island.setOpen(true); + island.setStatus(IslandStatus.OPEN); messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Opened.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java index 3cf701fa..61ae2c0a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java @@ -6,6 +6,7 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.command.ConsoleCommandSender; @@ -33,16 +34,25 @@ public class PublicCommand extends SubCommand { } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) && skyblock.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) { - if (island.isOpen()) { - islandManager.closeIsland(island); - - messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Private.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); - } else { - island.setOpen(true); - - messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Public.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + switch (island.getStatus()) { + case OPEN: + islandManager.whitelistIsland(island); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Restricted.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; + case CLOSED: + islandManager.closeIsland(island); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Private.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; + case WHITELISTED: + island.setStatus(IslandStatus.OPEN); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Public.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + break; } } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Permission.Message")); 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 d5f6af4c..88ccc533 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 @@ -3,10 +3,7 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandEnvironment; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandWorld; +import com.songoda.skyblock.island.*; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; @@ -68,12 +65,17 @@ public class TeleportCommand extends SubCommand { if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isCoopPlayer(player.getUniqueId())) { isCoopPlayer = true; } - if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isPlayerWhitelisted(player.getUniqueId())) { + if (visit.getStatus().equals(IslandStatus.WHITELISTED) && islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isPlayerWhitelisted(player.getUniqueId())) { isWhitelistedPlayer = true; } } - if (isCoopPlayer || isWhitelistedPlayer || player.hasPermission("fabledskyblock.bypass") || player.hasPermission("fabledskyblock.bypass.*") || player.hasPermission("fabledskyblock.*") || visit.isOpen()) { + if (visit.getStatus().equals(IslandStatus.OPEN) || + isCoopPlayer || + isWhitelistedPlayer || + player.hasPermission("fabledskyblock.bypass") || + player.hasPermission("fabledskyblock.bypass.*") || + player.hasPermission("fabledskyblock.*")) { if (!islandManager.containsIsland(islandOwnerUUID)) { islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java index f2ac88a0..19fea256 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java @@ -9,6 +9,7 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; @@ -68,13 +69,13 @@ public class VoteCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { Visit visit = visitManager.getIsland(islandOwnerUUID); + if (!islandManager.containsIsland(islandOwnerUUID)) { + islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); + } + + Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); - if (visit.isOpen()) { - if (!islandManager.containsIsland(islandOwnerUUID)) { - islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); - } - - Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); + if (visit.getStatus().equals(IslandStatus.OPEN)) { if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java index 55c499dc..3a5825dd 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java @@ -12,6 +12,7 @@ import com.songoda.skyblock.gui.GuiWelcomeEditor; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandPermission; import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.permission.BasicPermission; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.permission.PermissionType; @@ -78,10 +79,19 @@ public class GuiPermissions extends Gui { } Visit visit = island.getVisit(); - List welcomeLore = TextUtils.formatText(configLoad.getStringList( - island.isOpen() - ? "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Closed.Lore" - : "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Open.Lore")); + String configAddress = ""; + switch (island.getStatus()) { + case OPEN: + configAddress = "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Open.Lore"; + break; + case CLOSED: + configAddress = "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Closed.Lore"; + break; + case WHITELISTED: + configAddress = "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Whitelisted.Lore"; + break; + } + List welcomeLore = TextUtils.formatText(configLoad.getStringList(configAddress)); List welcomeFinal = new ArrayList<>(); @@ -95,12 +105,19 @@ public class GuiPermissions extends Gui { TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname")), welcomeFinal), (event -> { - if (island.isOpen()) { - plugin.getIslandManager().closeIsland(island); - soundManager.playSound(event.player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1f, 1f); - } else { - island.setOpen(true); - soundManager.playSound(event.player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1f, 1f); + switch (island.getStatus()) { + case OPEN: + plugin.getIslandManager().whitelistIsland(island); + soundManager.playSound(event.player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1f, 1f); + break; + case CLOSED: + plugin.getIslandManager().closeIsland(island); + soundManager.playSound(event.player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1f, 1f); + break; + case WHITELISTED: + island.setStatus(IslandStatus.OPEN); + soundManager.playSound(event.player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1f, 1f); + break; } paint(); })); diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 30aceaed..91868415 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -45,6 +45,7 @@ public class Island { private UUID islandUUID; private UUID ownerUUID; private IslandLevel level; + private IslandStatus status; private int size; private int maxMembers; private boolean deleted = false; @@ -193,11 +194,33 @@ public class Island { whitelistedPlayers.add(UUID.fromString(whitelistedUUID)); } } + + if(configLoad.getString("Visitor.Open", null).equalsIgnoreCase("true") || + configLoad.getString("Visitor.Open", null).equalsIgnoreCase("false")) { + if(configLoad.getBoolean("Visitor.Open")) { + status = IslandStatus.OPEN; + } else { + status = IslandStatus.CLOSED; + } + configLoad.set("Visitor.Open", null); + } else { + IslandStatus status = IslandStatus.valueOf(configLoad.getString("Visitor.Status")); + switch (status){ + case OPEN: + case CLOSED: + case WHITELISTED: + this.status = status; + break; + default: + this.status = IslandStatus.WHITELISTED; + break; + } + } } else { FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("UUID", islandUUID.toString()); - configLoad.set("Visitor.Open", mainConfigLoad.getBoolean("Island.Visitor.Open")); + configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status")); 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()); @@ -742,22 +765,24 @@ public class Island { public void removeFromBank(double value) { addToBank(-value); } - - public boolean isOpen() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) - .getFileConfiguration().getBoolean("Visitor.Open"); + + public IslandStatus getStatus() { + return this.status; } - - public void setOpen(boolean open) { - IslandOpenEvent islandOpenEvent = new IslandOpenEvent(getAPIWrapper(), open); + + public void setStatus(IslandStatus status) { + IslandOpenEvent islandOpenEvent = new IslandOpenEvent(getAPIWrapper(), status.equals(IslandStatus.OPEN)); Bukkit.getServer().getPluginManager().callEvent(islandOpenEvent); - - if (!islandOpenEvent.isCancelled()) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) - .getFileConfiguration().set("Visitor.Open", open); - getVisit().setOpen(open); + if(islandOpenEvent.isCancelled()) { + return; + } + + IslandStatusChangeEvent islandStatusChangeEvent = new IslandStatusChangeEvent(getAPIWrapper(), APIUtil.fromImplementation(status)); + Bukkit.getServer().getPluginManager().callEvent(islandStatusChangeEvent); + if(!islandStatusChangeEvent.isCancelled()) { + this.status = status; + getVisit().setStatus(status); + // TODO Save to config } } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index a631ab50..b979d027 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -239,7 +239,7 @@ public class IslandManager { new IslandLocation[]{island.getIslandLocation(IslandWorld.Normal, IslandEnvironment.Island), island.getIslandLocation(IslandWorld.Nether, IslandEnvironment.Island), island.getIslandLocation(IslandWorld.End, IslandEnvironment.Island)}, island.getSize(), island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1, island.getBankBalance(), visitManager.getIslandSafeLevel(island.getOwnerUUID()), island.getLevel(), - island.getMessage(IslandMessage.Signature), island.isOpen()); + island.getMessage(IslandMessage.Signature), island.getStatus()); } if (!banManager.hasIsland(island.getOwnerUUID())) banManager.createIsland(island.getOwnerUUID()); @@ -743,7 +743,7 @@ public class IslandManager { new IslandLocation[]{island.getIslandLocation(IslandWorld.Normal, IslandEnvironment.Island), island.getIslandLocation(IslandWorld.Nether, IslandEnvironment.Island), island.getIslandLocation(IslandWorld.End, IslandEnvironment.Island)}, island.getSize(), island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1, island.getBankBalance(), visitManager.getIslandSafeLevel(island.getOwnerUUID()), - island.getLevel(), island.getMessage(IslandMessage.Signature), island.isOpen()); + island.getLevel(), island.getMessage(IslandMessage.Signature), island.getStatus()); } if (!banManager.hasIsland(island.getOwnerUUID())) { @@ -900,7 +900,7 @@ public class IslandManager { int nonIslandMembers = islandVisitors - getCoopPlayersAtIsland(island).size(); if (nonIslandMembers <= 0) { - if (island.isOpen()) { + if (island.getStatus().equals(IslandStatus.OPEN)) { return; } else if (player != null) { removeCoopPlayers(island, player.getUniqueId()); @@ -1177,7 +1177,7 @@ public class IslandManager { Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - island.setOpen(false); + island.setStatus(IslandStatus.CLOSED); UUID islandOwnerUUID = island.getOwnerUUID(); Player islandOwnerPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID); @@ -1190,13 +1190,40 @@ public class IslandManager { } for (UUID visitor : getVisitorsAtIsland(island)) { - if (!island.isCoopPlayer(visitor) && !island.isPlayerWhitelisted(visitor)) { + if (!island.isCoopPlayer(visitor)) { Player targetPlayer = Bukkit.getServer().getPlayer(visitor); LocationUtil.teleportPlayerToSpawn(targetPlayer); messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", islandOwnerPlayerName)); } } } + + public void whitelistIsland(Island island) { + MessageManager messageManager = skyblock.getMessageManager(); + + Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + island.setStatus(IslandStatus.WHITELISTED); + + UUID islandOwnerUUID = island.getOwnerUUID(); + Player islandOwnerPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID); + String islandOwnerPlayerName; + + if (islandOwnerPlayer == null) { + islandOwnerPlayerName = new OfflinePlayer(islandOwnerUUID).getName(); + } else { + islandOwnerPlayerName = islandOwnerPlayer.getName(); + } + + for (UUID visitor : getVisitorsAtIsland(island)) { + if (!island.isCoopPlayer(visitor) && !island.isPlayerWhitelisted(visitor)) { + Player targetPlayer = Bukkit.getServer().getPlayer(visitor); + LocationUtil.teleportPlayerToSpawn(targetPlayer); + messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Whitelisted.Island.Message").replace("%player", islandOwnerPlayerName)); // TODO + } + } + } public Island getIsland(org.bukkit.OfflinePlayer offlinePlayer) { PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); diff --git a/src/main/java/com/songoda/skyblock/island/IslandStatus.java b/src/main/java/com/songoda/skyblock/island/IslandStatus.java new file mode 100644 index 00000000..f45f3d59 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/island/IslandStatus.java @@ -0,0 +1,7 @@ +package com.songoda.skyblock.island; + +public enum IslandStatus { + OPEN, + CLOSED, + WHITELISTED +} diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 682ae6d0..d568f5d8 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -179,7 +179,8 @@ public class Move implements Listener { return; } - if(loadedIsland.isOpen() || loadedIsland.isPlayerWhitelisted(player)){ + if(loadedIsland.getStatus().equals(IslandStatus.OPEN) || + (loadedIsland.getStatus().equals(IslandStatus.WHITELISTED) && loadedIsland.isPlayerWhitelisted(player))){ loadedIsland.getVisit().addVisitor(player.getUniqueId()); return; } diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index faac4882..16073290 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -10,6 +10,7 @@ import com.songoda.skyblock.api.island.Island; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; @@ -98,7 +99,9 @@ public class Teleport implements Listener { if (island != null) { if (!island.getOwnerUUID().equals(playerData.getOwner())) { if (!player.hasPermission("fabledskyblock.bypass") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) { - if (!island.isOpen() && !island.isCoopPlayer(player.getUniqueId()) && !island.isPlayerWhitelisted(player)) { + if (!island.getStatus().equals(IslandStatus.OPEN) && + !island.isCoopPlayer(player.getUniqueId()) && + !(island.getStatus().equals(IslandStatus.WHITELISTED) && island.isPlayerWhitelisted(player))) { event.setCancelled(true); messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Plugin.Message")); diff --git a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java index 9af4c2e4..db91e5f0 100644 --- a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java +++ b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java @@ -39,10 +39,16 @@ public final class ControlPanel { final Island island = SkyBlock.getInstance().getIslandManager().getIsland((Player) player); - if (island.isOpen()) { - Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island close"), 1L); - } else { - Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island open"), 1L); + switch (island.getStatus()) { + case OPEN: + Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island whitelist on"), 1L); + break; + case CLOSED: + Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island open"), 1L); + break; + case WHITELISTED: + Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island close"), 1L); + break; } }); diff --git a/src/main/java/com/songoda/skyblock/menus/Information.java b/src/main/java/com/songoda/skyblock/menus/Information.java index 102ec961..bdb31da7 100644 --- a/src/main/java/com/songoda/skyblock/menus/Information.java +++ b/src/main/java/com/songoda/skyblock/menus/Information.java @@ -8,6 +8,7 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; @@ -76,7 +77,7 @@ public class Information { } if (viewer.getType() == Information.Viewer.Type.Visitors) { - if (island.isOpen()) { + if (!island.getStatus().equals(IslandStatus.CLOSED)) { if (islandManager.getVisitorsAtIsland(island).size() == 0) { messageManager.sendMessage(player, configLoad.getString("Island.Information.Visitors.Message")); diff --git a/src/main/java/com/songoda/skyblock/menus/Settings.java b/src/main/java/com/songoda/skyblock/menus/Settings.java index 79772e7a..274a0292 100644 --- a/src/main/java/com/songoda/skyblock/menus/Settings.java +++ b/src/main/java/com/songoda/skyblock/menus/Settings.java @@ -286,12 +286,19 @@ public class Settings { } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta() .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Settings.Visitor.Item.Statistics.Displayname"))))) { - if (island14.isOpen()) { - islandManager.closeIsland(island14); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); - } else { - island14.setOpen(true); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + switch (island14.getStatus()) { + case OPEN: + islandManager.whitelistIsland(island14); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; + case CLOSED: + island14.setStatus(IslandStatus.OPEN); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + break; + case WHITELISTED: + islandManager.closeIsland(island14); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; } Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); @@ -349,46 +356,73 @@ public class Settings { } if (config.getFileConfiguration().getBoolean("Island.Visitor.Vote")) { - if (visit.isOpen()) { - nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), - configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), - configLoad.getStringList( - "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Open.Lore"), - new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), - new Placeholder("%votes", "" + visit.getVoters().size()), - new Placeholder("%visitors", - "" + islandManager.getVisitorsAtIsland(island).size())}, - null, null), 4); - } else { - nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), - configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), - configLoad.getStringList( - "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Closed.Lore"), - new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), - new Placeholder("%votes", "" + visit.getVoters().size()), - new Placeholder("%visitors", - "" + islandManager.getVisitorsAtIsland(island).size())}, - null, null), 4); + switch (visit.getStatus()){ + case OPEN: + nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), + configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), + configLoad.getStringList( + "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Open.Lore"), + new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), + new Placeholder("%votes", "" + visit.getVoters().size()), + new Placeholder("%visitors", + "" + islandManager.getVisitorsAtIsland(island).size())}, + null, null), 4); + break; + case CLOSED: + nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), + configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), + configLoad.getStringList( + "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Closed.Lore"), + new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), + new Placeholder("%votes", "" + visit.getVoters().size()), + new Placeholder("%visitors", + "" + islandManager.getVisitorsAtIsland(island).size())}, + null, null), 4); + break; + case WHITELISTED: + nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), + configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), + configLoad.getStringList( + "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Whitelisted.Lore"), + new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), + new Placeholder("%votes", "" + visit.getVoters().size()), + new Placeholder("%visitors", + "" + islandManager.getVisitorsAtIsland(island).size())}, + null, null), 4); + break; } } else { - if (visit.isOpen()) { - nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), - configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), - configLoad.getStringList( - "Menu.Settings.Visitor.Item.Statistics.Vote.Disabled.Open.Lore"), - new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), - new Placeholder("%visitors", - "" + islandManager.getVisitorsAtIsland(island).size())}, - null, null), 4); - } else { - nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), - configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), - configLoad.getStringList( - "Menu.Settings.Visitor.Item.Statistics.Vote.Disabled.Closed.Lore"), - new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), - new Placeholder("%visitors", - "" + islandManager.getVisitorsAtIsland(island).size())}, - null, null), 4); + switch (visit.getStatus()){ + case OPEN: + nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), + configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), + configLoad.getStringList( + "Menu.Settings.Visitor.Item.Statistics.Vote.Disabled.Open.Lore"), + new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), + new Placeholder("%visitors", + "" + islandManager.getVisitorsAtIsland(island).size())}, + null, null), 4); + break; + case CLOSED: + nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), + configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), + configLoad.getStringList( + "Menu.Settings.Visitor.Item.Statistics.Vote.Disabled.Closed.Lore"), + new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), + new Placeholder("%visitors", + "" + islandManager.getVisitorsAtIsland(island).size())}, + null, null), 4); + break; + case WHITELISTED: + nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), + configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"), + configLoad.getStringList( + "Menu.Settings.Visitor.Item.Statistics.Vote.Whitelisted.Closed.Lore"), + new Placeholder[]{new Placeholder("%visits", "" + visit.getVisitors().size()), + new Placeholder("%visitors", + "" + islandManager.getVisitorsAtIsland(island).size())}, + null, null), 4); + break; } } @@ -1049,12 +1083,19 @@ public class Settings { && (is.getItemMeta().getDisplayName().equals( ChatColor.translateAlternateColorCodes('&', configLoad.getString( "Menu.Settings.Visitor.Item.Statistics.Displayname"))))) { - if (island15.isOpen()) { - islandManager.closeIsland(island15); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); - } else { - island15.setOpen(true); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + switch (island15.getStatus()) { + case OPEN: + islandManager.whitelistIsland(island15); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; + case CLOSED: + island15.setStatus(IslandStatus.OPEN); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + break; + case WHITELISTED: + islandManager.closeIsland(island15); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; } Bukkit.getServer().getScheduler().runTaskLater(skyblock, @@ -1300,12 +1341,19 @@ public class Settings { && (is.getItemMeta().getDisplayName().equals( ChatColor.translateAlternateColorCodes('&', configLoad.getString( "Menu.Settings.Visitor.Item.Statistics.Displayname"))))) { - if (island12.isOpen()) { - islandManager.closeIsland(island12); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); - } else { - island12.setOpen(true); - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + switch (island12.getStatus()) { + case OPEN: + islandManager.whitelistIsland(island12); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; + case CLOSED: + island12.setStatus(IslandStatus.OPEN); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); + break; + case WHITELISTED: + islandManager.closeIsland(island12); + soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); + break; } Bukkit.getServer().getScheduler().runTaskLater(skyblock, diff --git a/src/main/java/com/songoda/skyblock/menus/Visit.java b/src/main/java/com/songoda/skyblock/menus/Visit.java index 9cdc4a9a..38c681f7 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visit.java +++ b/src/main/java/com/songoda/skyblock/menus/Visit.java @@ -9,6 +9,7 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerData; @@ -153,14 +154,15 @@ public class Visit { if (islandManager.getIsland(offlinePlayer).isCoopPlayer(player.getUniqueId())) { isCoopPlayer = true; } - if (islandManager.getIsland(offlinePlayer).isPlayerWhitelisted(player.getUniqueId())) { + if (visit.getStatus().equals(IslandStatus.WHITELISTED) && + islandManager.getIsland(offlinePlayer).isPlayerWhitelisted(player.getUniqueId())) { isWhitelistedPlayer = true; } } - if (isCoopPlayer || isWhitelistedPlayer || player.hasPermission("fabledskyblock.bypass") + if (visit.getStatus().equals(IslandStatus.OPEN) || isCoopPlayer || isWhitelistedPlayer || player.hasPermission("fabledskyblock.bypass") || player.hasPermission("fabledskyblock.bypass.*") - || player.hasPermission("fabledskyblock.*") || visit.isOpen()) { + || player.hasPermission("fabledskyblock.*")) { if (!islandManager.containsIsland(targetPlayerUUID)) { islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID)); } diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java index 23a84e63..84f4e00c 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.UUID; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.island.IslandStatus; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; @@ -90,7 +91,7 @@ public class PlaceholderManager { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_isopen.Empty.Message")); } else { - if (island.isOpen()) { + if (island.getStatus().equals(IslandStatus.OPEN)) { // TODO Update to Status return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_isopen.Open.Message")); } else { diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index 7ab1079f..7e3b5c29 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -171,8 +171,8 @@ public class PlayerDataManager { islandManager.updateFlight(player); return; - } else if (island.isOpen() || island.isCoopPlayer(player.getUniqueId())) { - if (!island.isOpen() && island.isCoopPlayer(player.getUniqueId())) { + } else if (!island.getStatus().equals(IslandStatus.CLOSED) || island.isCoopPlayer(player.getUniqueId())) { + if (island.getStatus().equals(IslandStatus.CLOSED) && island.isCoopPlayer(player.getUniqueId())) { if (islandManager.removeCoopPlayers(island, null)) { return; } @@ -253,8 +253,8 @@ public class PlayerDataManager { island = islandManager.getIsland(offlinePlayer); if (island != null) { - if (island.isOpen() || island.isCoopPlayer(player.getUniqueId())) { - if (!island.isOpen() && island.isCoopPlayer(player.getUniqueId())) { + if (!island.getStatus().equals(IslandStatus.CLOSED) || island.isCoopPlayer(player.getUniqueId())) { + if (island.getStatus().equals(IslandStatus.CLOSED) && island.isCoopPlayer(player.getUniqueId())) { if (islandManager.removeCoopPlayers(island, null)) { islandManager.unloadIsland(island, Bukkit.getServer().getOfflinePlayer(visitIslandList)); diff --git a/src/main/java/com/songoda/skyblock/visit/Visit.java b/src/main/java/com/songoda/skyblock/visit/Visit.java index be6facca..958f17f0 100644 --- a/src/main/java/com/songoda/skyblock/visit/Visit.java +++ b/src/main/java/com/songoda/skyblock/visit/Visit.java @@ -5,6 +5,7 @@ import com.songoda.skyblock.ban.Ban; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandLocation; +import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.island.IslandWorld; import org.bukkit.configuration.file.FileConfiguration; @@ -24,11 +25,11 @@ public class Visit { private int safeLevel; private double islandBankBalance; private List islandSignature; - - private boolean open; + + private IslandStatus status; protected Visit(SkyBlock skyblock, UUID islandOwnerUUID, IslandLocation[] islandLocations, int islandSize, - int islandMembers, double islandBankBalance, int safeLevel, IslandLevel islandLevel, List islandSignature, boolean open) { + int islandMembers, double islandBankBalance, int safeLevel, IslandLevel islandLevel, List islandSignature, IslandStatus status) { this.skyblock = skyblock; this.islandOwnerUUID = islandOwnerUUID; this.islandLocations = islandLocations; @@ -38,7 +39,7 @@ public class Visit { this.safeLevel = safeLevel; this.islandLevel = islandLevel; this.islandSignature = islandSignature; - this.open = open; + this.status = status; } public UUID getOwnerUUID() { @@ -203,14 +204,6 @@ public class Visit { this.islandSignature = islandSignature; } - public boolean isOpen() { - return open; - } - - public void setOpen(boolean open) { - this.open = open; - } - public Ban getBan() { return skyblock.getBanManager().getIsland(getOwnerUUID()); } @@ -225,4 +218,12 @@ public class Visit { e.printStackTrace(); } } + + public IslandStatus getStatus() { + return status; + } + + public void setStatus(IslandStatus status) { + this.status = status; + } } diff --git a/src/main/java/com/songoda/skyblock/visit/VisitManager.java b/src/main/java/com/songoda/skyblock/visit/VisitManager.java index 7e8fc311..c8ec9698 100644 --- a/src/main/java/com/songoda/skyblock/visit/VisitManager.java +++ b/src/main/java/com/songoda/skyblock/visit/VisitManager.java @@ -3,10 +3,7 @@ package com.songoda.skyblock.visit; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandLevel; -import com.songoda.skyblock.island.IslandLocation; -import com.songoda.skyblock.island.IslandWorld; +import com.songoda.skyblock.island.*; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.world.LocationUtil; @@ -92,7 +89,7 @@ public class VisitManager { + configLoad.getStringList("Operators").size() + 1, configLoad.getDouble("Bank.Balance", 0), getIslandSafeLevel(islandOwnerUUID), new IslandLevel(islandOwnerUUID, skyblock), - islandSignature, configLoad.getBoolean("Visitor.Open")); + islandSignature, IslandStatus.valueOf(configLoad.getString("Visitor.Status"))); } catch (Exception e) { e.printStackTrace(); } @@ -190,7 +187,7 @@ public class VisitManager { UUID islandOwnerUUID = it.next(); Visit visit = visitIslands.get(islandOwnerUUID); - if (!visit.isOpen()) { + if (!visit.getStatus().equals(IslandStatus.OPEN)) { visitIslands.remove(islandOwnerUUID); } } @@ -199,9 +196,9 @@ public class VisitManager { } public void createIsland(UUID islandOwnerUUID, IslandLocation[] islandLocations, int islandSize, int islandMembers, - double islandBankBalance, int safeLevel, IslandLevel islandLevel, List islandSignature, boolean open) { + double islandBankBalance, int safeLevel, IslandLevel islandLevel, List islandSignature, IslandStatus status) { visitStorage.put(islandOwnerUUID, new Visit(skyblock, islandOwnerUUID, islandLocations, islandSize, - islandMembers, islandBankBalance, safeLevel, islandLevel, islandSignature, open)); + islandMembers, islandBankBalance, safeLevel, islandLevel, islandSignature, status)); } public void addIsland(UUID islandOwnerUUID, Visit visit) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2bfe64fb..5f4ac7da 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -145,8 +145,8 @@ Island: # even if it's open. # [!] Enabling will prevent possible memory leak issues affecting performance. Unload: false - # Upon Island creation is the Island open to visit? - Open: false + # The island status upon island creation (Open, Closed, Whitelisted) + Status: Whitelisted # Allow players to vote for Islands. This will filter Islands with more votes first # in the Visit Island menu. Vote: true diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 3c40d9cc..b698876f 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1039,6 +1039,8 @@ Command: Message: '&bSkyBlock &8| &aInfo&8: &eYour Island is now &cPrivate&e.' Public: Message: '&bSkyBlock &8| &aInfo&8: &eYour Island is now &aPublic&e.' + Restricted: + Message: '&bSkyBlock &8| &aInfo&8: &eYour Island is now &eRestricted&e.' Leaderboard: Disabled: Message: '&bSkyBlock &8| &cError&8: &eYou cannot view that leaderboard because it has been disabled.' @@ -1362,13 +1364,19 @@ Menu: - '' - '&7Current Visitors&8: &a%visitors' - '' - - '&eClick to close Island!' + - '&eClick to enable Whitelist!' Closed: Lore: - '&7Island Visits&8: &e%visitors' - '&7Island Votes&8: &e%votes' - '' - '&aClick to open Island!' + Whitelisted: + Lore: + - '&7Island Visits&8: &e%visitors' + - '&7Island Votes&8: &e%votes' + - '' + - '&aClick to close Island!' Disabled: Closed: Lore: @@ -1381,7 +1389,13 @@ Menu: - '' - '&7Current Visitors&8: &a%visitors' - '' - - '&eClick to close Island!' + - '&eClick to enable Whitelist!' + Whitelisted: + Lore: + - '&7Island Visits&8: &e%visitors' + - '&7Island Votes&8: &e%votes' + - '' + - '&aClick to close Island!' Displayname: '&aIsland Visit Statistics' Signature: Displayname: '&bIsland Signature' From 619781eff9cf72acba446ae2dc25cc67ecadb083 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 6 Jul 2020 08:37:25 +0200 Subject: [PATCH 152/366] Fixed npe in BiomeIcon --- src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java index ca793778..05edc6a8 100644 --- a/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java @@ -32,7 +32,11 @@ public class BiomeIcon { } byte tempData = (byte) biomeConfig.getInt("Biomes." + biome.name() + ".DisplayItem.Data", 0); - this.displayItem = CompatibleMaterial.getMaterial(tempMat.getMaterial(), tempData).getItem(); + CompatibleMaterial displayMaterial = CompatibleMaterial.getMaterial(tempMat.getMaterial(), tempData); + if(displayMaterial == null) { + displayMaterial = CompatibleMaterial.STONE; + } + this.displayItem = displayMaterial.getItem(); ItemMeta im = displayItem.getItemMeta(); if(im != null){ im.setDisplayName(ChatColor.translateAlternateColorCodes('&', biomeConfig.getString("Biomes." + biome.name() + ".DisplayName", biome.name()))); From a434837aa145b7308ca7368f711fe945cec26655 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 6 Jul 2020 08:38:04 +0200 Subject: [PATCH 153/366] Fixed new Status value --- .../com/songoda/skyblock/island/Island.java | 32 ++++++++++--------- .../songoda/skyblock/island/IslandStatus.java | 6 +++- .../songoda/skyblock/visit/VisitManager.java | 23 +++++++++++-- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 91868415..90c89d6e 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -195,32 +195,31 @@ public class Island { } } - if(configLoad.getString("Visitor.Open", null).equalsIgnoreCase("true") || - configLoad.getString("Visitor.Open", null).equalsIgnoreCase("false")) { + String open = configLoad.getString("Visitor.Open", null); + if(open != null && (open.equalsIgnoreCase("true") || + open.equalsIgnoreCase("false"))) { if(configLoad.getBoolean("Visitor.Open")) { status = IslandStatus.OPEN; } else { status = IslandStatus.CLOSED; } configLoad.set("Visitor.Open", null); + configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status")); + save(); } else { - IslandStatus status = IslandStatus.valueOf(configLoad.getString("Visitor.Status")); - switch (status){ - case OPEN: - case CLOSED: - case WHITELISTED: - this.status = status; - break; - default: - this.status = IslandStatus.WHITELISTED; - break; + if(configLoad.getString("Visitor.Status") != null) { + status = IslandStatus.getEnum(configLoad.getString("Visitor.Status")); + } else { + status = IslandStatus.WHITELISTED; + configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status")); + save(); } } } else { FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("UUID", islandUUID.toString()); - configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status")); + configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status").toUpperCase()); 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()); @@ -242,6 +241,8 @@ public class Island { islandPermissions.put(roleList, permissions); } + status = IslandStatus.getEnum(mainConfigLoad.getString("Island.Visitor.Status")); + save(); Player onlinePlayer = Bukkit.getServer().getPlayer(ownerUUID); @@ -782,7 +783,7 @@ public class Island { if(!islandStatusChangeEvent.isCancelled()) { this.status = status; getVisit().setStatus(status); - // TODO Save to config + Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); } } @@ -872,7 +873,8 @@ public class Island { Config config = fileManager .getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); - config.getFileConfiguration().set("Whitelist", whitelistedPlayers); + config.getFileConfiguration().set("Whitelist", new ArrayList<>(whitelistedPlayers)); + config.getFileConfiguration().set("Visitor.Status", status.toString()); try { config.getFileConfiguration().save(config.getFile()); diff --git a/src/main/java/com/songoda/skyblock/island/IslandStatus.java b/src/main/java/com/songoda/skyblock/island/IslandStatus.java index f45f3d59..682e9495 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandStatus.java +++ b/src/main/java/com/songoda/skyblock/island/IslandStatus.java @@ -3,5 +3,9 @@ package com.songoda.skyblock.island; public enum IslandStatus { OPEN, CLOSED, - WHITELISTED + WHITELISTED; + + public static IslandStatus getEnum(String value) { + return valueOf(value.toUpperCase()); + } } diff --git a/src/main/java/com/songoda/skyblock/visit/VisitManager.java b/src/main/java/com/songoda/skyblock/visit/VisitManager.java index c8ec9698..11d7fffe 100644 --- a/src/main/java/com/songoda/skyblock/visit/VisitManager.java +++ b/src/main/java/com/songoda/skyblock/visit/VisitManager.java @@ -72,7 +72,25 @@ public class VisitManager { if (configLoad.getString("Size") != null) { size = configLoad.getInt("Size"); } - + + IslandStatus status; + String open = configLoad.getString("Visitor.Open", null); + if(open != null && (open.equalsIgnoreCase("true") || + open.equalsIgnoreCase("false"))) { + if(configLoad.getBoolean("Visitor.Open")) { + status = IslandStatus.OPEN; + } else { + status = IslandStatus.CLOSED; + } + configLoad.set("Visitor.Open", null); + } else { + if(configLoad.getString("Visitor.Status") != null) { + status = IslandStatus.getEnum(configLoad.getString("Visitor.Status")); + } else { + status = IslandStatus.WHITELISTED; + } + } + createIsland(islandOwnerUUID, new IslandLocation[]{ new IslandLocation(IslandWorld.Normal, null, @@ -89,7 +107,8 @@ public class VisitManager { + configLoad.getStringList("Operators").size() + 1, configLoad.getDouble("Bank.Balance", 0), getIslandSafeLevel(islandOwnerUUID), new IslandLevel(islandOwnerUUID, skyblock), - islandSignature, IslandStatus.valueOf(configLoad.getString("Visitor.Status"))); + islandSignature, + status); } catch (Exception e) { e.printStackTrace(); } From 7cff7893b8909b9a25ed16534425f81c3def09d1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 6 Jul 2020 08:38:18 +0200 Subject: [PATCH 154/366] Re-enabled biome update on island creation --- .../songoda/skyblock/island/IslandManager.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index b979d027..ce1c5d74 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -282,14 +282,15 @@ public class IslandManager { } Biome biome = cBiome.getBiome(); - /*Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { - skyblock.getBiomeManager().setBiome(island, biome, null); - if (structure.getCommands() != null) { - for (String commandList : structure.getCommands()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); + Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { + skyblock.getBiomeManager().setBiome(island, biome, () -> { + if (structure.getCommands() != null) { + for (String commandList : structure.getCommands()) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); + } } - } - }, 20L);*/ + }); + }, 20L); // Recalculate island level after 5 seconds if (configLoad.getBoolean("Island.Levelling.ScanAutomatically")) From 122aea1bba316796fedb86b54047590ba1a8e6ae Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 6 Jul 2020 09:29:55 +0200 Subject: [PATCH 155/366] Only even numbers in island size --- .../java/com/songoda/skyblock/island/Island.java | 13 +++++++++++++ src/main/resources/config.yml | 7 ++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 90c89d6e..4c514c86 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -65,6 +65,10 @@ public class Island { if (this.size > 1000) { this.size = 50; } + + if(this.size % 2 != 0) { + this.size += 1; + } if (player.isOnline()) { int customSize = PlayerUtils.getNumberFromPermission(player.getPlayer(), "fabledskyblock.size", 0); @@ -77,8 +81,17 @@ public class Island { if (minimumSize < 0 || minimumSize > 1000) minimumSize = 50; + + if(minimumSize % 2 != 0) { + minimumSize += 1; + } + if (maximumSize < 0 || maximumSize > 1000) maximumSize = 100; + + if(maximumSize % 2 != 0) { + maximumSize += 1; + } size = Math.max(minimumSize, Math.min(customSize, maximumSize)); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5f4ac7da..ed29bca0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -15,9 +15,10 @@ Island: # You should increase this only if you have an SSD ChunkPerTick: 15 Size: - # [!] Do not go over 1000 for both of these options. - # The size of an Island when created. - # [!] Do not go over the maximum. + # Warning: The maximum is capped at 1000 + # Warning: Only even numbers are accepted + # Warning: Do not go over the maximum + # The size of an Island when created Minimum: 100 # The maximum size of an Island based on the permission node 'fabledskyblock.size.'. Maximum: 200 From c5c9f974041f14dcb7455157682ac4915f48eced Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 7 Jul 2020 17:06:40 +0200 Subject: [PATCH 156/366] Renamed exception --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index ce1c5d74..4a9d9edd 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -876,8 +876,7 @@ public class IslandManager { scoreboard.run(); } - } catch (Exception e) { - } + } catch (Exception ignored) {} } unloadIsland = false; From ebee135ce2d0dde2d0adf8a81e84ebd30b41495a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 7 Jul 2020 17:07:00 +0200 Subject: [PATCH 157/366] Removed placeholder in bank anvil gui --- .../songoda/skyblock/gui/bank/GuiBankSelector.java | 14 +++----------- src/main/resources/language.yml | 1 - 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index ea75ca31..9a6fa262 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -185,21 +185,13 @@ public class GuiBankSelector extends Gui { e.player.closeInventory(); guiManager.showGUI(event.player, returnGui); })); - - ItemStack input = CompatibleMaterial.PAPER.getItem(); - ItemMeta im = input.getItemMeta(); - if(im != null){ - im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount"))); - input.setItemMeta(im); - } - - gui.setInput(input); + switch(type){ case DEPOSIT: - gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Deposit"))); + gui.setTitle(languageLoad.getString("Menu.Bank.Words.Deposit")); break; case WITHDRAW: - gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Withdraw"))); + gui.setTitle(languageLoad.getString("Menu.Bank.Words.Withdraw")); break; } guiManager.showGUI(event.player, gui); diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index b698876f..2a4918c4 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -3392,7 +3392,6 @@ Menu: Words: Withdraw: 'Withdraw' Deposit: 'Deposit' - Amount: 'Amount' Input: Title: 'Select amount.' Item: From 66ae360412445513d27538fecc7bd64b606d0407 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 08:04:02 +0200 Subject: [PATCH 158/366] Optimized admin upgrades commands --- .../commands/admin/AddUpgradeCommand.java | 16 +++++++--------- .../commands/admin/RemoveUpgradeCommand.java | 18 ++++++++---------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java index 6f700d12..7150ba59 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java @@ -58,16 +58,14 @@ public class AddUpgradeCommand extends SubCommand { targetPlayerName = targetPlayer.getName(); } - Upgrade.Type upgrade = null; - - for (Upgrade.Type upgradeList : Upgrade.Type.values()) { - if (upgradeList != Upgrade.Type.Size) { - if (args[1].toUpperCase().equals(upgradeList.name().toUpperCase())) { - upgrade = upgradeList; - - break; - } + Upgrade.Type upgrade; + try { + upgrade = Upgrade.Type.valueOf(args[1].toUpperCase()); + if(upgrade.equals(Upgrade.Type.Size) || upgrade.equals(Upgrade.Type.Members)){ + upgrade = null; } + } catch(IllegalArgumentException e) { + upgrade = null; } if (islandOwnerUUID == null) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java index cfa3c36f..382f8260 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java @@ -57,17 +57,15 @@ public class RemoveUpgradeCommand extends SubCommand { islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner(); targetPlayerName = targetPlayer.getName(); } - - Upgrade.Type upgrade = null; - - for (Upgrade.Type upgradeList : Upgrade.Type.values()) { - if (upgradeList != Upgrade.Type.Size) { - if (args[1].toUpperCase().equals(upgradeList.name().toUpperCase())) { - upgrade = upgradeList; - - break; - } + + Upgrade.Type upgrade; + try { + upgrade = Upgrade.Type.valueOf(args[1].toUpperCase()); + if(upgrade.equals(Upgrade.Type.Size) || upgrade.equals(Upgrade.Type.Members)){ + upgrade = null; } + } catch(IllegalArgumentException e) { + upgrade = null; } if (islandOwnerUUID == null) { From 63dcbbb376bec0b7579412bcfc7b5730ab6ddeb9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 08:04:13 +0200 Subject: [PATCH 159/366] Default owner settings to true --- src/main/resources/settings.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 562bbb25..154bfd74 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -166,8 +166,8 @@ Settings: Damage: true Owner: NaturalMobSpawning: true - MobGriefing: false - Explosions: false + MobGriefing: true + Explosions: true FireSpread: true LeafDecay: true KeepItemsOnDeath: true \ No newline at end of file From 2fe608aec2809de0290b185e4a45cdf159e82fee Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 08:07:42 +0200 Subject: [PATCH 160/366] Fixed %fabledskyblock_island_maxmembers% not working --- .../skyblock/placeholder/PlaceholderManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java index 84f4e00c..8f4d1463 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java @@ -231,6 +231,15 @@ public class PlaceholderManager { configLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty.Message") .replace("%placeholder", "" + island.getRole(IslandRole.Member).size())); } + } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_maxmembers")) { + if (island == null) { + return ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Placeholder.fabledskyblock_island_maxmembers.Empty.Message")); + } else { + return ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Placeholder.fabledskyblock_island_maxmembers.Non-empty.Message") + .replace("%placeholder", "" + island.getMaxMembers())); + } } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_operators")) { if (island == null) { return ChatColor.translateAlternateColorCodes('&', @@ -426,6 +435,7 @@ public class PlaceholderManager { placeholders.add("fabledskyblock_island_bans"); placeholders.add("fabledskyblock_island_members_total"); placeholders.add("fabledskyblock_island_members"); + placeholders.add("fabledskyblock_island_maxmembers"); placeholders.add("fabledskyblock_island_operators"); placeholders.add("fabledskyblock_island_coops"); placeholders.add("fabledskyblock_island_coops_total"); From fe9b01e0d9eac93decaccc44f3dc20b6b3273d48 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 08:48:57 +0200 Subject: [PATCH 161/366] Fix for admin upgrade commands --- .../command/commands/admin/AddUpgradeCommand.java | 14 ++++++-------- .../commands/admin/RemoveUpgradeCommand.java | 12 +++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java index 7150ba59..0bdba737 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java @@ -57,15 +57,13 @@ public class AddUpgradeCommand extends SubCommand { islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner(); targetPlayerName = targetPlayer.getName(); } - - Upgrade.Type upgrade; - try { - upgrade = Upgrade.Type.valueOf(args[1].toUpperCase()); - if(upgrade.equals(Upgrade.Type.Size) || upgrade.equals(Upgrade.Type.Members)){ - upgrade = null; + + Upgrade.Type upgrade = null; + for(Upgrade.Type type : Upgrade.Type.values()) { + if(type.name().toUpperCase().equals(args[1].toUpperCase())) { + upgrade = type; + break; } - } catch(IllegalArgumentException e) { - upgrade = null; } if (islandOwnerUUID == null) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java index 382f8260..c297788c 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java @@ -58,14 +58,12 @@ public class RemoveUpgradeCommand extends SubCommand { targetPlayerName = targetPlayer.getName(); } - Upgrade.Type upgrade; - try { - upgrade = Upgrade.Type.valueOf(args[1].toUpperCase()); - if(upgrade.equals(Upgrade.Type.Size) || upgrade.equals(Upgrade.Type.Members)){ - upgrade = null; + Upgrade.Type upgrade = null; + for(Upgrade.Type type : Upgrade.Type.values()) { + if(type.name().toUpperCase().equals(args[1].toUpperCase())) { + upgrade = type; + break; } - } catch(IllegalArgumentException e) { - upgrade = null; } if (islandOwnerUUID == null) { From f136290436b8aa5cfaedd0ee49f8c2160b8ce2bd Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 09:14:58 +0200 Subject: [PATCH 162/366] Fixed ChatSpy --- .../commands/admin/ChatSpyCommand.java | 10 +-- .../command/commands/island/ChatCommand.java | 31 --------- .../com/songoda/skyblock/listeners/Chat.java | 68 +++++++++++++++++-- .../skyblock/playerdata/PlayerData.java | 1 + 4 files changed, 69 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java index 6974a548..6b62c118 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java @@ -53,12 +53,13 @@ public class ChatSpyCommand extends SubCommand { } break; case "add": - if(args.length > 2){ + if(args.length == 2){ OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]); Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer()); if(island != null) { playerData.addChatSpyIsland(island); - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Add.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Add.Message") + .replace("%owner", new OfflinePlayer(island.getOwnerUUID()).getName())); } else { messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.NullIsland.Message")); } @@ -68,12 +69,13 @@ public class ChatSpyCommand extends SubCommand { } break; case "remove": - if(args.length > 2){ + if(args.length == 2){ OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]); Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer()); if(island != null) { playerData.removeChatSpyIsland(island); - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Remove.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Remove.Message") + .replace("%owner", new OfflinePlayer(island.getOwnerUUID()).getName())); } else { messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.NullIsland.Message")); } 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 19a8cbc9..26fd9782 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 @@ -4,24 +4,20 @@ 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 { @@ -31,7 +27,6 @@ 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(); @@ -73,37 +68,11 @@ public class ChatCommand extends SubCommand { island = skyblock.getIslandManager().getIsland(player); } - 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/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index fb984512..5cf1d898 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -66,21 +66,21 @@ public class Chat implements Listener { if (playerData.isChat()) { event.setCancelled(true); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); + Config language = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration languageLoad = language.getFileConfiguration(); String islandRole = ""; if (island.hasRole(IslandRole.Member, player.getUniqueId())) { - islandRole = configLoad.getString("Island.Chat.Format.Role.Member"); + islandRole = languageLoad.getString("Island.Chat.Format.Role.Member"); } else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) { - islandRole = configLoad.getString("Island.Chat.Format.Role.Operator"); + islandRole = languageLoad.getString("Island.Chat.Format.Role.Operator"); } else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { - islandRole = configLoad.getString("Island.Chat.Format.Role.Owner"); + islandRole = languageLoad.getString("Island.Chat.Format.Role.Owner"); } PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, island.getAPIWrapper(), - event.getMessage(), configLoad.getString("Island.Chat.Format.Message")); + event.getMessage(), languageLoad.getString("Island.Chat.Format.Message")); Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); if (!islandChatEvent.isCancelled()) { @@ -113,4 +113,60 @@ public class Chat implements Listener { } } } + + @EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true) + public void onIslandChat(PlayerIslandChatEvent event) { + PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); + PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + MessageManager messageManager = skyblock.getMessageManager(); + IslandManager islandManager = skyblock.getIslandManager(); + FileManager fileManager = skyblock.getFileManager(); + + Island island = event.getIsland().getIsland(); + Player player = event.getPlayer(); + + Config language = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration languageLoad = language.getFileConfiguration(); + + String islandRole = null; + + if (island.hasRole(IslandRole.Member, player.getUniqueId())) { + islandRole = languageLoad.getString("Island.Chat.Format.Role.Member"); + } else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) { + islandRole = languageLoad.getString("Island.Chat.Format.Role.Operator"); + } else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { + islandRole = languageLoad.getString("Island.Chat.Format.Role.Owner"); + } + if(islandRole == null) { + islandRole = ""; + } + + + for (UUID islandMembersOnlineList : islandManager.getMembersOnline(island)) { + Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); + String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, + event.getFormat().replace("%role", islandRole).replace("%player", player.getName()))) + .replace("%message", event.getMessage()); + messageManager.sendMessage(targetPlayer, message); + } + + // Spy + for(Player targetPlayer : Bukkit.getServer().getOnlinePlayers()){ + if(!targetPlayer.equals(event.getPlayer()) && targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) { + PlayerData pd = playerDataManager.getPlayerData(targetPlayer); + if(pd != null && pd.isChatSpy() && (pd.isGlobalChatSpy() || pd.isChatSpyIsland(island))) { + String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, + languageLoad.getString("Island.Chat.Spy.Format.Message").replace("%role", islandRole).replace("%player", player.getName()))) + .replace("%islandOwner", new OfflinePlayer(island.getOwnerUUID()).getName()) + .replace("%message", event.getMessage()); + messageManager.sendMessage(targetPlayer, message); + } + } + } + + if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { + messageManager.sendMessage(Bukkit.getConsoleSender(), event.getFormat().replace("%role", islandRole).replace("%player", player.getName()) + .replace("%message", event.getMessage())); + } + } } diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index c878f9cf..69bbf8f9 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -60,6 +60,7 @@ public class PlayerData { area = new Area(); chatSpy = getConfig().getFileConfiguration().getBoolean("ChatSpy", false); + spiedIslands = new HashSet<>(); if (getConfig().getFileConfiguration().getString("ChatSpiedIslands") != null) { for (String islandUUID : getConfig().getFileConfiguration().getStringList("ChatSpiedIslands")) { From 43fa39df8d3dd90250143abb72be4fe1d34639ce Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 09:27:57 +0200 Subject: [PATCH 163/366] Fix item not being removed on older versions --- .../com/songoda/skyblock/challenge/challenge/Challenge.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 8da500e4..d1f729ad 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.challenge.challenge; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; @@ -187,7 +188,7 @@ public class Challenge { if(isItem) { if(jis.getAmount() <= toRemove) { toRemove -= jis.getAmount(); - jis.setAmount(0); + p.getInventory().remove(jis); } else { jis.setAmount(jis.getAmount() - toRemove); toRemove = 0; From da02fd6d95f9fc617936bb7911430bd0b8650ae9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 10:33:17 +0200 Subject: [PATCH 164/366] Whitelist command --- .../skyblock/command/CommandManager.java | 3 +- .../commands/island/PublicCommand.java | 6 +- .../commands/island/WhitelistCommand.java | 129 ++++++++++++++++++ .../com/songoda/skyblock/island/Island.java | 10 +- src/main/resources/language.yml | 30 ++++ 5 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index 84ef286a..fcdbe20f 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -90,7 +90,8 @@ public class CommandManager implements CommandExecutor, TabCompleter { new VisitorsCommand(), new VoteCommand(), new ScoreboardCommand(), - new WeatherCommand() + new WeatherCommand(), + new WhitelistCommand() ); adminCommands = Arrays.asList( diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java index 61ae2c0a..60c4145a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java @@ -41,13 +41,13 @@ public class PublicCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Restricted.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); break; - case CLOSED: + case WHITELISTED: islandManager.closeIsland(island); messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Private.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); break; - case WHITELISTED: + case CLOSED: island.setStatus(IslandStatus.OPEN); messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Public.Message")); @@ -77,7 +77,7 @@ public class PublicCommand extends SubCommand { @Override public String[] getAliases() { - return new String[]{"pub", "private", "pri"}; + return new String[]{"pub", "private", "pri", "restricted", "res"}; } @Override diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java new file mode 100644 index 00000000..ec0666d2 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java @@ -0,0 +1,129 @@ +package com.songoda.skyblock.command.commands.island; + +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.skyblock.command.SubCommand; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.IslandStatus; +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 org.bukkit.Bukkit; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; +import java.util.Set; +import java.util.UUID; + +public class WhitelistCommand extends SubCommand { + + @Override + public void onCommandByPlayer(Player player, String[] args) { + MessageManager messageManager = skyblock.getMessageManager(); + IslandManager islandManager = skyblock.getIslandManager(); + FileManager fileManager = skyblock.getFileManager(); + SoundManager soundManager = skyblock.getSoundManager(); + + FileManager.Config language = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration languageLoad = language.getFileConfiguration(); + + FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + Island island = islandManager.getIsland(player); + + if (island == null) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Whitelist.Owner.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) + || (island.hasRole(IslandRole.Operator, player.getUniqueId()) + && skyblock.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) { + if(args.length == 1) { + if(args[0].equalsIgnoreCase("on")){ + island.setStatus(IslandStatus.WHITELISTED); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.On.Message")); + } else if(args[0].equalsIgnoreCase("off")){ + island.setStatus(IslandStatus.CLOSED); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.Off.Message")); + } else if(args[0].equalsIgnoreCase("list")){ + Set whitelistedPlayers = island.getWhitelistedPlayers(); + if(!whitelistedPlayers.isEmpty()){ + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.List.Start.Message")); + for(UUID uuid : whitelistedPlayers) { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.List.List.Message") + .replace("%owner", new OfflinePlayer(uuid).getName())); + } + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.List.End.Message")); + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.List.Empty.Message")); + } + } else { // Invalid args + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.InvalidArgNumber.Message")); + } + } else if(args.length == 2) { + OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]); + if(offlinePlayer.getBukkitOfflinePlayer().hasPlayedBefore()) { + if(args[0].equalsIgnoreCase("add")){ + if (!island.isPlayerWhitelisted(offlinePlayer.getUUID())) { + island.addWhitelistedPlayer(offlinePlayer.getUUID()); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.Added.Message") + .replace("%player", offlinePlayer.getName())); + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.AlreadyAdded.Message") + .replace("%player", offlinePlayer.getName())); + } + } else if(args[0].equalsIgnoreCase("remove")){ + if (island.isPlayerWhitelisted(offlinePlayer.getUUID())) { + island.removeWhitelistedPlayer(offlinePlayer.getUUID()); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.Removed.Message") + .replace("%player", offlinePlayer.getName())); + } else { + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.NotWhitelisted.Message") + .replace("%player", offlinePlayer.getName())); + } + } else { // Invalid args + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.InvalidArgNumber.Message")); + } + } else { // Player not found + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.PlayerNotFound.Message") + .replace("%player", offlinePlayer.getName())); + } + } else { // Invalid args + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.InvalidArgNumber.Message")); + } + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Whitelist.Permission.Message")); + soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + } + } + + @Override + public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { + sender.sendMessage("SkyBlock | Error: You must be a player to perform that command."); + } + + @Override + public String getName() { + return "whitelist"; + } + + @Override + public String getInfoMessagePath() { + return "Command.Island.Public.Info.Message"; + } + + @Override + public String[] getAliases() { + return new String[0]; + } + + @Override + public String[] getArguments() { + return new String[]{"on", "off", "add", "remove", "list"}; + } +} diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 4c514c86..3d9066cf 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -886,7 +886,11 @@ public class Island { Config config = fileManager .getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); - config.getFileConfiguration().set("Whitelist", new ArrayList<>(whitelistedPlayers)); + List tempWhitelist = new ArrayList<>(); + for(UUID uuid : whitelistedPlayers) { + tempWhitelist.add(uuid.toString()); + } + config.getFileConfiguration().set("Whitelist", tempWhitelist); config.getFileConfiguration().set("Visitor.Status", status.toString()); try { @@ -988,6 +992,10 @@ public class Island { Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); } + public Set getWhitelistedPlayers() { + return new HashSet<>(whitelistedPlayers); + } + public void addWhitelistedPlayer(Player player) { this.addWhitelistedPlayer(player.getUniqueId()); } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 2a4918c4..ffabb4d1 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -19,6 +19,36 @@ Command: Info: Message: '&bSkyBlock &8| &aInfo&8: &eEnable or disabled the scoreboard.' Island: + Whitelist: + Info: + Message: '&f&oManage your island''s whitelist.' + Permission: + Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to manage the island''s whitelist''.' + On: + Message: '&bSkyBlock &8| &aInfo&8: &eWhitelist enabled.' + Off: + Message: '&bSkyBlock &8| &aInfo&8: &eWhitelist disabled. The island is now closed' + Added: + Message: '&bSkyBlock &8| &aInfo&8: &eAdded %player to the island''s whitelist.' + Removed: + Message: '&bSkyBlock &8| &aInfo&8: &eRemoved %player from the island''s whitelist.' + AlreadyAdded: + Message: '&bSkyBlock &8| &aInfo&8: &e%player is already whitelisted.' + NotWhitelisted: + Message: '&bSkyBlock &8| &aInfo&8: &e%player is not whitelisted.' + PlayerNotFound: + Message: '&bSkyBlock &8| &cError&8: &ePlayer %player has not been found.' + InvalidArgNumber: + Message: '&bSkyBlock &8| &cError&8: &eInvalid arguments number.' + List: + Start: + Message: '&bSkyBlock &8| &aInfo&8: &eCurrent island''s whitelist:' + List: + Message: '&a- &e%owner' + End: + Message: '&a---------' + Empty: + Message: '&bSkyBlock &8| &aInfo&8: &eYour island''s whitelist is currently empty.' Bans: Owner: Message: '&bSkyBlock &8| &cError&8: &eYou are not an Island Owner.' From f6679f79b21aff09b7b014e90868a03d9b1bae50 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 10:33:50 +0200 Subject: [PATCH 165/366] Code optimizations --- .../command/commands/island/BanCommand.java | 4 ++-- .../commands/island/WhitelistCommand.java | 2 -- .../skyblock/utils/player/OfflinePlayer.java | 22 ++++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java index b27df88d..f7013442 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java @@ -47,8 +47,8 @@ public class BanCommand extends SubCommand { || (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Ban", IslandRole.Operator))) { Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); - UUID targetPlayerUUID = null; - String targetPlayerName = null; + UUID targetPlayerUUID; + String targetPlayerName; if (targetPlayer == null) { OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java index ec0666d2..8a5ad298 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java @@ -8,10 +8,8 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.island.IslandStatus; 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 org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java index 5a26bf33..3ecdd7af 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java +++ b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java @@ -11,29 +11,31 @@ import java.util.UUID; public class OfflinePlayer { - private UUID uuid; + private final UUID uuid; org.bukkit.OfflinePlayer bukkitOfflinePlayer; private String name; - private String memberSince; - private String lastOnline; + private final String memberSince; + private final String lastOnline; private UUID owner = null; - private String[] texture; + private final String[] texture; - private int playtime; + private final int playtime; public OfflinePlayer(String name) { SkyBlock skyblock = SkyBlock.getInstance(); UserCacheManager userCacheManager = skyblock.getUserCacheManager(); bukkitOfflinePlayer = Bukkit.getServer().getOfflinePlayer(name); - - this.name = bukkitOfflinePlayer.getName(); - this.uuid = bukkitOfflinePlayer.getUniqueId(); - - if (this.uuid == null && userCacheManager.hasUser(name)) { + + if (userCacheManager.hasUser(name)) { this.uuid = userCacheManager.getUser(name); + bukkitOfflinePlayer = Bukkit.getServer().getOfflinePlayer(uuid); + } else { + this.uuid = bukkitOfflinePlayer.getUniqueId(); } + + this.name = bukkitOfflinePlayer.getName(); FileConfiguration configLoad = YamlConfiguration.loadConfiguration( new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); From 1799123f596bfadf9cf37eca7eacace76efe0f75 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 10:35:13 +0200 Subject: [PATCH 166/366] Edit whitelist messages --- src/main/resources/language.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index ffabb4d1..0d3e8c3d 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -33,9 +33,9 @@ Command: Removed: Message: '&bSkyBlock &8| &aInfo&8: &eRemoved %player from the island''s whitelist.' AlreadyAdded: - Message: '&bSkyBlock &8| &aInfo&8: &e%player is already whitelisted.' + Message: '&bSkyBlock &8| &cError&8: &e%player is already whitelisted.' NotWhitelisted: - Message: '&bSkyBlock &8| &aInfo&8: &e%player is not whitelisted.' + Message: '&bSkyBlock &8| &cError&8: &e%player is not whitelisted.' PlayerNotFound: Message: '&bSkyBlock &8| &cError&8: &ePlayer %player has not been found.' InvalidArgNumber: From c1557da2681e4852c1bbaa715892a70d7b377c7f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 10:49:19 +0200 Subject: [PATCH 167/366] Fixed player bypass mob protections with arrows --- src/main/java/com/songoda/skyblock/listeners/Entity.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 3e2522e0..2f570d2d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -115,9 +115,7 @@ public class Entity implements Listener { .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true); } else if((event.getDamager() instanceof org.bukkit.entity.Projectile - && ((Projectile) event.getDamager()).getShooter() instanceof Player) - && (event.getEntity().getType().equals(EntityType.ARMOR_STAND) - || event.getEntity().getType().equals(EntityType.ITEM_FRAME))){ + && ((Projectile) event.getDamager()).getShooter() instanceof Player)){ Player player = (Player) ((Projectile) event.getDamager()).getShooter(); skyblock.getPermissionManager() .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); From 7396b763acb30b050d9ee9022ef7747bebfdedf0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 10:59:22 +0200 Subject: [PATCH 168/366] Fix whitelist messages --- .../command/commands/island/WhitelistCommand.java | 11 ++++++----- src/main/resources/language.yml | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java index 8a5ad298..24478392 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java @@ -10,6 +10,7 @@ import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; +import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -43,18 +44,18 @@ public class WhitelistCommand extends SubCommand { && skyblock.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) { if(args.length == 1) { if(args[0].equalsIgnoreCase("on")){ - island.setStatus(IslandStatus.WHITELISTED); - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.On.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.Enabled.Message")); + islandManager.whitelistIsland(island); } else if(args[0].equalsIgnoreCase("off")){ - island.setStatus(IslandStatus.CLOSED); - messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.Off.Message")); + messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.Disabled.Message")); + islandManager.closeIsland(island); } else if(args[0].equalsIgnoreCase("list")){ Set whitelistedPlayers = island.getWhitelistedPlayers(); if(!whitelistedPlayers.isEmpty()){ messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.List.Start.Message")); for(UUID uuid : whitelistedPlayers) { messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.List.List.Message") - .replace("%owner", new OfflinePlayer(uuid).getName())); + .replace("%player", new OfflinePlayer(uuid).getName())); } messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.List.End.Message")); } else { diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 0d3e8c3d..0c64453b 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -24,10 +24,10 @@ Command: Message: '&f&oManage your island''s whitelist.' Permission: Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to manage the island''s whitelist''.' - On: + Enabled: Message: '&bSkyBlock &8| &aInfo&8: &eWhitelist enabled.' - Off: - Message: '&bSkyBlock &8| &aInfo&8: &eWhitelist disabled. The island is now closed' + Disabled: + Message: '&bSkyBlock &8| &aInfo&8: &eWhitelist disabled. The island is now closed.' Added: Message: '&bSkyBlock &8| &aInfo&8: &eAdded %player to the island''s whitelist.' Removed: @@ -44,7 +44,7 @@ Command: Start: Message: '&bSkyBlock &8| &aInfo&8: &eCurrent island''s whitelist:' List: - Message: '&a- &e%owner' + Message: '&a- &e%player' End: Message: '&a---------' Empty: From abbc11ea6c81d95f3ad9b427baece2719d0a88d1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 11:13:03 +0200 Subject: [PATCH 169/366] Do not send spy to island's members --- src/main/java/com/songoda/skyblock/listeners/Chat.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index 5cf1d898..510bd76c 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -116,7 +116,6 @@ public class Chat implements Listener { @EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true) public void onIslandChat(PlayerIslandChatEvent event) { - PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); @@ -140,8 +139,7 @@ public class Chat implements Listener { if(islandRole == null) { islandRole = ""; } - - + for (UUID islandMembersOnlineList : islandManager.getMembersOnline(island)) { Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, @@ -152,7 +150,9 @@ public class Chat implements Listener { // Spy for(Player targetPlayer : Bukkit.getServer().getOnlinePlayers()){ - if(!targetPlayer.equals(event.getPlayer()) && targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) { + if(!targetPlayer.equals(event.getPlayer()) && + !islandManager.getMembersOnline(island).contains(targetPlayer.getUniqueId()) && + targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) { PlayerData pd = playerDataManager.getPlayerData(targetPlayer); if(pd != null && pd.isChatSpy() && (pd.isGlobalChatSpy() || pd.isChatSpyIsland(island))) { String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, From d9ba7c5065404f5f36c5e5f01221b214a250a80d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 16:39:31 +0200 Subject: [PATCH 170/366] Fix for playerData set --- .../java/com/songoda/skyblock/playerdata/PlayerData.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 69bbf8f9..0036824c 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -302,7 +302,11 @@ public class PlayerData { } configLoad.set("ChatSpy", chatSpy); - configLoad.set("ChatSpiedIslands", spiedIslands); + List tempSpiedIslands = new ArrayList<>(); + for(UUID uuid : spiedIslands){ + tempSpiedIslands.add(uuid.toString()); + } + configLoad.set("ChatSpiedIslands", tempSpiedIslands); try { configLoad.save(config.getFile()); From ac1a699ac79d78dc16ff8f46e7da17dac827f743 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 16:46:16 +0200 Subject: [PATCH 171/366] Upgrades permission --- .../com/songoda/skyblock/menus/Upgrade.java | 610 +++++++++--------- 1 file changed, 313 insertions(+), 297 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java index ee097aa8..784df982 100644 --- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java @@ -522,367 +522,383 @@ public class Upgrade { ItemStack potion = new ItemStack(Material.POTION); int NMSVersion = NMSUtil.getVersionNumber(); - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Speed); - - if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - - if (NMSVersion > 8) { - PotionMeta pm = (PotionMeta) potion.getItemMeta(); - - if (NMSVersion > 9) { - pm.setBasePotionData(new PotionData(PotionType.SPEED)); + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Speed.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Speed); + + if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); + + if (NMSVersion > 8) { + PotionMeta pm = (PotionMeta) potion.getItemMeta(); + + if (NMSVersion > 9) { + pm.setBasePotionData(new PotionData(PotionType.SPEED)); + } else { + pm.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1, 0), true); + } + + potion.setItemMeta(pm); } else { - pm.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1, 0), true); + potion = new ItemStack(Material.POTION, 1, (short) 8194); } - - potion.setItemMeta(pm); - } else { - potion = new ItemStack(Material.POTION, 1, (short) 8194); - } - - if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Speed)) { - nInv.addItem(nInv.createItem(potion, - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Speed.Claimed.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%status", - getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Speed))}, - null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); - } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + + if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Speed)) { nInv.addItem(nInv.createItem(potion, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Speed.Claimable.Lore"), + configLoad.getStringList("Menu.Upgrade.Item.Speed.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%status", + getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Speed))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); } else { - nInv.addItem(nInv.createItem(potion, - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Speed.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, - null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem(nInv.createItem(potion, + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Speed.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); + } else { + nInv.addItem(nInv.createItem(potion, + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Speed.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); + } } } } - - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Jump); - - if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - - if (NMSVersion > 8) { - potion = new ItemStack(Material.POTION); - PotionMeta pm = (PotionMeta) potion.getItemMeta(); - - if (NMSVersion > 9) { - pm.setBasePotionData(new PotionData(PotionType.JUMP)); + + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Jump.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Jump); + + if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); + + if (NMSVersion > 8) { + potion = new ItemStack(Material.POTION); + PotionMeta pm = (PotionMeta) potion.getItemMeta(); + + if (NMSVersion > 9) { + pm.setBasePotionData(new PotionData(PotionType.JUMP)); + } else { + pm.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 1, 0), true); + } + + potion.setItemMeta(pm); } else { - pm.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 1, 0), true); + potion = new ItemStack(Material.POTION, 1, (short) 8203); } - - potion.setItemMeta(pm); - } else { - potion = new ItemStack(Material.POTION, 1, (short) 8203); - } - - if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Jump)) { - nInv.addItem(nInv.createItem(potion, - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Jump.Claimed.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%status", - getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Jump))}, - null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); - } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + + if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Jump)) { nInv.addItem(nInv.createItem(potion, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Jump.Claimable.Lore"), + configLoad.getStringList("Menu.Upgrade.Item.Jump.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%status", + getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Jump))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); } else { - nInv.addItem(nInv.createItem(potion, - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Jump.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, - null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem(nInv.createItem(potion, + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Jump.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); + } else { + nInv.addItem(nInv.createItem(potion, + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Jump.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); + } } } } - - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Crop); - - if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - - if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Crop)) { - nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Crop.Claimed.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%status", - getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Crop))}, - null, null), 3); - } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Crop.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Crop); + + if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); + + if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Crop)) { nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Crop.Claimable.Lore"), + configLoad.getStringList("Menu.Upgrade.Item.Crop.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%status", + getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Crop))}, null, null), 3); } else { - nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Crop.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, - null, null), 3); + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Crop.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 3); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Crop.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 3); + } } } } - - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Fly); - - if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - - if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Fly)) { - nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Fly.Claimed.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%status", - getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Fly))}, - null, null), 4); - } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Fly.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Fly); + + if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); + + if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Fly)) { nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Fly.Claimable.Lore"), + configLoad.getStringList("Menu.Upgrade.Item.Fly.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%status", + getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Fly))}, null, null), 4); } else { - nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Fly.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, - null, null), 4); + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Fly.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 4); + } else { + nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Fly.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 4); + } } } } - - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Drops); - - if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - - if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Drops)) { - nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Drops.Claimed.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%status", - getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Drops))}, - null, null), 5); - } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Drops.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Drops); + + if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); + + if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Drops)) { nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Drops.Claimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, - null, null), 5); - } else { - nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Drops.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, - null, null), 5); - } - } - } - - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members); - - if (upgrades != null && upgrades.size() > 0) { - for (int i = 0; i < upgrades.size(); i++) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(i); - int tier = i + 1; - - if (tier != upgrades.size()) { - if (upgrade.getValue() <= island.getMaxMembers()) { - continue; - } - } - - if (island.getMaxMembers() >= upgrade.getValue()) { - nInv.addItem(nInv.createItem(new ItemStack(Material.BOOKSHELF), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Members.Displayname").replace("%tier", - "" + tier)), - configLoad.getStringList("Menu.Upgrade.Item.Members.Claimed.Lore"), + configLoad.getStringList("Menu.Upgrade.Item.Drops.Claimed.Lore"), new Placeholder[]{ new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%tier", "" + tier), - new Placeholder("%maxMembers", "" + upgrade.getValue())}, - null, null), 6); + new Placeholder("%status", + getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Drops))}, + null, null), 5); } else { if (EconomyManager.hasBalance(player, upgrade.getCost())) { - nInv.addItem( - nInv.createItem(new ItemStack(Material.BOOKSHELF), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Members.Displayname") - .replace("%tier", "" + tier)), - configLoad.getStringList("Menu.Upgrade.Item.Members.Claimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%tier", "" + tier), - new Placeholder("%maxMembers", "" + upgrade.getValue())}, - null, null), - 6); + nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Drops.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 5); } else { - nInv.addItem( - nInv.createItem(new ItemStack(Material.BOOKSHELF), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Members.Displayname") - .replace("%tier", "" + tier)), - configLoad.getStringList("Menu.Upgrade.Item.Members.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%tier", "" + tier), - new Placeholder("%maxMembers", "" + upgrade.getValue())}, - null, null), - 6); + nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Drops.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 5); } } - - break; } } - - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Size); - - if (upgrades != null && upgrades.size() > 0) { - for (int i = 0; i < upgrades.size(); i++) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(i); - int tier = i + 1; - - if (tier != upgrades.size()) { - if (upgrade.getValue() <= island.getSize()) { - continue; + + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Members.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members); + + if (upgrades != null && upgrades.size() > 0) { + for (int i = 0; i < upgrades.size(); i++) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(i); + int tier = i + 1; + + if (tier != upgrades.size()) { + if (upgrade.getValue() <= island.getMaxMembers()) { + continue; + } } - } - - if (island.getSize() >= upgrade.getValue()) { - nInv.addItem(nInv.createItem(new ItemStack(Material.BEACON), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Size.Displayname").replace("%tier", - "" + tier)), - configLoad.getStringList("Menu.Upgrade.Item.Size.Claimed.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%tier", "" + tier), - new Placeholder("%size", "" + upgrade.getValue())}, - null, null), 7); - } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { - nInv.addItem( - nInv.createItem(new ItemStack(Material.BEACON), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Size.Displayname") - .replace("%tier", "" + tier)), - configLoad.getStringList("Menu.Upgrade.Item.Size.Claimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%tier", "" + tier), - new Placeholder("%size", "" + upgrade.getValue())}, - null, null), - 7); + + if (island.getMaxMembers() >= upgrade.getValue()) { + nInv.addItem(nInv.createItem(new ItemStack(Material.BOOKSHELF), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Members.Displayname").replace("%tier", + "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Members.Claimed.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%maxMembers", "" + upgrade.getValue())}, + null, null), 6); } else { - nInv.addItem( - nInv.createItem(new ItemStack(Material.BEACON), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Size.Displayname") - .replace("%tier", "" + tier)), - configLoad.getStringList("Menu.Upgrade.Item.Size.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", - NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%tier", "" + tier), - new Placeholder("%size", "" + upgrade.getValue())}, - null, null), - 7); + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem( + nInv.createItem(new ItemStack(Material.BOOKSHELF), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Members.Displayname") + .replace("%tier", "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Members.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", + NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%maxMembers", "" + upgrade.getValue())}, + null, null), + 6); + } else { + nInv.addItem( + nInv.createItem(new ItemStack(Material.BOOKSHELF), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Members.Displayname") + .replace("%tier", "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Members.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", + NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%maxMembers", "" + upgrade.getValue())}, + null, null), + 6); + } } + + break; } - - break; } } - - upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner); - - if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { - com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - - if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner)) { - nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Spawner.Claimed.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), - new Placeholder("%status", - getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner))}, - null, null), 8); - } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Size.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Size); + + if (upgrades != null && upgrades.size() > 0) { + for (int i = 0; i < upgrades.size(); i++) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(i); + int tier = i + 1; + + if (tier != upgrades.size()) { + if (upgrade.getValue() <= island.getSize()) { + continue; + } + } + + if (island.getSize() >= upgrade.getValue()) { + nInv.addItem(nInv.createItem(new ItemStack(Material.BEACON), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Size.Displayname").replace("%tier", + "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Size.Claimed.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%size", "" + upgrade.getValue())}, + null, null), 7); + } else { + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem( + nInv.createItem(new ItemStack(Material.BEACON), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Size.Displayname") + .replace("%tier", "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Size.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", + NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%size", "" + upgrade.getValue())}, + null, null), + 7); + } else { + nInv.addItem( + nInv.createItem(new ItemStack(Material.BEACON), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Size.Displayname") + .replace("%tier", "" + tier)), + configLoad.getStringList("Menu.Upgrade.Item.Size.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", + NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%tier", "" + tier), + new Placeholder("%size", "" + upgrade.getValue())}, + null, null), + 7); + } + } + + break; + } + } + } + + if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Spawner.name().toLowerCase())) { + upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner); + + if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { + com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); + + if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner)) { nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Spawner.Claimable.Lore"), + configLoad.getStringList("Menu.Upgrade.Item.Spawner.Claimed.Lore"), new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())), + new Placeholder("%status", + getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner))}, null, null), 8); } else { - nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), - configLoad.getStringList("Menu.Upgrade.Item.Spawner.Unclaimable.Lore"), - new Placeholder[]{ - new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, - null, null), 8); + if (EconomyManager.hasBalance(player, upgrade.getCost())) { + nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Spawner.Claimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 8); + } else { + nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), + ChatColor.translateAlternateColorCodes('&', + configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), + configLoad.getStringList("Menu.Upgrade.Item.Spawner.Unclaimable.Lore"), + new Placeholder[]{ + new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost()))}, + null, null), 8); + } } } } From 7814f36174087cce205567905c2e21d1d3ae6e4f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 17:51:58 +0200 Subject: [PATCH 172/366] Fix for vault async permission check --- .../com/songoda/skyblock/listeners/Block.java | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 41e39c87..55e28ada 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -628,12 +628,31 @@ public class Block implements Listener { for (Generator generator : generators) { if(onlyOwner && skyblock.getVaultPermission() != null) { OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); - if(skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || - skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || - skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { - if (applyGenerator(event, block, worldManager, islandLevelManager, island, state, generatorManager, generator)) - return; - } + event.setCancelled(true); + World finalWorld = event.getBlock().getWorld(); + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + if(skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || + skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || + skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { + Bukkit.getScheduler().runTask(skyblock, () -> { + if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ + BlockState genState = generatorManager.generateBlock(generator, block); + block.setType(genState.getType()); + + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { + BlockState tempState = block.getState(); + tempState.setData(genState.getData()); + tempState.update(true, true); + } + islandLevelManager.updateLevel(island, genState.getLocation()); + } + }); + } else { + Bukkit.getScheduler().runTask(skyblock, () -> { + block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); + }); + } + }); } else { for (Player player : possiblePlayers) { if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){ @@ -645,7 +664,7 @@ public class Block implements Listener { } } - if (applyGenerator(event, block, worldManager, islandLevelManager, island, state, generatorManager, generator)) + if (applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator)) return; } } @@ -653,8 +672,8 @@ public class Block implements Listener { } } - private boolean applyGenerator(BlockFormEvent event, org.bukkit.block.Block block, WorldManager worldManager, IslandLevelManager islandLevelManager, Island island, BlockState state, GeneratorManager generatorManager, Generator generator) { - if(worldManager.getIslandWorld(event.getBlock().getWorld()).equals(generator.getIsWorld())){ + private boolean applyGenerator(World world, org.bukkit.block.Block block, WorldManager worldManager, IslandLevelManager islandLevelManager, Island island, BlockState state, GeneratorManager generatorManager, Generator generator) { + if(worldManager.getIslandWorld(world).equals(generator.getIsWorld())){ BlockState genState = generatorManager.generateBlock(generator, block); state.setType(genState.getType()); From e645df463c6f0ecdf2532a2cf8f5b36f159a264a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 17:52:13 +0200 Subject: [PATCH 173/366] Removed deprecation suppress --- src/main/java/com/songoda/skyblock/menus/Upgrade.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java index 784df982..7d4b10d8 100644 --- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java @@ -46,8 +46,7 @@ public class Upgrade { return instance; } - - @SuppressWarnings("deprecation") + public void open(Player player) { SkyBlock skyblock = SkyBlock.getInstance(); From 0e0848098147a904be7ae4a48bd7ed2e0c026a97 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 17:52:23 +0200 Subject: [PATCH 174/366] Config comments --- src/main/resources/config.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ed29bca0..78a6c4e6 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,3 +1,13 @@ +# ______ _ _ _ _____ _ ____ _ _ +# | ____| | | | | | |/ ____| | | _ \| | | | +# | |__ __ _| |__ | | ___ __| | (___ | | ___ _| |_) | | ___ ___| | __ +# | __/ _` | '_ \| |/ _ \/ _` |\___ \| |/ | | | | _ <| |/ _ \ / __| |/ / +# | | | (_| | |_) | | __| (_| |____) | <| |_| | |_) | | (_) | (__| < +# |_| \__,_|_.__/|_|\___|\__,_|_____/|_|\_\\__, |____/|_|\___/ \___|_|\_\ +# __/ | +# |___/ +# By Songoda <3 +# Command: Help: # Lists all commands rather than pages. @@ -322,6 +332,7 @@ Island: Enable: true # Check only the island owner's permissions # it requires Vault installed + # Experimental feature! CheckOnlyOwnerPermissions: false # Check permissions of all the online player in the island or just # the nearest player to the generator From a694bd9af93dfbacfbc9e8885b404a4a7f7ee6ad Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 8 Jul 2020 17:52:34 +0200 Subject: [PATCH 175/366] 2.3.5-RC1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 90d10a5f..ad44e4d7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.4 + 2.3.5-RC1 jar UTF-8 From eddd0424e1ab952a2eb5a90e9b2c1bf5b70fb324 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 07:33:29 +0200 Subject: [PATCH 176/366] Removed logo --- src/main/resources/config.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 78a6c4e6..39c8e702 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,13 +1,3 @@ -# ______ _ _ _ _____ _ ____ _ _ -# | ____| | | | | | |/ ____| | | _ \| | | | -# | |__ __ _| |__ | | ___ __| | (___ | | ___ _| |_) | | ___ ___| | __ -# | __/ _` | '_ \| |/ _ \/ _` |\___ \| |/ | | | | _ <| |/ _ \ / __| |/ / -# | | | (_| | |_) | | __| (_| |____) | <| |_| | |_) | | (_) | (__| < -# |_| \__,_|_.__/|_|\___|\__,_|_____/|_|\_\\__, |____/|_|\___/ \___|_|\_\ -# __/ | -# |___/ -# By Songoda <3 -# Command: Help: # Lists all commands rather than pages. From 8227888c845da66bb006d5631486d988bdd669ca Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 07:33:38 +0200 Subject: [PATCH 177/366] 2.3.5-RC2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ad44e4d7..966ef25e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC1 + 2.3.5-RC2 jar UTF-8 From 544485a216a3fa41fbfd3974c75047e44a155516 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 08:33:31 +0200 Subject: [PATCH 178/366] Typo in config --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 39c8e702..af42336d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,7 +12,7 @@ Island: Performance: # Chunk loading per tick affecting operations like island deletion, scan and biome changing. # This option is ignored when using Paper's async chunk load - # You should increase this only if you have an SSD + # You should increase this only if you have a SSD ChunkPerTick: 15 Size: # Warning: The maximum is capped at 1000 From dc315106bfbcbcbe4816f0f568a5c3571b562667 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 08:33:39 +0200 Subject: [PATCH 179/366] Create Manager class --- .../com/songoda/skyblock/manager/Manager.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/manager/Manager.java diff --git a/src/main/java/com/songoda/skyblock/manager/Manager.java b/src/main/java/com/songoda/skyblock/manager/Manager.java new file mode 100644 index 00000000..34c8e621 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/manager/Manager.java @@ -0,0 +1,23 @@ +package com.songoda.skyblock.manager; + +import com.songoda.skyblock.SkyBlock; + +public abstract class Manager { + + protected SkyBlock plugin; + + Manager(SkyBlock plugin) { + this.plugin = plugin; + } + + /** + * Reloads the Manager's settings + */ + public abstract void reload(); + + /** + * Cleans up the Manager's resources + */ + public abstract void disable(); + +} From 4e7d84933bccfbe78052c3d1481f970811f0f5fe Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 09:15:52 +0200 Subject: [PATCH 180/366] Some code optimizations --- .../songoda/skyblock/api/island/Island.java | 5 +- .../skyblock/api/island/IslandManager.java | 1 - .../java/com/songoda/skyblock/ban/Ban.java | 30 +- .../com/songoda/skyblock/ban/BanManager.java | 32 +- .../songoda/skyblock/bank/BankManager.java | 24 +- .../songoda/skyblock/bank/Transaction.java | 1 - .../songoda/skyblock/biome/BiomeManager.java | 20 +- .../skyblock/blockscanner/BlockScanner.java | 24 +- .../blockscanner/MaterialIDHelper.java | 7 +- .../skyblock/challenge/FabledChallenge.java | 21 +- .../challenge/challenge/Challenge.java | 2 - .../challenge/ChallengeCategory.java | 13 +- .../challenge/challenge/ChallengeManager.java | 20 +- .../challenge/challenge/ItemChallenge.java | 12 +- .../defaultinv/DefaultInventory.java | 15 +- .../challenge/inventory/ClickableItem.java | 4 +- .../challenge/inventory/Inventory.java | 8 +- .../challenge/inventory/InventoryManager.java | 21 +- .../inventory/InventoryProvider.java | 4 +- .../challenge/inventory/ItemBuilder.java | 13 +- .../inventory/inv/ChallengeInventory.java | 22 +- .../challenge/player/PlayerChallenge.java | 4 +- .../challenge/player/PlayerManager.java | 75 ++-- .../skyblock/command/CommandManager.java | 42 +-- .../songoda/skyblock/command/SubCommand.java | 6 +- .../commands/admin/AddUpgradeCommand.java | 14 +- .../command/commands/admin/AdminBank.java | 27 +- .../commands/admin/ChatSpyCommand.java | 15 +- .../command/commands/admin/CreateCommand.java | 4 +- .../command/commands/admin/DeleteCommand.java | 10 +- .../commands/admin/GeneratorCommand.java | 12 +- .../command/commands/admin/LevelCommand.java | 2 +- .../commands/admin/LevelScanCommand.java | 12 +- .../command/commands/admin/OwnerCommand.java | 10 +- .../command/commands/admin/ProxyCommand.java | 10 +- .../admin/RefreshHologramsCommand.java | 14 +- .../command/commands/admin/ReloadCommand.java | 57 ++- .../commands/admin/RemoveHologramCommand.java | 17 +- .../commands/admin/RemoveUpgradeCommand.java | 14 +- .../admin/SetAlwaysLoadedCommand.java | 29 +- .../commands/admin/SetBiomeCommand.java | 16 +- .../commands/admin/SetHologramCommand.java | 14 +- .../command/commands/admin/SetMaxMembers.java | 16 +- .../commands/admin/SetSizeCommand.java | 16 +- .../commands/admin/SetSpawnCommand.java | 10 +- .../commands/admin/SettingsCommand.java | 4 +- .../commands/admin/StackableCommand.java | 22 +- .../commands/admin/StructureCommand.java | 19 +- .../commands/admin/UpgradeCommand.java | 12 +- .../commands/island/AcceptCommand.java | 22 +- .../command/commands/island/BanCommand.java | 33 +- .../command/commands/island/BankCommand.java | 20 +- .../command/commands/island/BansCommand.java | 10 +- .../command/commands/island/BiomeCommand.java | 15 +- .../commands/island/BorderCommand.java | 14 +- .../commands/island/CancelCommand.java | 10 +- .../commands/island/ChallengeCommand.java | 29 +- .../command/commands/island/ChatCommand.java | 14 +- .../command/commands/island/CloseCommand.java | 10 +- .../commands/island/ConfirmCommand.java | 16 +- .../commands/island/ControlPanelCommand.java | 8 +- .../command/commands/island/CoopCommand.java | 14 +- .../commands/island/CreateCommand.java | 24 +- .../commands/island/CurrentCommand.java | 8 +- .../commands/island/DeleteCommand.java | 18 +- .../commands/island/DemoteCommand.java | 8 +- .../command/commands/island/DenyCommand.java | 8 +- .../commands/island/InformationCommand.java | 12 +- .../commands/island/InviteCommand.java | 20 +- .../commands/island/KickAllCommand.java | 10 +- .../command/commands/island/KickCommand.java | 51 ++- .../commands/island/LeaderboardCommand.java | 14 +- .../command/commands/island/LeaveCommand.java | 16 +- .../command/commands/island/LevelCommand.java | 16 +- .../commands/island/MembersCommand.java | 10 +- .../command/commands/island/OpenCommand.java | 10 +- .../command/commands/island/OwnerCommand.java | 16 +- .../commands/island/PreviewCommand.java | 32 +- .../commands/island/PromoteCommand.java | 8 +- .../commands/island/PublicCommand.java | 10 +- .../commands/island/ScoreboardCommand.java | 17 +- .../commands/island/SetSpawnCommand.java | 17 +- .../commands/island/SettingsCommand.java | 12 +- .../commands/island/TeleportCommand.java | 18 +- .../command/commands/island/UnbanCommand.java | 14 +- .../commands/island/UnlockCommand.java | 14 +- .../commands/island/UpgradeCommand.java | 10 +- .../command/commands/island/ValueCommand.java | 13 +- .../command/commands/island/VisitCommand.java | 14 +- .../commands/island/VisitorsCommand.java | 8 +- .../command/commands/island/VoteCommand.java | 16 +- .../commands/island/WeatherCommand.java | 12 +- .../commands/island/WhitelistCommand.java | 16 +- .../island/disabled/ResetCommand.java | 14 +- .../songoda/skyblock/config/FileChecker.java | 17 +- .../songoda/skyblock/config/FileManager.java | 91 +++-- .../confirmation/ConfirmationTask.java | 3 +- .../skyblock/cooldown/CooldownManager.java | 61 ++-- .../songoda/skyblock/generator/Generator.java | 1 - .../skyblock/generator/GeneratorManager.java | 11 +- .../songoda/skyblock/gui/bank/GuiBank.java | 19 - .../skyblock/gui/bank/GuiBankSelector.java | 2 - .../songoda/skyblock/gui/biome/BiomeIcon.java | 2 - .../songoda/skyblock/gui/biome/GuiBiome.java | 5 +- .../gui/permissions/GuiAdminPermissions.java | 6 - .../com/songoda/skyblock/gui/wip/GuiBans.java | 1 - .../skyblock/invite/InviteManager.java | 4 +- .../songoda/skyblock/invite/InviteTask.java | 12 +- .../com/songoda/skyblock/island/Island.java | 220 ++++++------ .../songoda/skyblock/island/IslandLevel.java | 40 +-- .../skyblock/island/IslandManager.java | 331 +++++++++--------- .../island/removal/ChunkDeleteSplitter.java | 20 +- .../skyblock/island/reward/LevelReward.java | 8 +- .../leaderboard/LeaderboardManager.java | 24 +- .../skyblock/leaderboard/LeaderboardTask.java | 12 +- .../leaderboard/leaderheads/TopBank.java | 10 +- .../leaderboard/leaderheads/TopLevel.java | 10 +- .../leaderboard/leaderheads/TopVotes.java | 10 +- .../levelling/IslandLevelManager.java | 30 +- .../skyblock/levelling/IslandScan.java | 30 +- .../calculator/CalculatorRegistry.java | 4 +- .../impl/EpicSpawnerCalculator.java | 3 +- .../impl/UltimateStackerCalculator.java | 3 +- .../skyblock/limit/EnumLimitation.java | 4 +- .../limit/LimitationInstanceHandler.java | 11 +- .../skyblock/limit/impl/BlockLimitation.java | 1 - .../skyblock/limit/impl/EntityLimitaton.java | 11 +- .../com/songoda/skyblock/listeners/Block.java | 140 ++++---- .../songoda/skyblock/listeners/Bucket.java | 29 +- .../com/songoda/skyblock/listeners/Chat.java | 34 +- .../com/songoda/skyblock/listeners/Death.java | 14 +- .../songoda/skyblock/listeners/Entity.java | 148 ++++---- .../skyblock/listeners/EpicSpawners.java | 25 +- .../songoda/skyblock/listeners/FallBreak.java | 12 +- .../com/songoda/skyblock/listeners/Food.java | 10 +- .../com/songoda/skyblock/listeners/Grow.java | 65 ++-- .../songoda/skyblock/listeners/Interact.java | 111 +++--- .../songoda/skyblock/listeners/Inventory.java | 12 +- .../com/songoda/skyblock/listeners/Item.java | 19 +- .../com/songoda/skyblock/listeners/Join.java | 32 +- .../com/songoda/skyblock/listeners/Move.java | 63 ++-- .../songoda/skyblock/listeners/Piston.java | 12 +- .../songoda/skyblock/listeners/Portal.java | 33 +- .../skyblock/listeners/Projectile.java | 13 +- .../com/songoda/skyblock/listeners/Quit.java | 37 +- .../songoda/skyblock/listeners/Respawn.java | 16 +- .../songoda/skyblock/listeners/Spawner.java | 12 +- .../songoda/skyblock/listeners/Teleport.java | 30 +- .../skyblock/listeners/UltimateStacker.java | 19 +- .../localization/LocalizationManager.java | 15 +- .../localization/type/Localization.java | 4 +- .../type/impl/BlankLocalization.java | 7 +- .../type/impl/EnumLocalization.java | 7 +- .../impl/MaterialsToMaterialLocalization.java | 1 - .../java/com/songoda/skyblock/menus/Bans.java | 31 +- .../com/songoda/skyblock/menus/Biome.java | 25 +- .../com/songoda/skyblock/menus/Border.java | 27 +- .../songoda/skyblock/menus/ControlPanel.java | 21 +- .../java/com/songoda/skyblock/menus/Coop.java | 29 +- .../com/songoda/skyblock/menus/Creator.java | 36 +- .../songoda/skyblock/menus/Information.java | 43 ++- .../songoda/skyblock/menus/Leaderboard.java | 33 +- .../com/songoda/skyblock/menus/Levelling.java | 69 ++-- .../com/songoda/skyblock/menus/Members.java | 45 ++- .../com/songoda/skyblock/menus/Ownership.java | 33 +- .../com/songoda/skyblock/menus/Settings.java | 117 +++---- .../com/songoda/skyblock/menus/Upgrade.java | 51 ++- .../com/songoda/skyblock/menus/Visit.java | 37 +- .../com/songoda/skyblock/menus/Visitors.java | 37 +- .../com/songoda/skyblock/menus/Weather.java | 31 +- .../songoda/skyblock/menus/admin/Creator.java | 170 ++++----- .../skyblock/menus/admin/Generator.java | 79 +++-- .../skyblock/menus/admin/Levelling.java | 52 +-- .../songoda/skyblock/menus/admin/Upgrade.java | 83 +++-- .../skyblock/message/MessageManager.java | 10 +- .../skyblock/permission/BasicPermission.java | 1 - .../permission/PermissionManager.java | 2 - .../events/ProjectileLaunchByPlayerEvent.java | 2 - .../listening/BrewingPermission.java | 3 - .../listening/DamagePermission.java | 1 - .../listening/DestroyPermission.java | 5 +- .../listening/EntityPlacementPermission.java | 2 - .../listening/ExplosionsPermission.java | 2 - .../permissions/listening/FirePermission.java | 1 - .../listening/FishingPermission.java | 1 - .../listening/HangingDestroyPermission.java | 5 +- .../listening/HungerPermission.java | 2 - .../listening/ItemPickupPermission.java | 1 - .../listening/MonsterHurtingPermission.java | 6 +- .../listening/PortalPermission.java | 4 - .../listening/ProjectilePermission.java | 1 - .../listening/StoragePermission.java | 2 - .../skyblock/placeholder/EZPlaceholder.java | 18 +- .../skyblock/placeholder/MVdWPlaceholder.java | 22 +- .../placeholder/PlaceholderManager.java | 74 ++-- .../skyblock/playerdata/PlayerData.java | 17 +- .../playerdata/PlayerDataManager.java | 40 +-- .../skyblock/scoreboard/Scoreboard.java | 31 +- .../scoreboard/ScoreboardManager.java | 30 +- .../songoda/skyblock/sound/SoundManager.java | 10 +- .../songoda/skyblock/stackable/Stackable.java | 14 +- .../skyblock/stackable/StackableManager.java | 27 +- .../songoda/skyblock/structure/Structure.java | 1 - .../skyblock/structure/StructureManager.java | 7 +- .../skyblock/tasks/MobNetherWaterTask.java | 19 +- .../skyblock/upgrade/UpgradeManager.java | 16 +- .../skyblock/usercache/UserCacheManager.java | 31 +- .../songoda/skyblock/utils/Compression.java | 6 +- .../songoda/skyblock/utils/Reflections.java | 8 +- .../songoda/skyblock/utils/StringUtil.java | 4 +- .../skyblock/utils/item/ItemStackUtil.java | 3 +- .../utils/item/MenuClickRegistry.java | 17 +- .../skyblock/utils/item/SkullUtil.java | 2 - .../skyblock/utils/player/NameFetcher.java | 4 +- .../skyblock/utils/player/OfflinePlayer.java | 12 +- .../skyblock/utils/player/PlayerUtil.java | 4 +- .../utils/structure/StructureUtil.java | 14 +- .../skyblock/utils/world/LocationUtil.java | 24 +- .../skyblock/utils/world/WorldBorder.java | 12 +- .../utils/world/entity/EntityUtil.java | 1 - .../com/songoda/skyblock/visit/Visit.java | 36 +- .../songoda/skyblock/visit/VisitManager.java | 50 +-- .../com/songoda/skyblock/visit/VisitTask.java | 3 +- .../songoda/skyblock/world/WorldManager.java | 18 +- .../world/generator/VoidGenerator.java | 11 +- 225 files changed, 2460 insertions(+), 2666 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/api/island/Island.java b/src/main/java/com/songoda/skyblock/api/island/Island.java index 67323db3..86bd6849 100644 --- a/src/main/java/com/songoda/skyblock/api/island/Island.java +++ b/src/main/java/com/songoda/skyblock/api/island/Island.java @@ -15,7 +15,10 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; public class Island { diff --git a/src/main/java/com/songoda/skyblock/api/island/IslandManager.java b/src/main/java/com/songoda/skyblock/api/island/IslandManager.java index 6e20c504..d35b8d44 100644 --- a/src/main/java/com/songoda/skyblock/api/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/api/island/IslandManager.java @@ -4,7 +4,6 @@ import com.google.common.base.Preconditions; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.api.structure.Structure; import com.songoda.skyblock.api.utils.APIUtil; -import com.songoda.skyblock.island.IslandPermission; import com.songoda.skyblock.permission.PermissionManager; import org.bukkit.Location; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/com/songoda/skyblock/ban/Ban.java b/src/main/java/com/songoda/skyblock/ban/Ban.java index 47dc9a57..e7879239 100644 --- a/src/main/java/com/songoda/skyblock/ban/Ban.java +++ b/src/main/java/com/songoda/skyblock/ban/Ban.java @@ -32,12 +32,12 @@ public class Ban { } public Set getBans() { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); Set islandBans = new HashSet<>(); - for (String islandBanList : skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"), + for (String islandBanList : plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration().getStringList("Bans")) { @@ -52,18 +52,18 @@ public class Ban { } public void addBan(UUID issuer, UUID banned) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); IslandBanEvent islandBanEvent = new IslandBanEvent( - skyblock.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)) + plugin.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)) .getAPIWrapper(), Bukkit.getServer().getOfflinePlayer(issuer), Bukkit.getServer().getOfflinePlayer(banned)); - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent)); if (!islandBanEvent.isCancelled()) { List islandBans = new ArrayList<>(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"), + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration(); @@ -77,11 +77,11 @@ public class Ban { } public void removeBan(UUID uuid) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); List islandBans = new ArrayList<>(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"), + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration(); @@ -94,16 +94,16 @@ public class Ban { configLoad.set("Bans", islandBans); Bukkit.getServer().getPluginManager() - .callEvent(new IslandUnbanEvent(skyblock.getIslandManager() + .callEvent(new IslandUnbanEvent(plugin.getIslandManager() .getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).getAPIWrapper(), Bukkit.getServer().getOfflinePlayer(uuid))); } public void save() { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - Config config = skyblock.getFileManager().getConfig(new File( - new File(skyblock.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File( + new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")); try { config.getFileConfiguration().save(config.getFile()); diff --git a/src/main/java/com/songoda/skyblock/ban/BanManager.java b/src/main/java/com/songoda/skyblock/ban/BanManager.java index e9f792c0..b156f475 100644 --- a/src/main/java/com/songoda/skyblock/ban/BanManager.java +++ b/src/main/java/com/songoda/skyblock/ban/BanManager.java @@ -19,11 +19,11 @@ import java.util.UUID; public class BanManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private Map banStorage = new HashMap<>(); - public BanManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public BanManager(SkyBlock plugin) { + this.plugin = plugin; loadIslands(); } @@ -37,11 +37,11 @@ public class BanManager { } public void loadIslands() { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Visitor.Unload")) { - File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); + File configFile = new File(plugin.getDataFolder().toString() + "/island-data"); if (configFile.exists()) { for (File fileList : configFile.listFiles()) { @@ -53,14 +53,14 @@ public class BanManager { } public void transfer(UUID uuid1, UUID uuid2) { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); Ban ban = getIsland(uuid1); ban.save(); - File oldBanDataFile = new File(new File(skyblock.getDataFolder().toString() + "/ban-data"), + File oldBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"), uuid1.toString() + ".yml"); - File newBanDataFile = new File(new File(skyblock.getDataFolder().toString() + "/ban-data"), + File newBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"), uuid2.toString() + ".yml"); fileManager.unloadConfig(oldBanDataFile); @@ -73,14 +73,14 @@ public class BanManager { } public void removeVisitor(Island island) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - for (UUID visitorList : skyblock.getIslandManager().getVisitorsAtIsland(island)) { + for (UUID visitorList : plugin.getIslandManager().getVisitorsAtIsland(island)) { Player targetPlayer = Bukkit.getServer().getPlayer(visitorList); LocationUtil.teleportPlayerToSpawn(targetPlayer); @@ -116,7 +116,7 @@ public class BanManager { public void unloadIsland(UUID islandOwnerUUID) { if (hasIsland(islandOwnerUUID)) { - skyblock.getFileManager().unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"), + plugin.getFileManager().unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")); banStorage.remove(islandOwnerUUID); } @@ -124,7 +124,7 @@ public class BanManager { public void deleteIsland(UUID islandOwnerUUID) { if (hasIsland(islandOwnerUUID)) { - skyblock.getFileManager().deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"), + plugin.getFileManager().deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")); banStorage.remove(islandOwnerUUID); } diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 466c1f65..21ceae38 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -1,21 +1,13 @@ package com.songoda.skyblock.bank; -import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; -import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.*; public class BankManager { @@ -28,8 +20,8 @@ public class BankManager { public FileConfiguration lang; public BankManager() { - SkyBlock skyblock = SkyBlock.getInstance(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + SkyBlock plugin = SkyBlock.getInstance(); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); lang = config.getFileConfiguration(); log = new HashMap<>(); loadTransactions(); @@ -105,8 +97,8 @@ public class BankManager { } public BankResponse deposit(Player player, Island island, double amt, boolean admin) { - SkyBlock skyblock = SkyBlock.getInstance(); - FileManager fileManager = skyblock.getFileManager(); + SkyBlock plugin = SkyBlock.getInstance(); + FileManager fileManager = plugin.getFileManager(); // Make sure the amount is positive if (amt <= 0) { @@ -114,7 +106,7 @@ public class BankManager { } // If decimals aren't allowed, check for them - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { int intAmt = (int) amt; if (intAmt != amt) { return BankResponse.DECIMALS_NOT_ALLOWED; @@ -141,8 +133,8 @@ public class BankManager { } public BankResponse withdraw(Player player, Island island, double amt, boolean admin) { - SkyBlock skyblock = SkyBlock.getInstance(); - FileManager fileManager = skyblock.getFileManager(); + SkyBlock plugin = SkyBlock.getInstance(); + FileManager fileManager = plugin.getFileManager(); // Make sure the amount is positive if (amt <= 0) { @@ -150,7 +142,7 @@ public class BankManager { } // If decimals aren't allowed, check for them - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { int intAmt = (int) amt; if (intAmt != amt) { return BankResponse.DECIMALS_NOT_ALLOWED; diff --git a/src/main/java/com/songoda/skyblock/bank/Transaction.java b/src/main/java/com/songoda/skyblock/bank/Transaction.java index 72e75673..e3567047 100644 --- a/src/main/java/com/songoda/skyblock/bank/Transaction.java +++ b/src/main/java/com/songoda/skyblock/bank/Transaction.java @@ -1,6 +1,5 @@ package com.songoda.skyblock.bank; -import com.songoda.skyblock.menus.Ownership; import org.bukkit.OfflinePlayer; import java.util.Date; diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 8efd726c..3c3d407c 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -22,13 +22,13 @@ import java.util.concurrent.atomic.AtomicInteger; public class BiomeManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private final List updatingIslands; private final FileConfiguration language; private final int runEveryX; - public BiomeManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public BiomeManager(SkyBlock plugin) { + this.plugin = plugin; this.updatingIslands = new ArrayList<>(); this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration(); this.runEveryX = language.getInt("Command.Island.Biome.Progress.Display-Every-X-Updates"); @@ -51,12 +51,12 @@ public class BiomeManager { if (island.getLocation(IslandWorld.Normal, IslandEnvironment.Island) == null) return; - if(skyblock.isPaperAsync()){ + if(plugin.isPaperAsync()){ // We keep it sequentially in order to use less RAM int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d)); AtomicInteger progress = new AtomicInteger(); - ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunk, syncChunk) -> { + ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunk, syncChunk) -> { Chunk chunk = asyncChunk.join(); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there setChunkBiome3D(island, biome, chunk); // 2D for the moment @@ -77,7 +77,7 @@ public class BiomeManager { message = message.replace("%percent%", NumberFormat.getInstance().format(percent)); for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { - skyblock.getMessageManager().sendMessage(player, message); + plugin.getMessageManager().sendMessage(player, message); } } }, (island1 -> { @@ -87,8 +87,8 @@ public class BiomeManager { } })); } else { - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { int progress = 0; for(Chunk chunk : syncChunks){ if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there @@ -109,7 +109,7 @@ public class BiomeManager { message = message.replace("%percent%", NumberFormat.getInstance().format(percent)); for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { - skyblock.getMessageManager().sendMessage(player, message); + plugin.getMessageManager().sendMessage(player, message); } } } @@ -153,7 +153,7 @@ public class BiomeManager { packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk"); chunkClass = NMSUtil.getNMSClass("Chunk"); - for (Player player : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) { + for (Player player : plugin.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) { try { if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index 5f8034f6..8cd3f4bd 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -1,5 +1,16 @@ package com.songoda.skyblock.blockscanner; +import com.google.common.collect.Lists; +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.utils.version.NMSUtil; +import org.bukkit.Bukkit; +import org.bukkit.ChunkSnapshot; +import org.bukkit.World; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.scheduler.BukkitRunnable; + import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -9,19 +20,6 @@ import java.util.Map.Entry; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import com.songoda.core.compatibility.CompatibleMaterial; -import org.bukkit.Bukkit; -import org.bukkit.ChunkSnapshot; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.scheduler.BukkitRunnable; - -import com.google.common.collect.Lists; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.utils.version.NMSUtil; - public final class BlockScanner extends BukkitRunnable { private static final Method ID_FIELD; diff --git a/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java b/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java index 8a6dbd45..fecc94d2 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java @@ -1,12 +1,11 @@ package com.songoda.skyblock.blockscanner; +import com.songoda.skyblock.utils.version.NMSUtil; +import org.bukkit.Material; + import java.util.HashMap; import java.util.Map; -import org.bukkit.Material; - -import com.songoda.skyblock.utils.version.NMSUtil; - @SuppressWarnings("deprecation") public final class MaterialIDHelper { diff --git a/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java b/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java index 3c777884..ede403f1 100644 --- a/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java @@ -1,8 +1,5 @@ package com.songoda.skyblock.challenge; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.challenge.challenge.ChallengeCategory; import com.songoda.skyblock.challenge.challenge.ChallengeManager; @@ -10,9 +7,11 @@ import com.songoda.skyblock.challenge.defaultinv.DefaultInventory; import com.songoda.skyblock.challenge.inventory.InventoryManager; import com.songoda.skyblock.challenge.inventory.inv.ChallengeInventory; import com.songoda.skyblock.challenge.player.PlayerManager; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; public class FabledChallenge { - private SkyBlock skyblock; + private SkyBlock plugin; private ChallengeManager challengeManager; private PlayerManager playerManager; // I use my own inventory api bc it's hard to implement inventories with the @@ -20,13 +19,13 @@ public class FabledChallenge { private DefaultInventory defaultInventory; private ChallengeInventory challengeInventory; - public FabledChallenge(SkyBlock skyblock) { - this.skyblock = skyblock; - this.defaultInventory = new DefaultInventory(skyblock); - this.challengeManager = new ChallengeManager(skyblock); - this.playerManager = new PlayerManager(skyblock); + public FabledChallenge(SkyBlock plugin) { + this.plugin = plugin; + this.defaultInventory = new DefaultInventory(plugin); + this.challengeManager = new ChallengeManager(plugin); + this.playerManager = new PlayerManager(plugin); this.challengeInventory = new ChallengeInventory(this); - this.inventoryManager = new InventoryManager(skyblock); + this.inventoryManager = new InventoryManager(plugin); this.inventoryManager.init(); } @@ -37,7 +36,7 @@ public class FabledChallenge { public void openChallengeInventory(Player p, ChallengeCategory category) { if (category == null) return; - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> { + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { inventoryManager.openInventory(challengeInventory, p, params -> { params.put(ChallengeInventory.CATEGORY, category); }); 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 d1f729ad..e8a832f4 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -1,12 +1,10 @@ package com.songoda.skyblock.challenge.challenge; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.utils.item.ItemStackUtil; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Entity; diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java index 3e48ffb6..695c748d 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java @@ -1,17 +1,16 @@ package com.songoda.skyblock.challenge.challenge; +import com.songoda.core.compatibility.CompatibleMaterial; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Set; -import com.songoda.core.compatibility.CompatibleMaterial; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; - public class ChallengeCategory { private int id; private String name; diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java index 96008a7d..c317b002 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java @@ -1,30 +1,28 @@ package com.songoda.skyblock.challenge.challenge; -import java.io.File; -import java.util.HashMap; -import java.util.logging.Level; - -import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager.Config; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager.Config; +import java.io.File; +import java.util.HashMap; +import java.util.logging.Level; public class ChallengeManager { - private SkyBlock skyblock; + private SkyBlock plugin; private HashMap categories; - public ChallengeManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public ChallengeManager(SkyBlock plugin) { + this.plugin = plugin; categories = new HashMap<>(); loadChallenges(); } private void loadChallenges() { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "challenges.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml")); FileConfiguration configLoad = config.getFileConfiguration(); try { diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java index 8f000cdc..f2a8ea8a 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java @@ -1,18 +1,16 @@ package com.songoda.skyblock.challenge.challenge; -import java.io.File; -import java.util.List; -import java.util.UUID; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; +import java.io.File; +import java.util.List; +import java.util.UUID; public class ItemChallenge { private Challenge challenge; diff --git a/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java b/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java index b53a49ee..1ddd0681 100644 --- a/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java +++ b/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java @@ -1,10 +1,8 @@ package com.songoda.skyblock.challenge.defaultinv; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager.Config; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -13,16 +11,17 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager.Config; +import java.io.File; +import java.util.ArrayList; +import java.util.List; public class DefaultInventory { private final Item defaultItem = new Item(new ItemStack(Material.AIR)); private int size; private Item[][] items; - public DefaultInventory(SkyBlock skyblock) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "challenges.yml")); + public DefaultInventory(SkyBlock plugin) { + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml")); FileConfiguration configLoad = config.getFileConfiguration(); size = configLoad.getInt("inventory.size"); items = new Item[9][size]; diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java b/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java index 52ad8045..dbdd18a8 100644 --- a/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java +++ b/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java @@ -3,11 +3,11 @@ */ package com.songoda.skyblock.challenge.inventory; -import java.util.function.Consumer; - import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; +import java.util.function.Consumer; + public class ClickableItem { private ItemStack item; private Consumer event; diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java b/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java index 13540763..8c746935 100644 --- a/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java +++ b/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java @@ -3,15 +3,15 @@ */ package com.songoda.skyblock.challenge.inventory; -import java.util.HashMap; -import java.util.List; -import java.util.function.Consumer; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; +import java.util.HashMap; +import java.util.List; +import java.util.function.Consumer; + public class Inventory { public static final String TICK = "tick"; private HashMap values; diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java index fd653084..3f59d5dc 100644 --- a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java +++ b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java @@ -3,11 +3,7 @@ */ package com.songoda.skyblock.challenge.inventory; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.UUID; -import java.util.function.Consumer; - +import com.songoda.skyblock.SkyBlock; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -18,21 +14,24 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import com.songoda.skyblock.SkyBlock; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.UUID; +import java.util.function.Consumer; public class InventoryManager implements Listener { - private SkyBlock skyblock; + private SkyBlock plugin; private HashMap inventories; private int task; - public InventoryManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public InventoryManager(SkyBlock plugin) { + this.plugin = plugin; this.inventories = new HashMap<>(); } public void init() { - Bukkit.getPluginManager().registerEvents(this, skyblock); - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(skyblock, () -> { + Bukkit.getPluginManager().registerEvents(this, plugin); + task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> { if (inventories.size() == 0) return; for (Inventory inv : inventories.values()) { diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java index ee1aa479..a8140100 100644 --- a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java +++ b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java @@ -3,11 +3,11 @@ */ package com.songoda.skyblock.challenge.inventory; +import org.bukkit.event.inventory.InventoryCloseEvent; + import java.util.ArrayList; import java.util.List; -import org.bukkit.event.inventory.InventoryCloseEvent; - public interface InventoryProvider { public String title(Inventory inv); diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/ItemBuilder.java b/src/main/java/com/songoda/skyblock/challenge/inventory/ItemBuilder.java index f4310b27..235e6b15 100644 --- a/src/main/java/com/songoda/skyblock/challenge/inventory/ItemBuilder.java +++ b/src/main/java/com/songoda/skyblock/challenge/inventory/ItemBuilder.java @@ -3,11 +3,8 @@ */ package com.songoda.skyblock.challenge.inventory; -import java.lang.reflect.Field; -import java.util.List; -import java.util.UUID; -import java.util.logging.Level; - +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -15,8 +12,10 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; +import java.lang.reflect.Field; +import java.util.List; +import java.util.UUID; +import java.util.logging.Level; public class ItemBuilder { private Material m; 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 3cd2cffa..5bc8e7de 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 @@ -1,18 +1,6 @@ package com.songoda.skyblock.challenge.inventory.inv; -import java.util.HashMap; -import java.util.function.Consumer; -import java.util.logging.Level; - import com.songoda.core.compatibility.CompatibleSound; -import org.bukkit.Bukkit; -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; import com.songoda.skyblock.challenge.challenge.Challenge; import com.songoda.skyblock.challenge.challenge.ChallengeCategory; @@ -22,8 +10,18 @@ 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.Bukkit; +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 org.bukkit.inventory.meta.ItemMeta; +import java.util.HashMap; +import java.util.function.Consumer; +import java.util.logging.Level; + public class ChallengeInventory implements InventoryProvider { public static final String CATEGORY = "ChallengeCategory"; private FabledChallenge fc; diff --git a/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java b/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java index fc8e91cc..10786162 100644 --- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java @@ -1,10 +1,10 @@ package com.songoda.skyblock.challenge.player; +import com.songoda.skyblock.challenge.challenge.Challenge; + import java.util.HashMap; import java.util.UUID; -import com.songoda.skyblock.challenge.challenge.Challenge; - public class PlayerChallenge { private UUID uuid; private HashMap challenges; 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 4cd66833..fff46221 100644 --- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java +++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java @@ -1,5 +1,18 @@ package com.songoda.skyblock.challenge.player; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.challenge.challenge.Challenge; +import com.songoda.skyblock.challenge.challenge.Challenge.Type; +import com.songoda.skyblock.challenge.challenge.ChallengeCategory; +import com.songoda.skyblock.challenge.challenge.Peer; +import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.island.Island; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -7,33 +20,19 @@ 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; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.challenge.challenge.Challenge; -import com.songoda.skyblock.challenge.challenge.Challenge.Type; -import com.songoda.skyblock.challenge.challenge.ChallengeCategory; -import com.songoda.skyblock.challenge.challenge.Peer; -import com.songoda.skyblock.config.FileManager.Config; - public class PlayerManager { - private SkyBlock skyblock; + private SkyBlock plugin; private HashMap> islands; private File playersDirectory; - public PlayerManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public PlayerManager(SkyBlock plugin) { + this.plugin = plugin; islands = new HashMap<>(); - playersDirectory = new File(skyblock.getDataFolder(), "challenge-data"); + playersDirectory = new File(plugin.getDataFolder(), "challenge-data"); if (!playersDirectory.exists()) playersDirectory.mkdirs(); - Bukkit.getScheduler().runTask(skyblock, () -> { + Bukkit.getScheduler().runTask(plugin, () -> { for(Player p : Bukkit.getServer().getOnlinePlayers()){ loadPlayer(p.getUniqueId()); } @@ -41,9 +40,9 @@ public class PlayerManager { } public HashMap getPlayer(UUID uuid) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); if(is != null){ uuid = is.getOwnerUUID(); } @@ -58,14 +57,14 @@ public class PlayerManager { * The uuid of specific player */ public void loadPlayer(UUID uuid) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); if(is != null){ uuid = is.getOwnerUUID(); } } - Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, + Config config = plugin.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); HashMap challenges = new HashMap<>(); @@ -73,7 +72,7 @@ public class PlayerManager { Set strs = (section != null) ? section.getKeys(false) : new HashSet<>(); for (String k : strs) { int id = fileConfig.getInt("challenges." + k + ".id"); - ChallengeCategory cc = skyblock.getFabledChallenge().getChallengeManager().getChallenge(id); + ChallengeCategory cc = plugin.getFabledChallenge().getChallengeManager().getChallenge(id); // WTF if (cc == null) continue; @@ -99,15 +98,15 @@ public class PlayerManager { * The uuid of specific player */ public void unloadPlayer(UUID uuid) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); if(is != null){ uuid = is.getOwnerUUID(); } } islands.remove(uuid); - skyblock.getFileManager().unloadConfig(new File(playersDirectory, + plugin.getFileManager().unloadConfig(new File(playersDirectory, uuid.toString() + ".yml")); } @@ -125,9 +124,9 @@ public class PlayerManager { if (c == null) return false; UUID uuid = p.getUniqueId(); - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); if(is != null){ uuid = is.getOwnerUUID(); } @@ -161,9 +160,9 @@ public class PlayerManager { if (!canDoChallenge(p, c)) return false; UUID uuid = p.getUniqueId(); - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); if(is != null){ uuid = is.getOwnerUUID(); } @@ -192,14 +191,14 @@ public class PlayerManager { } public void addChallenge(UUID uuid, Challenge c) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); if(is != null){ uuid = is.getOwnerUUID(); } } - Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, + Config config = plugin.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); int ccId = c.getCategory().getId(); @@ -231,16 +230,16 @@ public class PlayerManager { if (challenges != null) { return challenges.getOrDefault(c, 0); } else { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); if(is != null){ uuid = is.getOwnerUUID(); } } // Not connected, check in file - Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, + Config config = plugin.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); int ccId = c.getCategory().getId(); diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index fcdbe20f..8e8b6f02 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -33,15 +33,15 @@ import java.util.List; public class CommandManager implements CommandExecutor, TabCompleter { - private final SkyBlock skyblock; + private final SkyBlock plugin; private List islandCommands; private List adminCommands; - public CommandManager(SkyBlock skyblock) { - this.skyblock = skyblock; - - skyblock.getCommand("island").setExecutor(this); - skyblock.getCommand("island").setTabCompleter(this); + public CommandManager(SkyBlock plugin) { + this.plugin = plugin; + + plugin.getCommand("island").setExecutor(this); + plugin.getCommand("island").setTabCompleter(this); registerSubCommands(); } @@ -125,11 +125,11 @@ public class CommandManager implements CommandExecutor, TabCompleter { @Override public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { if (command.getName().equalsIgnoreCase("island")) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Player player = null; @@ -142,8 +142,8 @@ public class CommandManager implements CommandExecutor, TabCompleter { if (player == null) { sendConsoleHelpCommands(sender); } else { - if (skyblock.getIslandManager().getIsland(player) == null) { - Bukkit.getServer().getScheduler().runTask(skyblock, () -> Bukkit.getServer().dispatchCommand(sender, "island create")); + if (plugin.getIslandManager().getIsland(player) == null) { + Bukkit.getServer().getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(sender, "island create")); } else { boolean canUseControlPanel = player.hasPermission("fabledskyblock.*") || player.hasPermission("fabledskyblock.island.*") @@ -182,7 +182,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { int page = -1; - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Command.Help.List")) { page = 1; @@ -220,7 +220,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { int page = -1; - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Command.Help.List")) { page = 1; @@ -395,21 +395,21 @@ public class CommandManager implements CommandExecutor, TabCompleter { } public void sendPlayerHelpCommands(Player player, List subCommands, int page, boolean isAdmin) { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); int pageSize = 7; int nextEndIndex = subCommands.size() - page * pageSize, index = page * pageSize - pageSize, endIndex = index >= subCommands.size() ? subCommands.size() - 1 : index + pageSize; - boolean showAlises = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + boolean showAlises = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Command.Help.Aliases.Enable"); if (nextEndIndex <= -7) { - skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Help.Page.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Help.Page.Message")); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); return; } @@ -482,7 +482,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { } } } else { - skyblock.getMessageManager().sendMessage(player, helpLines); + plugin.getMessageManager().sendMessage(player, helpLines); } } @@ -537,7 +537,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { } } - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); } public void sendConsoleHelpCommands(CommandSender sender) { diff --git a/src/main/java/com/songoda/skyblock/command/SubCommand.java b/src/main/java/com/songoda/skyblock/command/SubCommand.java index 85bf087c..0c4315ae 100644 --- a/src/main/java/com/songoda/skyblock/command/SubCommand.java +++ b/src/main/java/com/songoda/skyblock/command/SubCommand.java @@ -10,12 +10,12 @@ import java.io.File; public abstract class SubCommand { - protected final SkyBlock skyblock; + protected final SkyBlock plugin; protected final String info; public SubCommand() { - this.skyblock = SkyBlock.getInstance(); - this.info = ChatColor.translateAlternateColorCodes('&', this.skyblock.getFileManager().getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString(this.getInfoMessagePath())); + this.plugin = SkyBlock.getInstance(); + this.info = ChatColor.translateAlternateColorCodes('&', this.plugin.getFileManager().getConfig(new File(this.plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString(this.getInfoMessagePath())); } public abstract void onCommandByPlayer(Player player, String[] args); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java index 0bdba737..76967c3b 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java @@ -35,13 +35,13 @@ public class AddUpgradeCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 2) { @@ -88,7 +88,7 @@ public class AddUpgradeCommand extends SubCommand { island.setUpgrade(null, upgrade, true); } else { - File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data", + File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml"); if (!fileManager.isFileExist(islandDataFile)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index f9cee773..e316f3c3 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -17,7 +17,6 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; -import java.util.Objects; import java.util.UUID; public class AdminBank extends SubCommand { @@ -25,25 +24,25 @@ public class AdminBank extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); + SoundManager soundManager = plugin.getSoundManager(); - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIslandAtLocation(player.getLocation()); - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) { + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); return; } if (args.length < 1) { - skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); + plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true)); } else { switch (args[0].toLowerCase()) { case "balance": @@ -84,7 +83,7 @@ public class AdminBank extends SubCommand { island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); } if (island != null){ - skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true)); + plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true)); } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); @@ -99,11 +98,11 @@ public class AdminBank extends SubCommand { @Override public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length < 2) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java index 6b62c118..6f68d294 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java @@ -1,10 +1,8 @@ package com.songoda.skyblock.command.commands.admin; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.gui.bank.GuiBank; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; @@ -12,7 +10,6 @@ import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; -import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -25,13 +22,13 @@ public class ChatSpyCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); + SoundManager soundManager = plugin.getSoundManager(); - FileManager.Config language = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config language = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration languageLoad = language.getFileConfiguration(); PlayerData playerData = playerDataManager.getPlayerData(player); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/CreateCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/CreateCommand.java index 2cbdc5ce..05eb0022 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/CreateCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/CreateCommand.java @@ -12,8 +12,8 @@ public class CreateCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + SoundManager soundManager = plugin.getSoundManager(); if (playerDataManager.hasPlayerData(player)) { playerDataManager.getPlayerData(player).setViewer(null); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java index da182ad6..1cfc388d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/DeleteCommand.java @@ -35,12 +35,12 @@ public class DeleteCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Player player = null; diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/GeneratorCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/GeneratorCommand.java index dbaf5f43..4dfdd5e8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/GeneratorCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/GeneratorCommand.java @@ -18,15 +18,15 @@ public class GeneratorCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (skyblock.getGeneratorManager() == null) { + if (plugin.getGeneratorManager() == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Generator.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelCommand.java index 90ef67c4..9fbf3bad 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelCommand.java @@ -11,7 +11,7 @@ public class LevelCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - SoundManager soundManager = skyblock.getSoundManager(); + SoundManager soundManager = plugin.getSoundManager(); Levelling.getInstance().open(player); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java index a54509b6..53c0f63d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java @@ -30,13 +30,13 @@ public class LevelScanCommand extends SubCommand { } private void onCommand(CommandSender sender, String[] args) { - IslandLevelManager levellingManager = skyblock.getLevellingManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 0) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/OwnerCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/OwnerCommand.java index c402e247..fa0c8c08 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/OwnerCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/OwnerCommand.java @@ -30,12 +30,12 @@ public class OwnerCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java index d5ad7cf6..8aa8cd60 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ProxyCommand.java @@ -30,12 +30,12 @@ public class ProxyCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/RefreshHologramsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/RefreshHologramsCommand.java index 17002a3c..82976683 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/RefreshHologramsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/RefreshHologramsCommand.java @@ -28,20 +28,20 @@ public class RefreshHologramsCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); leaderboardManager.clearLeaderboard(); leaderboardManager.resetLeaderboard(); leaderboardManager.setupLeaderHeads(); - Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramTask().updateHologram()); + Bukkit.getScheduler().runTask(plugin, () -> plugin.getHologramTask().updateHologram()); }); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java index d776e29c..bb191456 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java @@ -1,20 +1,11 @@ package com.songoda.skyblock.command.commands.admin; -import java.io.File; -import java.util.Map; - import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.skyblock.island.reward.RewardManager; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.generator.GeneratorManager; +import com.songoda.skyblock.island.reward.RewardManager; import com.songoda.skyblock.leaderboard.LeaderboardManager; import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.limit.LimitationInstanceHandler; @@ -22,6 +13,14 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.item.MenuClickRegistry; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; +import java.util.Map; public class ReloadCommand extends SubCommand { @@ -36,17 +35,17 @@ public class ReloadCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - LimitationInstanceHandler limitHandler = skyblock.getLimitationHandler(); - FileManager fileManager = skyblock.getFileManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + LimitationInstanceHandler limitHandler = plugin.getLimitationHandler(); + FileManager fileManager = plugin.getFileManager(); messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " + "cause issues that could put the plugin in an unstable state. " + "If you encounter any issues please stop your server, edit the configuration files, " + "and then start your server again. This command does NOT reload all the plugin files, only " + "the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml."); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Map configs = fileManager.getConfigs(); @@ -56,48 +55,48 @@ public class ReloadCommand extends SubCommand { Config configFileConfig = configs.get(configFileName); String configFilePath = configFileName.replace(configFileConfig.getFile().getName(), ""); - if (configFilePath.equals(skyblock.getDataFolder().toString() + "\\") || configFilePath.equals(skyblock.getDataFolder().toString() + "/")) { + if (configFilePath.equals(plugin.getDataFolder().toString() + "\\") || configFilePath.equals(plugin.getDataFolder().toString() + "/")) { configFileConfig.loadFile(); } } - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration(); - if (skyblock.getScoreboardManager() == null) { + if (plugin.getScoreboardManager() == null) { if (mainConfigLoad.getBoolean("Island.Scoreboard.Enable")) { - skyblock.setScoreboardManager(new ScoreboardManager(skyblock)); + plugin.setScoreboardManager(new ScoreboardManager(plugin)); } } else { - skyblock.getScoreboardManager().updateScoreboards(false); + plugin.getScoreboardManager().updateScoreboards(false); } - if (skyblock.getGeneratorManager() == null) { + if (plugin.getGeneratorManager() == null) { if (mainConfigLoad.getBoolean("Island.Generator.Enable")) { - skyblock.setGeneratorManager(new GeneratorManager(skyblock)); + plugin.setGeneratorManager(new GeneratorManager(plugin)); } } else { - GeneratorManager generatorManager = skyblock.getGeneratorManager(); + GeneratorManager generatorManager = plugin.getGeneratorManager(); generatorManager.unregisterGenerators(); generatorManager.registerGenerators(); } - IslandLevelManager levellingManager = skyblock.getLevellingManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); levellingManager.reloadWorth(); - RewardManager rewardManager = skyblock.getRewardManager(); + RewardManager rewardManager = plugin.getRewardManager(); rewardManager.loadRewards(); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { leaderboardManager.clearLeaderboard(); leaderboardManager.resetLeaderboard(); leaderboardManager.setupLeaderHeads(); - Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramTask().updateHologram()); + Bukkit.getScheduler().runTask(plugin, () -> plugin.getHologramTask().updateHologram()); }); limitHandler.reloadAll(); - skyblock.getLocalizationManager().reloadAll(); + plugin.getLocalizationManager().reloadAll(); MenuClickRegistry.getInstance().reloadAll(); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java index d72ef499..56d5c706 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java @@ -5,11 +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.hologram.Hologram; -import com.songoda.skyblock.tasks.HologramTask; import com.songoda.skyblock.hologram.HologramType; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; - +import com.songoda.skyblock.tasks.HologramTask; import org.apache.commons.lang.WordUtils; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -33,12 +32,12 @@ public class RemoveHologramCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - HologramTask hologramManager = skyblock.getHologramTask(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + HologramTask hologramManager = plugin.getHologramTask(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { @@ -57,7 +56,7 @@ public class RemoveHologramCommand extends SubCommand { } if (hologramType != null) { - Config locationsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")); + Config locationsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")); FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration(); if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + hologramType.name()) == null) { @@ -72,7 +71,7 @@ public class RemoveHologramCommand extends SubCommand { e.printStackTrace(); } - Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + Bukkit.getServer().getScheduler().runTask(plugin, () -> { HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase())); Hologram hologram = hologramManager.getHologram(hologramType1); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java index c297788c..6753cf99 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveUpgradeCommand.java @@ -35,13 +35,13 @@ public class RemoveUpgradeCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 2) { @@ -88,7 +88,7 @@ public class RemoveUpgradeCommand extends SubCommand { island.removeUpgrade(upgrade); } else { - File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data", + File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml"); if (!fileManager.isFileExist(islandDataFile)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetAlwaysLoadedCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetAlwaysLoadedCommand.java index c388a822..996a19ef 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetAlwaysLoadedCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetAlwaysLoadedCommand.java @@ -1,15 +1,6 @@ package com.songoda.skyblock.command.commands.admin; -import java.io.File; -import java.util.UUID; - import com.songoda.core.compatibility.CompatibleSound; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -19,6 +10,14 @@ 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 org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +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 SetAlwaysLoadedCommand extends SubCommand { @@ -34,10 +33,10 @@ public class SetAlwaysLoadedCommand extends SubCommand { public void onCommand(CommandSender sender, String[] args) { - FileManager fileManager = skyblock.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager fileManager = plugin.getFileManager(); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - MessageManager messageManager = skyblock.getMessageManager(); + MessageManager messageManager = plugin.getMessageManager(); if (args.length == 0) { messageManager.sendMessage(sender, @@ -45,9 +44,9 @@ public class SetAlwaysLoadedCommand extends SubCommand { return; } - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); if (args.length == 1) { Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java index fc59b64d..e5a6f2af 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java @@ -2,7 +2,6 @@ package com.songoda.skyblock.command.commands.admin; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.biome.BiomeManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; @@ -14,7 +13,6 @@ import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.StringUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; -import com.songoda.skyblock.utils.version.SBiome; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; @@ -37,14 +35,14 @@ public class SetBiomeCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - BiomeManager biomeManager = skyblock.getBiomeManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + BiomeManager biomeManager = plugin.getBiomeManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 2) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java index 1f3c947f..26a9e08b 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java @@ -21,12 +21,12 @@ public class SetHologramCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - HologramTask hologramManager = skyblock.getHologramTask(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + HologramTask hologramManager = plugin.getHologramTask(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { @@ -46,11 +46,11 @@ public class SetHologramCommand extends SubCommand { if (hologramType != null) { fileManager.setLocation( - fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")), + fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")), "Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + Bukkit.getServer().getScheduler().runTask(plugin, () -> { HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase())); Hologram hologram = hologramManager.getHologram(hologramType1); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java index 238e7ed5..cab10967 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java @@ -35,13 +35,13 @@ public class SetMaxMembers extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 2) { @@ -79,13 +79,13 @@ public class SetMaxMembers extends SubCommand { .getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); island.setMaxMembers(maxMembers); - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.WorldBorder.Enable") && island.isBorder()) { islandManager.updateBorder(island); } } else { - File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data", + File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml"); if (!fileManager.isFileExist(islandDataFile)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java index ebc492c9..06f43459 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java @@ -35,13 +35,13 @@ public class SetSizeCommand extends SubCommand { } public void onCommand(CommandSender sender, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 2) { @@ -79,13 +79,13 @@ public class SetSizeCommand extends SubCommand { .getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); island.setSize(size); - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.WorldBorder.Enable") && island.isBorder()) { islandManager.updateBorder(island); } } else { - File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data", + File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml"); if (!fileManager.isFileExist(islandDataFile)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSpawnCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSpawnCommand.java index 5308cc12..b9ebb071 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSpawnCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSpawnCommand.java @@ -16,14 +16,14 @@ public class SetSpawnCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - fileManager.setLocation(fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")), + fileManager.setLocation(fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")), "Location.Spawn", player.getLocation(), true); messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSpawn.Set.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java index 7db1efa6..daa7c249 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java @@ -11,9 +11,9 @@ public class SettingsCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - SoundManager soundManager = skyblock.getSoundManager(); + SoundManager soundManager = plugin.getSoundManager(); - skyblock.getGuiManager().showGUI(player, new GuiPermissionsSelector(skyblock, null, null)); + plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, null, null)); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java index 2802b358..0de934fa 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java @@ -1,20 +1,18 @@ package com.songoda.skyblock.command.commands.admin; -import java.io.File; -import java.util.Set; - import com.songoda.core.compatibility.CompatibleMaterial; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.utils.StringUtil; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; public class StackableCommand extends SubCommand { @@ -22,14 +20,14 @@ public class StackableCommand extends SubCommand { @SuppressWarnings("deprecation") @Override public void onCommandByPlayer(Player player, String[] args) { - final MessageManager messageManager = skyblock.getMessageManager(); + final MessageManager messageManager = plugin.getMessageManager(); if (args.length == 0) { player.sendMessage(StringUtil.color("&e/island admin stackable setsize &7- &f&osets the target block's stack size if applicable")); return; } - final FileConfiguration messageConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); + final FileConfiguration messageConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); if (args[0].equalsIgnoreCase("setsize")) { @@ -54,7 +52,7 @@ public class StackableCommand extends SubCommand { return; } - final StackableManager stackableManager = skyblock.getStackableManager(); + final StackableManager stackableManager = plugin.getStackableManager(); final CompatibleMaterial type = CompatibleMaterial.getMaterial(block.getType()); if (!stackableManager.isStackableMaterial(type)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java index 6fa575bd..9b7035e7 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java @@ -10,8 +10,6 @@ import com.songoda.skyblock.utils.ChatComponent; import com.songoda.skyblock.utils.Compression; import com.songoda.skyblock.utils.structure.StructureUtil; import com.songoda.skyblock.utils.world.LocationUtil; -import java.io.*; -import java.util.Base64; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; @@ -22,16 +20,21 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Base64; import java.util.logging.Level; public class StructureCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 0 || args[0].equalsIgnoreCase("help")) { @@ -140,7 +143,7 @@ public class StructureCommand extends SubCommand { return; } else if (args[0].equalsIgnoreCase("save")) { if (args.length == 2) { - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); Location position1Location = playerData.getArea().getPosition(1); Location position2Location = playerData.getArea().getPosition(2); @@ -171,7 +174,7 @@ public class StructureCommand extends SubCommand { } else { try { File configFile = new File( - skyblock.getDataFolder().toString() + "/structures/" + args[1] + ".structure"); + plugin.getDataFolder().toString() + "/structures/" + args[1] + ".structure"); StructureUtil.saveStructure(configFile, player.getLocation(), StructureUtil.getFixedLocations(position1Location, position2Location)); @@ -198,7 +201,7 @@ public class StructureCommand extends SubCommand { } else if (args[0].equalsIgnoreCase("convert")) { if (args.length == 2) { - File structureFile = new File(new File(skyblock.getDataFolder().toString() + "/structures"), args[1]); + File structureFile = new File(new File(plugin.getDataFolder().toString() + "/structures"), args[1]); if (!structureFile.exists()) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Convert.Invalid.Message") diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/UpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/UpgradeCommand.java index 3834739d..a9144145 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/UpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/UpgradeCommand.java @@ -18,15 +18,15 @@ public class UpgradeCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (skyblock.getUpgradeManager() == null) { + if (plugin.getUpgradeManager() == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Upgrade.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java index 8cf32a29..a5e688fc 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java @@ -32,20 +32,20 @@ public class AcceptCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); PlayerData playerData = playerDataManager.getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { - InviteManager inviteManager = skyblock.getInviteManager(); + InviteManager inviteManager = plugin.getInviteManager(); if (inviteManager.hasInvite(player.getUniqueId())) { Invite invite = inviteManager.getInvite(player.getUniqueId()); @@ -99,7 +99,7 @@ public class AcceptCommand extends SubCommand { island.save(); if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() - + 1) >= fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + + 1) >= fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Member.Capacity")) { Map invites = inviteManager.getInvites(); @@ -123,8 +123,8 @@ public class AcceptCommand extends SubCommand { } } } - - skyblock.getVisitManager().getIsland(invite.getOwnerUUID()) + + plugin.getVisitManager().getIsland(invite.getOwnerUUID()) .removeVoter(player.getUniqueId()); for (Player all : Bukkit.getOnlinePlayers()) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java index f7013442..68abb0b8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java @@ -1,15 +1,6 @@ package com.songoda.skyblock.command.commands.island; -import java.io.File; -import java.util.UUID; - import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.skyblock.permission.PermissionManager; -import org.bukkit.Bukkit; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - import com.songoda.skyblock.ban.Ban; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; @@ -18,22 +9,30 @@ 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.permission.PermissionManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.utils.world.LocationUtil; +import org.bukkit.Bukkit; +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 BanCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - MessageManager messageManager = skyblock.getMessageManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + MessageManager messageManager = plugin.getMessageManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { @@ -42,7 +41,7 @@ public class BanCommand extends SubCommand { if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) { + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) { if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Ban", IslandRole.Operator))) { Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java index aaa86a8a..d511d7b2 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java @@ -19,15 +19,15 @@ public class BankCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) { + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; @@ -37,12 +37,12 @@ public class BankCommand extends SubCommand { island = islandManager.getIsland(player); if (island == null) { - skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); - skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Bank.Unknown")); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Bank.Unknown")); return; } - - skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, false)); + + plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, false)); } @Override diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BansCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BansCommand.java index b76fb8e7..4087524e 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BansCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BansCommand.java @@ -18,19 +18,19 @@ public class BansCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - Island island = skyblock.getIslandManager().getIsland(player); + Island island = plugin.getIslandManager().getIsland(player); if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island, "Unban", IslandRole.Operator)) + && plugin.getPermissionManager().hasPermission(island, "Unban", IslandRole.Operator)) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { if (island.getBan().getBans().size() == 0) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Bans.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java index 4e569499..a726910d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BiomeCommand.java @@ -1,7 +1,6 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.biome.BiomeManager; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager.Config; @@ -22,12 +21,12 @@ public class BiomeCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - BiomeManager biomeManager = skyblock.getBiomeManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + BiomeManager biomeManager = plugin.getBiomeManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -36,13 +35,13 @@ public class BiomeCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island,"Biome", IslandRole.Operator)) + && plugin.getPermissionManager().hasPermission(island,"Biome", IslandRole.Operator)) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { if(biomeManager.isUpdating(island)){ messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.InProgress.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); } else { - skyblock.getGuiManager().showGUI(player, new GuiBiome(skyblock, player, island, IslandWorld.Normal, null, false)); // TODO Nether and End support + plugin.getGuiManager().showGUI(player, new GuiBiome(plugin, player, island, IslandWorld.Normal, null, false)); // TODO Nether and End support soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java index a1453cff..8c12e8c9 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java @@ -21,13 +21,13 @@ public class BorderCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -38,7 +38,7 @@ public class BorderCommand extends SubCommand { } else if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Border", IslandRole.Operator)) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.WorldBorder.Enable")) { Border.getInstance().open(player); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CancelCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CancelCommand.java index 8027e360..c736c6e2 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CancelCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CancelCommand.java @@ -21,12 +21,12 @@ public class CancelCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - InviteManager inviteManager = skyblock.getInviteManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + InviteManager inviteManager = plugin.getInviteManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { 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 87a2b4f4..aa1610ce 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 @@ -1,44 +1,43 @@ 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; - import com.songoda.skyblock.challenge.FabledChallenge; import com.songoda.skyblock.challenge.challenge.Challenge; import com.songoda.skyblock.challenge.challenge.ChallengeCategory; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; public class ChallengeCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); - FabledChallenge fabledChallenge = skyblock.getFabledChallenge(); - IslandManager islandManager = skyblock.getIslandManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); + FabledChallenge fabledChallenge = plugin.getFabledChallenge(); + IslandManager islandManager = plugin.getIslandManager(); - Config langConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config langConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration langConfigLoad = langConfig.getFileConfiguration(); // Not loaded - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.Enable")) { messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; } if (args.length == 0) { - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland")){ if(islandManager.getIsland(player) == null){ messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.NoIsland.Message")); 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 26fd9782..a1142150 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 @@ -23,12 +23,12 @@ public class ChatCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -65,11 +65,11 @@ public class ChatCommand extends SubCommand { } else { if (playerDataManager.hasPlayerData(player)) { if (playerData.getOwner() != null) { - island = skyblock.getIslandManager().getIsland(player); + island = plugin.getIslandManager().getIsland(player); } Island finalIsland = island; - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(), String.join(" ", args), configLoad.getString("Island.Chat.Format.Message")); Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java index cb4cfd28..90f3dfc7 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CloseCommand.java @@ -19,11 +19,11 @@ public class CloseCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -33,7 +33,7 @@ public class CloseCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island,"Visitor", IslandRole.Operator))) { + && plugin.getPermissionManager().hasPermission(island,"Visitor", IslandRole.Operator))) { if (island.getStatus().equals(IslandStatus.OPEN) || island.getStatus().equals(IslandStatus.WHITELISTED)) { islandManager.closeIsland(island); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java index c92b0c2a..9da979c0 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java @@ -33,17 +33,17 @@ public class ConfirmCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - StructureManager structureManager = skyblock.getStructureManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + StructureManager structureManager = plugin.getStructureManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (playerData.getConfirmationTime() > 0) { @@ -100,7 +100,7 @@ public class ConfirmCommand extends SubCommand { islandManager.giveOwnership(island, Bukkit.getServer().getOfflinePlayer(targetPlayerUUID)); - skyblock.getCooldownManager().createPlayer(CooldownType.Ownership, + plugin.getCooldownManager().createPlayer(CooldownType.Ownership, Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID())); } else { messageManager.sendMessage(player, configLoad diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ControlPanelCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ControlPanelCommand.java index d0d074b0..400ccb47 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ControlPanelCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ControlPanelCommand.java @@ -15,13 +15,13 @@ public class ControlPanelCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - SoundManager soundManager = skyblock.getSoundManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (skyblock.getIslandManager().getIsland(player) == null) { - skyblock.getMessageManager().sendMessage(player, + if (plugin.getIslandManager().getIsland(player) == null) { + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.ControlPanel.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java index 5ae35b0a..400cfc37 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java @@ -23,13 +23,13 @@ public class CoopCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -39,7 +39,7 @@ public class CoopCommand extends SubCommand { if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Coop.Enable")) { if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java index 0983a130..ad67a9c5 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CreateCommand.java @@ -25,19 +25,19 @@ public class CreateCommand 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(); - FileManager fileManager = skyblock.getFileManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (islandManager.getIsland(player) == null) { - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); if (args.length == 1) { - Structure structure = skyblock.getStructureManager().getStructure(args[0]); + Structure structure = plugin.getStructureManager().getStructure(args[0]); if (structure != null && islandManager.createIsland(player, structure)) { messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Created.Message")); @@ -50,7 +50,7 @@ public class CreateCommand extends SubCommand { Creator.getInstance().open(player); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } else { - List structures = skyblock.getStructureManager().getStructures(); + List structures = plugin.getStructureManager().getStructures(); if (structures.size() == 0) { messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.None.Message")); @@ -58,7 +58,7 @@ public class CreateCommand extends SubCommand { return; } else if (!fileManager - .isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"), + .isFileExist(new File(new File(plugin.getDataFolder().toString() + "/structures"), structures.get(0).getOverworldFile()))) { messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.File.Overworld.Message")); @@ -66,14 +66,14 @@ public class CreateCommand extends SubCommand { return; } else if (!fileManager - .isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"), + .isFileExist(new File(new File(plugin.getDataFolder().toString() + "/structures"), structures.get(0).getNetherFile()))) { messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.File.Nether.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; - } else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable") && cooldownManager.hasPlayer(CooldownType.Creation, player)) { CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Creation, player); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CurrentCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CurrentCommand.java index 5f4c0be3..80bb8128 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CurrentCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CurrentCommand.java @@ -19,11 +19,11 @@ public class CurrentCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length > 0) { 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 47e8146d..25317d3b 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 @@ -33,15 +33,15 @@ 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(); - FileManager fileManager = skyblock.getFileManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -50,7 +50,7 @@ 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")) + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable") && cooldownManager.hasPlayer(CooldownType.Deletion, player)) { CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Deletion, player); @@ -81,7 +81,7 @@ public class DeleteCommand extends SubCommand { configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); } else { - int confirmationTime = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Confirmation.Timeout"); playerData.setConfirmation(Confirmation.Deletion); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/DemoteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/DemoteCommand.java index 235f0fef..8f6668d2 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/DemoteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/DemoteCommand.java @@ -22,11 +22,11 @@ public class DemoteCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/DenyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/DenyCommand.java index 2bfce9be..4663dac8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/DenyCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/DenyCommand.java @@ -18,11 +18,11 @@ public class DenyCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - InviteManager inviteManager = skyblock.getInviteManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + InviteManager inviteManager = plugin.getInviteManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/InformationCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/InformationCommand.java index 98b9ce18..a4605df4 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/InformationCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/InformationCommand.java @@ -22,13 +22,13 @@ public class InformationCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); if (playerDataManager.hasPlayerData(player)) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); UUID islandOwnerUUID = null; @@ -57,7 +57,7 @@ public class InformationCommand extends SubCommand { return; } - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); if (islandOwnerUUID == null) { if (islandManager.getIsland(player) == null) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java index d175c111..0ce58614 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java @@ -30,12 +30,12 @@ public class InviteCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { @@ -46,8 +46,8 @@ public class InviteCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island, "Invite", IslandRole.Operator))) { - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + && plugin.getPermissionManager().hasPermission(island, "Invite", IslandRole.Operator))) { + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1) >= mainConfig.getFileConfiguration().getInt("Island.Member.Capacity")) { @@ -77,8 +77,8 @@ public class InviteCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Member.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (skyblock.getInviteManager().hasInvite(targetPlayer.getUniqueId())) { - Invite invite = skyblock.getInviteManager().getInvite(targetPlayer.getUniqueId()); + } else if (plugin.getInviteManager().hasInvite(targetPlayer.getUniqueId())) { + Invite invite = plugin.getInviteManager().getInvite(targetPlayer.getUniqueId()); if (invite.getOwnerUUID().equals(island.getOwnerUUID())) { messageManager.sendMessage(player, @@ -213,7 +213,7 @@ public class InviteCommand extends SubCommand { targetPlayer.spigot().sendMessage(chatComponent.getTextComponent()); - Invite invite = skyblock.getInviteManager().createInvite(targetPlayer, player, + Invite invite = plugin.getInviteManager().createInvite(targetPlayer, player, island.getOwnerUUID(), respondTime); Bukkit.getServer().getPluginManager() 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 804dc59e..a0d6a68d 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 @@ -25,11 +25,11 @@ public class KickAllCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -39,7 +39,7 @@ public class KickAllCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator))) { + && plugin.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator))) { if (!island.getStatus().equals(IslandStatus.CLOSED)) { Set islandVisitors = islandManager.getVisitorsAtIsland(island); 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 924810a1..97feb6af 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 @@ -1,19 +1,6 @@ package com.songoda.skyblock.command.commands.island; -import java.io.File; -import java.io.IOException; -import java.util.Set; -import java.util.UUID; - import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.skyblock.island.IslandStatus; -import com.songoda.skyblock.permission.PermissionManager; -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 com.songoda.skyblock.api.event.island.IslandKickEvent; import com.songoda.skyblock.api.utils.APIUtil; import com.songoda.skyblock.command.SubCommand; @@ -22,7 +9,9 @@ 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.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.scoreboard.Scoreboard; @@ -30,23 +19,33 @@ import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.utils.world.LocationUtil; +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.io.IOException; +import java.util.Set; +import java.util.UUID; public class KickCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); PlayerData playerData = playerDataManager.getPlayerData(player); - Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); if (args.length == 1) { Island island = islandManager.getIsland(player); @@ -93,7 +92,7 @@ public class KickCommand extends SubCommand { IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), APIUtil.fromImplementation(IslandRole.Visitor), Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player); - Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent)); + Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent)); if (!islandKickEvent.isCancelled()) { LocationUtil.teleportPlayerToSpawn(targetPlayer); @@ -117,7 +116,7 @@ public class KickCommand extends SubCommand { IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), APIUtil.fromImplementation(islandRole), Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player); - Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent)); + Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent)); if (!islandKickEvent.isCancelled()) { messageManager.sendMessage(player, @@ -125,7 +124,7 @@ public class KickCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); if (targetPlayer == null) { - Config config = fileManager.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), targetPlayerUUID.toString() + ".yml")); + Config config = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), targetPlayerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Statistics.Island.Playtime", null); @@ -182,7 +181,7 @@ public class KickCommand extends SubCommand { if (targetPlayerData.isChat()) { targetPlayerData.setChat(false); - messageManager.sendMessage(targetPlayer, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration() + messageManager.sendMessage(targetPlayer, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration() .getString("Island.Chat.Untoggled.Message")); } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java index 4d202861..85f64c1c 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java @@ -18,17 +18,17 @@ public class LeaderboardCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (playerDataManager.hasPlayerData(player)) { if (args.length == 0) { - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Visitor.Vote")) { playerDataManager.getPlayerData(player) .setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Browse)); @@ -46,7 +46,7 @@ public class LeaderboardCommand extends SubCommand { playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Bank)); break; case "votes": - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) { + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) { playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Votes)); } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Leaderboard.Disabled.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java index 372dcb44..e1d5453b 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java @@ -28,16 +28,16 @@ public class LeaveCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); PlayerData playerData = playerDataManager.getPlayerData(player); - Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); Island island = islandManager.getIsland(player); @@ -83,7 +83,7 @@ public class LeaveCommand extends SubCommand { if (targetPlayerData.isChat()) { targetPlayerData.setChat(false); messageManager.sendMessage(targetPlayer, - fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.Chat.Untoggled.Message")); } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java index ab70ca02..f4641db3 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/LevelCommand.java @@ -30,15 +30,15 @@ public class LevelCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - IslandLevelManager levellingManager = skyblock.getLevellingManager(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - VisitManager visitManager = skyblock.getVisitManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + VisitManager visitManager = plugin.getVisitManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/MembersCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/MembersCommand.java index 80b7d93a..6d26351b 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/MembersCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/MembersCommand.java @@ -14,15 +14,15 @@ public class MembersCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - SoundManager soundManager = skyblock.getSoundManager(); + SoundManager soundManager = plugin.getSoundManager(); - if (skyblock.getIslandManager().getIsland(player) == null) { - skyblock.getMessageManager().sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + if (plugin.getIslandManager().getIsland(player) == null) { + plugin.getMessageManager().sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Command.Island.Settings.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); playerData.setType(Members.Type.Default); playerData.setSort(Members.Sort.Default); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java index ea7ae61d..3d055dec 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/OpenCommand.java @@ -20,12 +20,12 @@ public class OpenCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java index ecd40eb7..aaef16e0 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java @@ -37,15 +37,15 @@ public class OwnerCommand 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(); - FileManager fileManager = skyblock.getFileManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -126,7 +126,7 @@ public class OwnerCommand extends SubCommand { return; } else { - int confirmationTime = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Confirmation.Timeout"); playerData.setOwnership(targetPlayerUUID); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/PreviewCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/PreviewCommand.java index 002a0bdb..7bc4a9cd 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/PreviewCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/PreviewCommand.java @@ -19,40 +19,40 @@ public class PreviewCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - FileManager fileManager = skyblock.getFileManager(); - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager fileManager = plugin.getFileManager(); + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLang = config.getFileConfiguration(); if(args.length != 1) { - skyblock.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Argument.Count.Message")); + plugin.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Argument.Count.Message")); return; } - PlayerData data = skyblock.getPlayerDataManager().getPlayerData(player); - Island island = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(player.getUniqueId())); + PlayerData data = plugin.getPlayerDataManager().getPlayerData(player); + Island island = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(player.getUniqueId())); if (args[0].equals("confirm")) { if(data.getConfirmation() == Confirmation.Preview && data.getConfirmationTime() > 0) { - Structure islandStructure = skyblock.getStructureManager().getStructure(island.getStructure()); + Structure islandStructure = plugin.getStructureManager().getStructure(island.getStructure()); - if(skyblock.getIslandManager().deleteIsland(island, true)) { + if(plugin.getIslandManager().deleteIsland(island, true)) { island.setDeleted(true); data.setPreview(false); if(player.getGameMode() == GameMode.SPECTATOR) { player.setGameMode(GameMode.SURVIVAL); } - Bukkit.getScheduler().runTaskLater(skyblock, () -> { - if(skyblock.getIslandManager().createIsland(player, islandStructure)) { - skyblock.getMessageManager().sendMessage(player, configLang.getString("Island.Creator.Selector.Created.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); + Bukkit.getScheduler().runTaskLater(plugin, () -> { + if(plugin.getIslandManager().createIsland(player, islandStructure)) { + plugin.getMessageManager().sendMessage(player, configLang.getString("Island.Creator.Selector.Created.Message")); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); } }, 30L); } } } else if (args[0].equals("cancel")) { if(data.getConfirmation() == Confirmation.Preview && data.getConfirmationTime() > 0) { - if(skyblock.getIslandManager().deleteIsland(island, true)) { + if(plugin.getIslandManager().deleteIsland(island, true)) { island.setDeleted(true); data.setPreview(false); if (player.getGameMode() == GameMode.SPECTATOR) { @@ -63,15 +63,15 @@ public class PreviewCommand extends SubCommand { } else { // Do not preview if user has an island if (island != null) { - skyblock.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Island.Message")); + plugin.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Island.Message")); return; } - Structure structure = skyblock.getStructureManager().getStructure(args[0]); + Structure structure = plugin.getStructureManager().getStructure(args[0]); if(structure == null) { - skyblock.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.File.Message")); + plugin.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.File.Message")); return; } - skyblock.getIslandManager().previewIsland(player, structure); + plugin.getIslandManager().previewIsland(player, structure); } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/PromoteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/PromoteCommand.java index 579d6e39..ce7105ec 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/PromoteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/PromoteCommand.java @@ -23,11 +23,11 @@ public class PromoteCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length != 1) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java index 60c4145a..f4eb6ab0 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/PublicCommand.java @@ -19,11 +19,11 @@ public class PublicCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -33,7 +33,7 @@ public class PublicCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) { + && plugin.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) { switch (island.getStatus()) { case OPEN: islandManager.whitelistIsland(island); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java index cfe4ee8a..5cceb97b 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java @@ -3,16 +3,11 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; 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.permission.PermissionManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; -import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -23,12 +18,12 @@ public class ScoreboardCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - SoundManager soundManager = skyblock.getSoundManager(); - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + SoundManager soundManager = plugin.getSoundManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); PlayerData playerData = playerDataManager.getPlayerData(player); @@ -36,7 +31,7 @@ public class ScoreboardCommand extends SubCommand { if (playerData == null) { messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Error.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if(!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")) + } else if(!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Scoreboard.Enable", false)) { messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.GlobalDisable.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java index e4a55b9e..92678833 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java @@ -8,7 +8,6 @@ import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.*; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; - import org.bukkit.Location; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -20,12 +19,12 @@ public class SetSpawnCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { @@ -51,14 +50,14 @@ public class SetSpawnCommand extends SubCommand { if (island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) - && (skyblock.getPermissionManager().hasPermission(island, + && (plugin.getPermissionManager().hasPermission(island, environment.name() + "Spawn", IslandRole.Operator))) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { if (islandManager.isPlayerAtIsland(island, player)) { - IslandWorld world = skyblock.getWorldManager().getIslandWorld(player.getWorld()); + IslandWorld world = plugin.getWorldManager().getIslandWorld(player.getWorld()); Location location = player.getLocation(); - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Spawn.Protection")) { CompatibleMaterial toCompare = CompatibleMaterial.getMaterial(location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType()); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java index 52ddba14..c8bb0393 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java @@ -20,12 +20,12 @@ public class SettingsCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -39,7 +39,7 @@ public class SettingsCommand extends SubCommand { && (permissionManager.hasPermission(island, "Visitor", IslandRole.Operator) || permissionManager.hasPermission(island, "Member", IslandRole.Operator))) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - skyblock.getGuiManager().showGUI(player, new GuiPermissionsSelector(skyblock, island, null)); + plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, island, null)); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } else{ messageManager.sendMessage(player, 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 88ccc533..d7729be9 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 @@ -14,8 +14,6 @@ import com.songoda.skyblock.visit.VisitManager; import io.papermc.lib.PaperLib; 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; @@ -27,13 +25,13 @@ public class TeleportCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - VisitManager visitManager = skyblock.getVisitManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + VisitManager visitManager = plugin.getVisitManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { @@ -115,10 +113,10 @@ public class TeleportCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + Bukkit.getServer().getScheduler().runTask(plugin, () -> { Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); PaperLib.getChunkAtAsync(loc).thenRun((() -> { - LocationUtil.removeWaterFromLoc(skyblock, loc); + LocationUtil.removeWaterFromLoc(plugin, loc); PaperLib.teleportAsync(player, loc); })); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java index bbbc76f1..7da0f85f 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java @@ -23,12 +23,12 @@ public class UnbanCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { @@ -37,11 +37,11 @@ public class UnbanCommand extends SubCommand { if (island == null) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Visitor.Banning")) { if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island,"Unban", IslandRole.Operator))) { + && plugin.getPermissionManager().hasPermission(island,"Unban", IslandRole.Operator))) { Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); UUID targetPlayerUUID = null; diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java index 93083714..2a75da26 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java @@ -22,12 +22,12 @@ public class UnlockCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length != 1) { @@ -44,7 +44,7 @@ public class UnlockCommand extends SubCommand { return; } - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + type + ".Enable")) { + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + type + ".Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Disabled.Message").replace("%type%", type)); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; @@ -65,7 +65,7 @@ public class UnlockCommand extends SubCommand { return; } - double price = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + double price = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getDouble("Island.World." + islandWorld.name() + ".UnlockPrice"); if (!EconomyManager.hasBalance(player, price)) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java index 7886c5c1..755f583c 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java @@ -17,14 +17,14 @@ public class UpgradeCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (skyblock.getIslandManager().getIsland(player) == null) { - skyblock.getMessageManager().sendMessage(player, + if (plugin.getIslandManager().getIsland(player) == null) { + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Upgrade.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java index 751bf0b3..d4d026c0 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java @@ -9,7 +9,6 @@ import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; - import org.apache.commons.lang.WordUtils; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -22,12 +21,12 @@ public class ValueCommand extends SubCommand { @SuppressWarnings("deprecation") @Override public void onCommandByPlayer(Player player, String[] args) { - IslandLevelManager levellingManager = skyblock.getLevellingManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (player.getItemInHand() == null) { @@ -38,7 +37,7 @@ public class ValueCommand extends SubCommand { if (materials != null && levellingManager.hasWorth(materials)) { long worth = levellingManager.getWorth(materials); - double level = (double) worth / (double) fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Levelling.Division"); + double level = (double) worth / (double) fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Levelling.Division"); messageManager.sendMessage(player, configLoad.getString("Command.Island.Value.Value.Message").replace("%material", WordUtils.capitalizeFully(materials.name().toLowerCase().replace("_", " "))) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/VisitCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/VisitCommand.java index 86e6d22d..8c857a12 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/VisitCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/VisitCommand.java @@ -16,24 +16,24 @@ public class VisitCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); if (args.length == 0) { - if (!skyblock.getPlayerDataManager().hasPlayerData(player)) - skyblock.getPlayerDataManager().createPlayerData(player); + if (!plugin.getPlayerDataManager().hasPlayerData(player)) + plugin.getPlayerDataManager().createPlayerData(player); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); playerData.setType(Visit.Type.Default); playerData.setSort(Visit.Sort.Default); Visit.getInstance().open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort()); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } else if (args.length == 1) { - Bukkit.getServer().getScheduler().runTask(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island teleport " + args[0])); + Bukkit.getServer().getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(player, "island teleport " + args[0])); } else { messageManager.sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Command.Island.Visit.Invalid.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java index ffe3b492..05da3ef2 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/VisitorsCommand.java @@ -18,11 +18,11 @@ public class VisitorsCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java index 19fea256..d25c3781 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java @@ -29,18 +29,18 @@ public class VoteCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - VisitManager visitManager = skyblock.getVisitManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + VisitManager visitManager = plugin.getVisitManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Visitor.Vote")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/WeatherCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/WeatherCommand.java index 0b5bd056..831a8c25 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/WeatherCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/WeatherCommand.java @@ -18,12 +18,12 @@ public class WeatherCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -31,7 +31,7 @@ public class WeatherCommand extends SubCommand { messageManager.sendMessage(player, configLoad.getString("Command.Island.Weather.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island, "Weather", IslandRole.Operator)) + && plugin.getPermissionManager().hasPermission(island, "Weather", IslandRole.Operator)) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { Weather.getInstance().open(player); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java index 24478392..406cf1f1 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/WhitelistCommand.java @@ -6,11 +6,9 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; -import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -23,15 +21,15 @@ public class WhitelistCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); + SoundManager soundManager = plugin.getSoundManager(); - FileManager.Config language = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config language = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration languageLoad = language.getFileConfiguration(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -41,7 +39,7 @@ public class WhitelistCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (island.hasRole(IslandRole.Owner, player.getUniqueId()) || (island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) { + && plugin.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) { if(args.length == 1) { if(args[0].equalsIgnoreCase("on")){ messageManager.sendMessage(player, languageLoad.getString("Command.Island.Whitelist.Enabled.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/disabled/ResetCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/disabled/ResetCommand.java index 96fe971d..848839b6 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/disabled/ResetCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/disabled/ResetCommand.java @@ -26,14 +26,14 @@ public class ResetCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Island island = islandManager.getIsland(player); @@ -47,7 +47,7 @@ public class ResetCommand extends SubCommand { configLoad.getString("Command.Island.Reset.Confirmation.Pending.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); } else { - int confirmationTime = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Confirmation.Timeout"); playerData.setConfirmation(Confirmation.Reset); diff --git a/src/main/java/com/songoda/skyblock/config/FileChecker.java b/src/main/java/com/songoda/skyblock/config/FileChecker.java index 334de872..4aee9545 100644 --- a/src/main/java/com/songoda/skyblock/config/FileChecker.java +++ b/src/main/java/com/songoda/skyblock/config/FileChecker.java @@ -1,5 +1,9 @@ package com.songoda.skyblock.config; +import com.songoda.skyblock.SkyBlock; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + import java.io.IOException; import java.io.InputStreamReader; import java.util.EnumMap; @@ -7,29 +11,24 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import com.songoda.skyblock.SkyBlock; - public class FileChecker { private final FileManager fileManager; private Map loadedFiles; - public FileChecker(SkyBlock skyblock, FileManager fileManager, String configurationFileName, boolean applyComments) { + public FileChecker(SkyBlock plugin, FileManager fileManager, String configurationFileName, boolean applyComments) { this.fileManager = fileManager; loadedFiles = new EnumMap<>(File.Type.class); - java.io.File configFile = new java.io.File(skyblock.getDataFolder(), configurationFileName); + java.io.File configFile = new java.io.File(plugin.getDataFolder(), configurationFileName); loadedFiles.put(File.Type.CREATED, new File(fileManager, configFile, YamlConfiguration.loadConfiguration(configFile))); if (applyComments) { - loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(new InputStreamReader(skyblock.getResource(configurationFileName))))))); + loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(new InputStreamReader(plugin.getResource(configurationFileName))))))); } else { - loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(skyblock.getResource(configurationFileName))))); + loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getResource(configurationFileName))))); } } diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java index 62248fe3..fe76ed74 100644 --- a/src/main/java/com/songoda/skyblock/config/FileManager.java +++ b/src/main/java/com/songoda/skyblock/config/FileManager.java @@ -1,18 +1,15 @@ package com.songoda.skyblock.config; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; +import com.google.common.io.ByteStreams; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.IslandWorld; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.*; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.LinkedHashMap; @@ -20,33 +17,23 @@ import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import com.google.common.io.ByteStreams; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.island.IslandWorld; - public class FileManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private Map loadedConfigs = new HashMap<>(); - public FileManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public FileManager(SkyBlock plugin) { + this.plugin = plugin; loadConfigs(); } public void loadConfigs() { - if (!skyblock.getDataFolder().exists()) { - skyblock.getDataFolder().mkdir(); + if (!plugin.getDataFolder().exists()) { + plugin.getDataFolder().mkdir(); } - File structureDirectory = new File(skyblock.getDataFolder().toString() + "/structures"); + File structureDirectory = new File(plugin.getDataFolder().toString() + "/structures"); if (!structureDirectory.exists()) { structureDirectory.mkdir(); @@ -55,28 +42,28 @@ public class FileManager { // Will remain null unless WorldEdit is present. File schematicsDirectory = null; - if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !(schematicsDirectory = new File(skyblock.getDataFolder().toString() + "/schematics")).exists()) { + if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !(schematicsDirectory = new File(plugin.getDataFolder().toString() + "/schematics")).exists()) { schematicsDirectory.mkdir(); } Map configFiles = new LinkedHashMap<>(); - configFiles.put("limits.yml", new File(skyblock.getDataFolder(), "limits.yml")); - configFiles.put("worlds.yml", new File(skyblock.getDataFolder(), "worlds.yml")); - configFiles.put("levelling.yml", new File(skyblock.getDataFolder(), "levelling.yml")); - configFiles.put("config.yml", new File(skyblock.getDataFolder(), "config.yml")); - configFiles.put("language.yml", new File(skyblock.getDataFolder(), "language.yml")); - configFiles.put("settings.yml", new File(skyblock.getDataFolder(), "settings.yml")); - configFiles.put("upgrades.yml", new File(skyblock.getDataFolder(), "upgrades.yml")); - configFiles.put("biomes.yml", new File(skyblock.getDataFolder(), "biomes.yml")); + configFiles.put("limits.yml", new File(plugin.getDataFolder(), "limits.yml")); + configFiles.put("worlds.yml", new File(plugin.getDataFolder(), "worlds.yml")); + configFiles.put("levelling.yml", new File(plugin.getDataFolder(), "levelling.yml")); + configFiles.put("config.yml", new File(plugin.getDataFolder(), "config.yml")); + configFiles.put("language.yml", new File(plugin.getDataFolder(), "language.yml")); + configFiles.put("settings.yml", new File(plugin.getDataFolder(), "settings.yml")); + configFiles.put("upgrades.yml", new File(plugin.getDataFolder(), "upgrades.yml")); + configFiles.put("biomes.yml", new File(plugin.getDataFolder(), "biomes.yml")); // configFiles.put("menus.yml", new File(skyblock.getDataFolder(), "menus.yml")); - configFiles.put("generators.yml", new File(skyblock.getDataFolder(), "generators.yml")); - configFiles.put("stackables.yml", new File(skyblock.getDataFolder(), "stackables.yml")); - configFiles.put("structures.yml", new File(skyblock.getDataFolder(), "structures.yml")); - configFiles.put("rewards.yml", new File(skyblock.getDataFolder(), "rewards.yml")); - configFiles.put("structures/default.structure", new File(skyblock.getDataFolder().toString() + "/structures", "default.structure")); - configFiles.put("challenges.yml", new File(skyblock.getDataFolder(), "challenges.yml")); + configFiles.put("generators.yml", new File(plugin.getDataFolder(), "generators.yml")); + configFiles.put("stackables.yml", new File(plugin.getDataFolder(), "stackables.yml")); + configFiles.put("structures.yml", new File(plugin.getDataFolder(), "structures.yml")); + configFiles.put("rewards.yml", new File(plugin.getDataFolder(), "rewards.yml")); + configFiles.put("structures/default.structure", new File(plugin.getDataFolder().toString() + "/structures", "default.structure")); + configFiles.put("challenges.yml", new File(plugin.getDataFolder(), "challenges.yml")); - File oldStructureFile = new File(skyblock.getDataFolder().toString() + "/structures", "default.structure"); + File oldStructureFile = new File(plugin.getDataFolder().toString() + "/structures", "default.structure"); oldStructureFile.delete(); for (Entry configEntry : configFiles.entrySet()) { @@ -91,7 +78,7 @@ public class FileManager { } catch (IOException e) { e.printStackTrace(); } - try (InputStream is = skyblock.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) { + try (InputStream is = plugin.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) { if(is != null){ ByteStreams.copy(is, os); } @@ -106,9 +93,9 @@ public class FileManager { FileChecker fileChecker; if (fileName.equals("config.yml") || fileName.equals("biomes.yml")) { - fileChecker = new FileChecker(skyblock, this, fileName, true); + fileChecker = new FileChecker(plugin, this, fileName, true); } else { - fileChecker = new FileChecker(skyblock, this, fileName, false); + fileChecker = new FileChecker(plugin, this, fileName, false); } fileChecker.loadSections(); @@ -118,7 +105,7 @@ public class FileManager { } else { try { configFile.createNewFile(); - try (InputStream is = skyblock.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) { + try (InputStream is = plugin.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) { if(is != null){ ByteStreams.copy(is, os); } @@ -233,7 +220,7 @@ public class FileManager { public InputStream getConfigContent(Reader reader) { try { - String addLine, currentLine, pluginName = skyblock.getDescription().getName(); + String addLine, currentLine, pluginName = plugin.getDescription().getName(); int commentNum = 0; StringBuilder whole = new StringBuilder(); @@ -280,8 +267,8 @@ public class FileManager { StringBuilder config = new StringBuilder(); for (String line : lines) { - if (line.contains(skyblock.getDescription().getName() + "_COMMENT")) { - config.append(line.replace("IMPORTANT", "[!]").replace("\n", "").replace(skyblock.getDescription().getName() + "_COMMENT_", "#").replaceAll("[0-9]+:", "") + "\n"); + if (line.contains(plugin.getDescription().getName() + "_COMMENT")) { + config.append(line.replace("IMPORTANT", "[!]").replace("\n", "").replace(plugin.getDescription().getName() + "_COMMENT_", "#").replaceAll("[0-9]+:", "") + "\n"); } else if (line.contains(":")) { config.append(line + "\n"); } diff --git a/src/main/java/com/songoda/skyblock/confirmation/ConfirmationTask.java b/src/main/java/com/songoda/skyblock/confirmation/ConfirmationTask.java index 2d6994fa..fc5f344e 100644 --- a/src/main/java/com/songoda/skyblock/confirmation/ConfirmationTask.java +++ b/src/main/java/com/songoda/skyblock/confirmation/ConfirmationTask.java @@ -1,9 +1,8 @@ package com.songoda.skyblock.confirmation; -import org.bukkit.scheduler.BukkitRunnable; - import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; +import org.bukkit.scheduler.BukkitRunnable; public class ConfirmationTask extends BukkitRunnable { diff --git a/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java b/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java index 37f9b99b..87a045ea 100644 --- a/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java +++ b/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java @@ -12,23 +12,18 @@ import org.bukkit.entity.Player; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; public class CooldownManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private Map> cooldownStorage = new EnumMap<>(CooldownType.class); - public CooldownManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public CooldownManager(SkyBlock plugin) { + this.plugin = plugin; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); for (CooldownType cooldownTypeList : CooldownType.getTypes()) { List cooldownPlayers = new ArrayList<>(); @@ -58,7 +53,7 @@ public class CooldownManager { cooldownStorage.put(cooldownTypeList, cooldownPlayers); } - new CooldownTask(this).runTaskTimerAsynchronously(skyblock, 0L, 20L); + new CooldownTask(this).runTaskTimerAsynchronously(plugin, 0L, 20L); } public void onDisable() { @@ -70,16 +65,16 @@ public class CooldownManager { public CooldownPlayer loadCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) { 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")); + Config config = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString("Island." + cooldownType.name() + ".Cooldown") != null) { return new CooldownPlayer(player.getUniqueId(), new Cooldown(configLoad.getInt("Island." + cooldownType.name() + ".Cooldown"))); } } else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) { - Config config = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")); + Config config = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString(cooldownType.name() + ".Cooldown") != null) { @@ -91,7 +86,7 @@ public class CooldownManager { } public void createPlayer(CooldownType cooldownType, OfflinePlayer player) { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); List cooldowns = cooldownStorage.get(cooldownType); @@ -100,11 +95,11 @@ public class CooldownManager { int time = 0; if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { - time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + time = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getInt("Island." + cooldownType.name() + ".Cooldown.Time"); Config config = fileManager - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -116,11 +111,11 @@ public class CooldownManager { e.printStackTrace(); } } else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) { - time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + time = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getInt("Island." + cooldownType.name() + ".Cooldown.Time"); - Config config = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")); + Config config = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -140,13 +135,13 @@ public class CooldownManager { for (Iterator it = getCooldownPlayersOrEmptyList(cooldownType).iterator(); it.hasNext();) { if (it.next().getUUID().equals(player.getUniqueId())) { if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { - skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), + plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")) .getFileConfiguration().set("Island." + cooldownType.name() + ".Cooldown", null); } else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")) .getFileConfiguration().set(cooldownType.name() + ".Cooldown", null); } it.remove(); @@ -198,13 +193,13 @@ public class CooldownManager { for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) { if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) { if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) { - skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), + plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")) .getFileConfiguration().set("Island." + cooldownType + ".Cooldown", cooldownPlayerList.getCooldown().getTime()); } else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) { - skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")) .getFileConfiguration().set(cooldownType.name() + ".Cooldown", cooldownPlayerList.getCooldown().getTime()); } @@ -223,11 +218,11 @@ public class CooldownManager { Config config = null; 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")); + config = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); } else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) { - config = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")); + config = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml")); } if (config != null) { diff --git a/src/main/java/com/songoda/skyblock/generator/Generator.java b/src/main/java/com/songoda/skyblock/generator/Generator.java index 0e5a53f1..95f0e365 100644 --- a/src/main/java/com/songoda/skyblock/generator/Generator.java +++ b/src/main/java/com/songoda/skyblock/generator/Generator.java @@ -3,7 +3,6 @@ package com.songoda.skyblock.generator; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.island.IslandWorld; - import java.util.List; public class Generator { diff --git a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java index 28bd5075..6e32035c 100644 --- a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java +++ b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java @@ -4,7 +4,6 @@ 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; @@ -22,16 +21,16 @@ import java.util.Random; public class GeneratorManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private List generatorStorage = new ArrayList<>(); - public GeneratorManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public GeneratorManager(SkyBlock plugin) { + this.plugin = plugin; registerGenerators(); } public void registerGenerators() { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "generators.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "generators.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString("Generators") == null) @@ -123,7 +122,7 @@ public class GeneratorManager { CompatibleMaterial materials = getRandomMaterials(generator); if (materials == null) return block.getState(); - skyblock.getSoundManager().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 10.0F); + plugin.getSoundManager().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 10.0F); if (NMSUtil.getVersionNumber() > 12) { diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java index bab25d1f..162f756b 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java @@ -2,37 +2,18 @@ package com.songoda.skyblock.gui.bank; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.gui.AnvilGui; import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiManager; import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.bank.BankManager; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.gui.GuiSignatureEditor; -import com.songoda.skyblock.gui.GuiWelcomeEditor; import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandMessage; -import com.songoda.skyblock.island.IslandPermission; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.permission.BasicPermission; -import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.NumberUtil; -import com.songoda.skyblock.visit.Visit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import javax.annotation.Nonnull; import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; public class GuiBank extends Gui { private final SkyBlock plugin; diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index 9a6fa262..5df17f83 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -14,8 +14,6 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.io.File; import java.util.Objects; diff --git a/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java index 05edc6a8..070d5a30 100644 --- a/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java @@ -3,7 +3,6 @@ package com.songoda.skyblock.gui.biome; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.enchantments.Enchantment; @@ -12,7 +11,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.io.File; -import java.util.Map; public class BiomeIcon { public final CompatibleBiome biome; diff --git a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java index f848d880..1e8abf8d 100644 --- a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java @@ -24,7 +24,10 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.ListIterator; public class GuiBiome extends Gui { private final SkyBlock plugin; diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java index 66097e2e..6c1d8d63 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiAdminPermissions.java @@ -7,21 +7,15 @@ import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandPermission; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.permission.BasicPermission; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.visit.Visit; -import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java index cf29cd98..58fa797f 100644 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiBans.java @@ -6,7 +6,6 @@ import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.ban.BanManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; diff --git a/src/main/java/com/songoda/skyblock/invite/InviteManager.java b/src/main/java/com/songoda/skyblock/invite/InviteManager.java index 97b4b2c8..ed62949c 100644 --- a/src/main/java/com/songoda/skyblock/invite/InviteManager.java +++ b/src/main/java/com/songoda/skyblock/invite/InviteManager.java @@ -11,8 +11,8 @@ public class InviteManager { private Map inviteStorage = new HashMap<>(); - public InviteManager(SkyBlock skyblock) { - new InviteTask(this, skyblock).runTaskTimerAsynchronously(skyblock, 0L, 20L); + public InviteManager(SkyBlock plugin) { + new InviteTask(this, plugin).runTaskTimerAsynchronously(plugin, 0L, 20L); } public Invite createInvite(Player player, Player sender, UUID owner, int time) { diff --git a/src/main/java/com/songoda/skyblock/invite/InviteTask.java b/src/main/java/com/songoda/skyblock/invite/InviteTask.java index a24261ea..3ebafda2 100644 --- a/src/main/java/com/songoda/skyblock/invite/InviteTask.java +++ b/src/main/java/com/songoda/skyblock/invite/InviteTask.java @@ -19,20 +19,20 @@ import java.io.File; public class InviteTask extends BukkitRunnable { - private final SkyBlock skyblock; + private final SkyBlock plugin; private final InviteManager inviteManager; - protected InviteTask(InviteManager inviteManager, SkyBlock skyblock) { + protected InviteTask(InviteManager inviteManager, SkyBlock plugin) { this.inviteManager = inviteManager; - this.skyblock = skyblock; + this.plugin = plugin; } @Override public void run() { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); for (Player all : Bukkit.getOnlinePlayers()) { diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 3d9066cf..9843540c 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -34,7 +34,7 @@ import java.util.Map.Entry; public class Island { - private final SkyBlock skyblock; + private final SkyBlock plugin; private final com.songoda.skyblock.api.island.Island apiWrapper; private final Map> islandPermissions = new HashMap<>(); @@ -51,15 +51,15 @@ public class Island { private boolean deleted = false; public Island(OfflinePlayer player) { - this.skyblock = SkyBlock.getInstance(); + this.plugin = SkyBlock.getInstance(); - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); this.islandUUID = UUID.randomUUID(); this.ownerUUID = player.getUniqueId(); - this.size = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + this.size = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getInt("Island.Size.Minimum"); - this.maxMembers = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + this.maxMembers = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getInt("Island.Member.Capacity", 3); if (this.size > 1000) { @@ -73,7 +73,7 @@ public class Island { if (player.isOnline()) { int customSize = PlayerUtils.getNumberFromPermission(player.getPlayer(), "fabledskyblock.size", 0); if (customSize > 0 || player.getPlayer().hasPermission("fabledskyblock.*")) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); int minimumSize = configLoad.getInt("Island.Size.Minimum"); @@ -97,13 +97,13 @@ public class Island { } } - level = new IslandLevel(getOwnerUUID(), skyblock); + level = new IslandLevel(getOwnerUUID(), plugin); - File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); + File configFile = new File(plugin.getDataFolder().toString() + "/island-data"); Config config = fileManager.getConfig(new File(configFile, ownerUUID + ".yml")); - Config defaultSettingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "settings.yml")); - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config defaultSettingsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "settings.yml")); + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration(); @@ -145,7 +145,7 @@ public class Island { for (int i = 0; i < members.size(); i++) { String member = members.get(i); Config playerDataConfig = new FileManager.Config(fileManager, - new File(skyblock.getDataFolder().toString() + "/player-data", member + ".yml")); + new File(plugin.getDataFolder().toString() + "/player-data", member + ".yml")); FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration(); if (playerDataConfigLoad.getString("Island.Owner") == null @@ -163,7 +163,7 @@ public class Island { for (int i = 0; i < operators.size(); i++) { String operator = operators.get(i); Config playerDataConfig = new FileManager.Config(fileManager, - new File(skyblock.getDataFolder().toString() + "/player-data", operator + ".yml")); + new File(plugin.getDataFolder().toString() + "/player-data", operator + ".yml")); FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration(); if (playerDataConfigLoad.getString("Island.Owner") == null @@ -177,14 +177,14 @@ public class Island { Config settingsDataConfig = null; - File settingDataFile = new File(skyblock.getDataFolder().toString() + "/setting-data", getOwnerUUID().toString() + ".yml"); + File settingDataFile = new File(plugin.getDataFolder().toString() + "/setting-data", getOwnerUUID().toString() + ".yml"); if (fileManager.isFileExist(settingDataFile)) { settingsDataConfig = fileManager.getConfig(settingDataFile); } for (IslandRole roleList : IslandRole.getRoles()) { - List allPermissions = skyblock.getPermissionManager().getPermissions(); + List allPermissions = plugin.getPermissionManager().getPermissions(); List permissions = new ArrayList<>(allPermissions.size()); for (BasicPermission permission : allPermissions) { @@ -242,7 +242,7 @@ public class Island { configLoad.set("Ownership.Original", ownerUUID.toString()); for (IslandRole roleList : IslandRole.getRoles()) { - List allPermissions = skyblock.getPermissionManager().getPermissions(); + List allPermissions = plugin.getPermissionManager().getPermissions(); List permissions = new ArrayList<>(allPermissions.size()); for (BasicPermission permission : allPermissions) { @@ -260,11 +260,11 @@ public class Island { Player onlinePlayer = Bukkit.getServer().getPlayer(ownerUUID); - if (!skyblock.getPlayerDataManager().hasPlayerData(onlinePlayer)) { - skyblock.getPlayerDataManager().createPlayerData(onlinePlayer); + if (!plugin.getPlayerDataManager().hasPlayerData(onlinePlayer)) { + plugin.getPlayerDataManager().createPlayerData(onlinePlayer); } - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(onlinePlayer); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(onlinePlayer); playerData.setPlaytime(0); playerData.setOwner(ownerUUID); playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date())); @@ -272,7 +272,7 @@ public class Island { } if (!mainConfigLoad.getBoolean("Island.Coop.Unload")) { - File coopDataFile = new File(skyblock.getDataFolder().toString() + "/coop-data", + File coopDataFile = new File(plugin.getDataFolder().toString() + "/coop-data", getOwnerUUID().toString() + ".yml"); if (fileManager.isFileExist(coopDataFile)) { @@ -304,7 +304,7 @@ public class Island { } public UUID getOriginalOwnerUUID() { - return UUID.fromString(skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return UUID.fromString(plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Ownership.Original")); } @@ -318,8 +318,8 @@ public class Island { } this.maxMembers = maxMembers; - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("MaxMembers", maxMembers); } @@ -333,8 +333,8 @@ public class Island { } this.size = size; - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Size", size); } @@ -343,14 +343,14 @@ public class Island { } public boolean hasPassword() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Ownership.Password") != null; } public String getPassword() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Ownership.Password"); } @@ -358,8 +358,8 @@ public class Island { IslandPasswordChangeEvent islandPasswordChangeEvent = new IslandPasswordChangeEvent(getAPIWrapper(), password); Bukkit.getServer().getPluginManager().callEvent(islandPasswordChangeEvent); - skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Ownership.Password", islandPasswordChangeEvent.getPassword()); } @@ -391,24 +391,24 @@ public class Island { public void setLocation(IslandWorld world, IslandEnvironment environment, Location location) { for (IslandLocation islandLocationList : islandLocations) { if (islandLocationList.getWorld() == world && islandLocationList.getEnvironment() == environment) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandLocationChangeEvent(getAPIWrapper(), new com.songoda.skyblock.api.island.IslandLocation( APIUtil.fromImplementation(environment), APIUtil.fromImplementation(world), location)))); - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); if (environment == IslandEnvironment.Island) { fileManager.setLocation( fileManager - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), getOwnerUUID().toString() + ".yml")), "Location." + world.name() + "." + environment.name(), location, true); } else { fileManager.setLocation( fileManager - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), getOwnerUUID().toString() + ".yml")), "Location." + world.name() + ".Spawn." + environment.name(), location, true); } @@ -421,31 +421,31 @@ public class Island { } public boolean isBorder() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getBoolean("Border.Enable"); } public void setBorder(boolean border) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Border.Enable", border); } public WorldBorder.Color getBorderColor() { - return WorldBorder.Color.valueOf(skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return WorldBorder.Color.valueOf(plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Border.Color")); } public void setBorderColor(WorldBorder.Color color) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Border.Color", color.name()); } public boolean isInBorder(Location blockLocation) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!isBorder()) { return true; } @@ -464,8 +464,8 @@ public class Island { } public Biome getBiome() { - return Biome.valueOf(skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return Biome.valueOf(plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Biome.Type")); } @@ -473,8 +473,8 @@ public class Island { IslandBiomeChangeEvent islandBiomeChangeEvent = new IslandBiomeChangeEvent(getAPIWrapper(), biome); Bukkit.getServer().getPluginManager().callEvent(islandBiomeChangeEvent); - skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Biome.Type", islandBiomeChangeEvent.getBiome().name()); } @@ -484,8 +484,8 @@ public class Island { } public boolean isWeatherSynchronized() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getBoolean("Weather.Synchronised"); } @@ -494,14 +494,14 @@ public class Island { getTime(), sync); Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent); - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Weather.Synchronised", sync); } public WeatherType getWeather() { - String weatherTypeName = skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + String weatherTypeName = plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Weather.Weather"); WeatherType weatherType; @@ -524,8 +524,8 @@ public class Island { getTime(), isWeatherSynchronized()); Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent); - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Weather.Weather", weatherType.name()); } @@ -534,8 +534,8 @@ public class Island { } public int getTime() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getInt("Weather.Time"); } @@ -544,8 +544,8 @@ public class Island { time, isWeatherSynchronized()); Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent); - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Weather.Time", time); } @@ -555,12 +555,12 @@ public class Island { public void addCoopPlayer(UUID uuid, IslandCoop islandCoop) { coopPlayers.put(uuid, islandCoop); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public void removeCoopPlayer(UUID uuid) { coopPlayers.remove(uuid); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public boolean isCoopPlayer(UUID uuid) { @@ -572,14 +572,14 @@ public class Island { } public void setAlwaysLoaded(boolean alwaysLoaded) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("AlwaysLoaded", alwaysLoaded); } public boolean isAlwaysLoaded() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getBoolean("AlwaysLoaded", false); } @@ -589,8 +589,8 @@ public class Island { if (role == IslandRole.Owner) { islandRoles.add(getOwnerUUID()); } else { - Config config = skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString(role.name() + "s") != null) { @@ -631,8 +631,8 @@ public class Island { } } - Config config = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + Config config = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), getOwnerUUID().toString() + ".yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -666,8 +666,8 @@ public class Island { public boolean removeRole(IslandRole role, UUID uuid) { if (!(role == IslandRole.Visitor || role == IslandRole.Coop || role == IslandRole.Owner)) { if (hasRole(role, uuid)) { - Config config = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + Config config = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), getOwnerUUID().toString() + ".yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -693,15 +693,15 @@ public class Island { public boolean hasRole(IslandRole role, UUID uuid) { if (role == IslandRole.Owner) { - return getOwnerUUID().equals(uuid) || skyblock.getIslandManager().isPlayerProxyingAnotherPlayer(uuid, getOwnerUUID()); + return getOwnerUUID().equals(uuid) || plugin.getIslandManager().isPlayerProxyingAnotherPlayer(uuid, getOwnerUUID()); } return getRole(role).contains(uuid); } public void setUpgrade(Player player, Upgrade.Type type, boolean status) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Upgrade." + type.name(), status); Bukkit.getServer().getPluginManager() @@ -709,20 +709,20 @@ public class Island { } public void removeUpgrade(Upgrade.Type type) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Upgrade." + type.name(), null); } public boolean hasUpgrade(Upgrade.Type type) { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Upgrade." + type.name()) != null; } public boolean isUpgrade(Upgrade.Type type) { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getBoolean("Upgrade." + type.name()); } @@ -755,16 +755,16 @@ public class Island { } public double getBankBalance() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getDouble("Bank.Balance"); } public void addToBank(double value) { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); Config config = fileManager - .getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); + .getConfig(new File(plugin.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); value = getBankBalance() + value; config.getFileConfiguration().set("Bank.Balance", value); @@ -796,15 +796,15 @@ public class Island { if(!islandStatusChangeEvent.isCancelled()) { this.status = status; getVisit().setStatus(status); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } } public List getMessage(IslandMessage message) { List islandMessage = new ArrayList<>(); - Config config = skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString("Visitor." + message.name() + ".Message") != null) { @@ -815,8 +815,8 @@ public class Island { } public String getMessageAuthor(IslandMessage message) { - Config config = skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString("Visitor." + message.name() + ".Author") != null) { @@ -832,8 +832,8 @@ public class Island { Bukkit.getServer().getPluginManager().callEvent(islandMessageChangeEvent); if (!islandMessageChangeEvent.isCancelled()) { - Config config = skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Visitor." + message.name() + ".Message", islandMessageChangeEvent.getLines()); configLoad.set("Visitor." + message.name() + ".Author", islandMessageChangeEvent.getAuthor()); @@ -849,23 +849,23 @@ public class Island { } public String getStructure() { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Structure"); } public void setStructure(String structure) { - skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + plugin.getFileManager().getConfig( + new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().set("Structure", structure); } public Visit getVisit() { - return skyblock.getVisitManager().getIsland(getOwnerUUID()); + return plugin.getVisitManager().getIsland(getOwnerUUID()); } public Ban getBan() { - return skyblock.getBanManager().getIsland(getOwnerUUID()); + return plugin.getBanManager().getIsland(getOwnerUUID()); } public IslandLevel getLevel() { @@ -881,10 +881,10 @@ public class Island { } public synchronized void save() { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); Config config = fileManager - .getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); + .getConfig(new File(plugin.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); List tempWhitelist = new ArrayList<>(); for(UUID uuid : whitelistedPlayers) { @@ -900,7 +900,7 @@ public class Island { } config = fileManager - .getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml")); + .getConfig(new File(plugin.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); for (Entry> entry : islandPermissions.entrySet()) { @@ -915,10 +915,10 @@ public class Island { e.printStackTrace(); } - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Coop.Unload")) { config = fileManager - .getConfig(new File(skyblock.getDataFolder().toString() + "/coop-data", ownerUUID.toString() + ".yml")); + .getConfig(new File(plugin.getDataFolder().toString() + "/coop-data", ownerUUID.toString() + ".yml")); configLoad = config.getFileConfiguration(); List coopPlayersAsString = new ArrayList<>(coopPlayers.size()); @@ -941,13 +941,13 @@ public class Island { } public boolean isRegionUnlocked(Player player, IslandWorld type) { - FileManager fileManager = skyblock.getFileManager(); - SoundManager soundManager = skyblock.getSoundManager(); - MessageManager messageManager = skyblock.getMessageManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager fileManager = plugin.getFileManager(); + SoundManager soundManager = plugin.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Config islandData = fileManager - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoadIslandData = islandData.getFileConfiguration(); double price = configLoad.getDouble("Island.World." + type.name() + ".UnlockPrice"); @@ -960,7 +960,7 @@ public class Island { if (!unlocked) { messageManager.sendMessage(player, - fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration() + fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration() .getString("Island.Unlock." + type.name() + ".Message").replace( "%cost%", NumberUtil.formatNumberByDecimal(price))); @@ -980,7 +980,7 @@ public class Island { public void addWhitelistedPlayer(UUID uuid) { this.whitelistedPlayers.add(uuid); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public boolean isPlayerWhitelisted(UUID uuid) { @@ -989,7 +989,7 @@ public class Island { public void removeWhitelistedPlayer(UUID uuid) { this.whitelistedPlayers.remove(uuid); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public Set getWhitelistedPlayers() { diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java index 9d3d9784..2d73d9f3 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java @@ -17,7 +17,7 @@ import java.util.Map.Entry; public class IslandLevel { - private final SkyBlock skyblock; + private final SkyBlock plugin; private UUID ownerUUID; @@ -29,11 +29,11 @@ public class IslandLevel { // Highest level achieved, to prevent reward farming (since is level can decrease) private long highestLevel; - public IslandLevel(UUID ownerUUID, SkyBlock skyblock) { - this.skyblock = skyblock; + public IslandLevel(UUID ownerUUID, SkyBlock plugin) { + this.plugin = plugin; this.ownerUUID = ownerUUID; - final Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); + final Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); final FileConfiguration configLoad = config.getFileConfiguration(); final ConfigurationSection section = configLoad.getConfigurationSection("Levelling.Materials"); @@ -63,7 +63,7 @@ public class IslandLevel { } public long getPoints() { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "levelling.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml")); FileConfiguration configLoad = config.getFileConfiguration(); ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials"); @@ -94,7 +94,7 @@ public class IslandLevel { } public long getMaterialPoints(String material) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "levelling.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml")); FileConfiguration configLoad = config.getFileConfiguration(); ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials"); @@ -120,14 +120,14 @@ public class IslandLevel { } public long getLevel() { - long division = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Division"); + long division = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Division"); if (division == 0) { division = 1; } long points = getPoints(); - long subtract = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Subtract"); + long subtract = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Subtract"); if(points >= subtract){ points -= subtract; } else { @@ -145,8 +145,8 @@ public class IslandLevel { if (level <= highestLevel) return; - final FileConfiguration language = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); - final FileConfiguration config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); + final FileConfiguration language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + final FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); OfflinePlayer owner = Bukkit.getOfflinePlayer(ownerUUID); @@ -157,16 +157,16 @@ public class IslandLevel { if (config.getBoolean("Island.LevelRewards.Rewards", false)) { // Reward the player for each level reached, message only for the highest, so we don't spam the chat for (int i = (int) highestLevel + 1; i <= level; i++) { - LevelReward levelReward = skyblock.getRewardManager().getReward(i); + LevelReward levelReward = plugin.getRewardManager().getReward(i); if (levelReward != null) - levelReward.give(player, skyblock, i); + levelReward.give(player, plugin, i); - List repeatRewards = skyblock.getRewardManager().getRepeatRewards(i); + List repeatRewards = plugin.getRewardManager().getRepeatRewards(i); if (!repeatRewards.isEmpty()) { for (LevelReward reward : repeatRewards) { - reward.give(player, skyblock, i); + reward.give(player, plugin, i); } } } @@ -177,7 +177,7 @@ public class IslandLevel { if (!Strings.isNullOrEmpty(msg)) { msg = msg.replace("%level%", String.valueOf(level)); - skyblock.getMessageManager().sendMessage(player, msg); + plugin.getMessageManager().sendMessage(player, msg); } } } @@ -186,7 +186,7 @@ public class IslandLevel { } public void setMaterialAmount(String material, long amount) { - skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration() + plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration() .set("Levelling.Materials." + material + ".Amount", amount); this.materials.put(material, amount); @@ -197,7 +197,7 @@ public class IslandLevel { } public void removeMaterial(String material) { - skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration() + plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration() .set("Levelling.Materials." + material, null); this.materials.remove(material); @@ -216,7 +216,7 @@ public class IslandLevel { } public void setMaterials(Map materials) { - Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Levelling.Materials", null); @@ -245,7 +245,7 @@ public class IslandLevel { } public void save() { - Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -257,7 +257,7 @@ public class IslandLevel { } public void setHighestLevel(long highestLevel) { - Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Levelling.Highest-Level", highestLevel); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 4a9d9edd..b84a251a 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -10,6 +10,7 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.api.event.island.*; import com.songoda.skyblock.ban.BanManager; +import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.confirmation.Confirmation; @@ -18,7 +19,6 @@ import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.invite.Invite; import com.songoda.skyblock.invite.InviteManager; import com.songoda.skyblock.island.removal.ChunkDeleteSplitter; -import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; @@ -35,7 +35,6 @@ import com.songoda.skyblock.utils.player.PlayerUtil; import com.songoda.skyblock.utils.structure.SchematicUtil; import com.songoda.skyblock.utils.structure.StructureUtil; import com.songoda.skyblock.utils.version.NMSUtil; -import com.songoda.skyblock.utils.version.SBiome; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.utils.world.WorldBorder; import com.songoda.skyblock.utils.world.block.BlockDegreesType; @@ -62,7 +61,7 @@ import java.util.stream.Collectors; public class IslandManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private List islandPositions = new ArrayList<>(); private Map islandProxies = new HashMap<>(); @@ -71,13 +70,13 @@ public class IslandManager { private HashMap oldSystemIslands; - public IslandManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public IslandManager(SkyBlock plugin) { + this.plugin = plugin; - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "worlds.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "worlds.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - offset = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")) + offset = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Creation.Distance", 1200); for (IslandWorld worldList : IslandWorld.values()) { @@ -105,8 +104,8 @@ public class IslandManager { } public synchronized void saveNextAvailableLocation(IslandWorld world) { - FileManager fileManager = skyblock.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "worlds.yml")); + FileManager fileManager = plugin.getFileManager(); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "worlds.yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -140,8 +139,8 @@ public class IslandManager { for (IslandPosition islandPositionList : islandPositions) { if (islandPositionList.getWorld() == world) { - Config config_world = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "worlds.yml")); - Config config_config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config_world = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "worlds.yml")); + Config config_config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad_world = config_world.getFileConfiguration(); FileConfiguration configLoad_config = config_config.getFileConfiguration(); @@ -182,7 +181,7 @@ public class IslandManager { islandPositionList.setZ((double) posY); // Check if there was an island at this position int oldFormatPos = oldSystemIslands.get(world); - Location islandLocation = new org.bukkit.Location(skyblock.getWorldManager().getWorld(world), islandPositionList.getX(), islandHeight, islandPositionList.getZ()); + Location islandLocation = new org.bukkit.Location(plugin.getWorldManager().getWorld(world), islandPositionList.getX(), islandHeight, islandPositionList.getZ()); if (posX == 1200 && posY >= 0 && posY <= oldFormatPos) { // We have to save to avoid having two islands at same location setNextAvailableLocation(world, islandLocation); @@ -199,12 +198,12 @@ public class IslandManager { } public synchronized boolean createIsland(Player player, Structure structure) { - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - VisitManager visitManager = skyblock.getVisitManager(); - FileManager fileManager = skyblock.getFileManager(); - BanManager banManager = skyblock.getBanManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + VisitManager visitManager = plugin.getVisitManager(); + FileManager fileManager = plugin.getFileManager(); + BanManager banManager = plugin.getBanManager(); - PlayerData data = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData data = plugin.getPlayerDataManager().getPlayerData(player); long amt = 0; @@ -212,14 +211,14 @@ public class IslandManager { final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.create", true, 2); if ((amt = data.getIslandCreationCount()) >= highest) { - skyblock.getMessageManager().sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage")); + plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage")); return false; } } - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") == null) { - skyblock.getMessageManager().sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + if (fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") == null) { + plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.Message")); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return false; } @@ -244,23 +243,23 @@ public class IslandManager { if (!banManager.hasIsland(island.getOwnerUUID())) banManager.createIsland(island.getOwnerUUID()); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); 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); + plugin.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); + plugin.getCooldownManager().createPlayer(CooldownType.Deletion, player); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player))); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player))); data.setIsland(player.getUniqueId()); data.setOwner(player.getUniqueId()); if (scoreboardManager != null) { - Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); Scoreboard scoreboard = scoreboardManager.getScoreboard(player); scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); @@ -268,12 +267,12 @@ public class IslandManager { scoreboard.run(); } - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, () -> { + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); player.setFallDistance(0.0F); }, configLoad.getInt("Island.Creation.TeleportTimeout") * 20); - String biomeName = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase(); + String biomeName = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase(); CompatibleBiome cBiome; try { cBiome = CompatibleBiome.valueOf(biomeName); @@ -282,8 +281,8 @@ public class IslandManager { } Biome biome = cBiome.getBiome(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { - skyblock.getBiomeManager().setBiome(island, biome, () -> { + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { + plugin.getBiomeManager().setBiome(island, biome, () -> { if (structure.getCommands() != null) { for (String commandList : structure.getCommands()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); @@ -294,18 +293,18 @@ public class IslandManager { // Recalculate island level after 5 seconds if (configLoad.getBoolean("Island.Levelling.ScanAutomatically")) - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().startScan(null, island), 100L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> plugin.getLevellingManager().startScan(null, island), 100L); return true; } public synchronized boolean previewIsland(Player player, Structure structure) { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); - PlayerData data = skyblock.getPlayerDataManager().getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + PlayerData data = plugin.getPlayerDataManager().getPlayerData(player); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLang = config.getFileConfiguration(); - config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configMain = config.getFileConfiguration(); @@ -313,15 +312,15 @@ public class IslandManager { final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.create", true, 2); if ((data.getIslandCreationCount()) >= highest) { - skyblock.getMessageManager().sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage")); + plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage")); return false; } } - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") == null) { - skyblock.getMessageManager().sendMessage(player, configLang.getString("Island.Creator.Error.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + if (fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") == null) { + plugin.getMessageManager().sendMessage(player, configLang.getString("Island.Creator.Error.Message")); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return false; } @@ -342,15 +341,15 @@ public class IslandManager { return true; }); - Bukkit.getScheduler().runTaskLater(skyblock, () -> { + Bukkit.getScheduler().runTaskLater(plugin, () -> { if (data.isPreview()) { - Location spawn = fileManager.getLocation(fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")), "Location.Spawn", true); + Location spawn = fileManager.getLocation(fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")), "Location.Spawn", true); PaperLib.teleportAsync(player, spawn); player.setGameMode(GameMode.SURVIVAL); data.setIsland(null); islandStorage.remove(player.getUniqueId(), island); deleteIsland(island, true); - skyblock.getMessageManager().sendMessage(player, configLang.getString("Island.Preview.Timeout.Message")); + plugin.getMessageManager().sendMessage(player, configLang.getString("Island.Preview.Timeout.Message")); data.setPreview(false); } }, configMain.getInt("Island.Preview.Time") * 20); @@ -411,9 +410,9 @@ public class IslandManager { } public synchronized void giveOwnership(Island island, org.bukkit.OfflinePlayer player) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + FileManager fileManager = plugin.getFileManager(); if (island.isDeleted()) { return; @@ -430,57 +429,57 @@ public class IslandManager { level.save(); level.setOwnerUUID(player.getUniqueId()); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Ownership.Password.Reset")) { island.setPassword(null); } - File oldCoopDataFile = new File(new File(skyblock.getDataFolder().toString() + "/coop-data"), uuid2.toString() + ".yml"); + File oldCoopDataFile = new File(new File(plugin.getDataFolder().toString() + "/coop-data"), uuid2.toString() + ".yml"); fileManager.unloadConfig(oldCoopDataFile); if (fileManager.isFileExist(oldCoopDataFile)) { - File newCoopDataFile = new File(new File(skyblock.getDataFolder().toString() + "/coop-data"), player.getUniqueId().toString() + ".yml"); + File newCoopDataFile = new File(new File(plugin.getDataFolder().toString() + "/coop-data"), player.getUniqueId().toString() + ".yml"); fileManager.unloadConfig(newCoopDataFile); oldCoopDataFile.renameTo(newCoopDataFile); } - File oldLevelDataFile = new File(new File(skyblock.getDataFolder().toString() + "/level-data"), uuid2.toString() + ".yml"); - File newLevelDataFile = new File(new File(skyblock.getDataFolder().toString() + "/level-data"), player.getUniqueId().toString() + ".yml"); + File oldLevelDataFile = new File(new File(plugin.getDataFolder().toString() + "/level-data"), uuid2.toString() + ".yml"); + File newLevelDataFile = new File(new File(plugin.getDataFolder().toString() + "/level-data"), player.getUniqueId().toString() + ".yml"); fileManager.unloadConfig(oldLevelDataFile); fileManager.unloadConfig(newLevelDataFile); oldLevelDataFile.renameTo(newLevelDataFile); - File oldSettingDataFile = new File(new File(skyblock.getDataFolder().toString() + "/setting-data"), uuid2.toString() + ".yml"); - File newSettingDataFile = new File(new File(skyblock.getDataFolder().toString() + "/setting-data"), player.getUniqueId().toString() + ".yml"); + File oldSettingDataFile = new File(new File(plugin.getDataFolder().toString() + "/setting-data"), uuid2.toString() + ".yml"); + File newSettingDataFile = new File(new File(plugin.getDataFolder().toString() + "/setting-data"), player.getUniqueId().toString() + ".yml"); fileManager.unloadConfig(oldSettingDataFile); fileManager.unloadConfig(newSettingDataFile); oldSettingDataFile.renameTo(newSettingDataFile); - File oldIslandDataFile = new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid2.toString() + ".yml"); - File newIslandDataFile = new File(new File(skyblock.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml"); + File oldIslandDataFile = new File(new File(plugin.getDataFolder().toString() + "/island-data"), uuid2.toString() + ".yml"); + File newIslandDataFile = new File(new File(plugin.getDataFolder().toString() + "/island-data"), player.getUniqueId().toString() + ".yml"); fileManager.unloadConfig(oldIslandDataFile); fileManager.unloadConfig(newIslandDataFile); oldIslandDataFile.renameTo(newIslandDataFile); - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.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"); + File oldChallengeDataFile = new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), uuid2.toString() + ".yml"); + File newChallengeDataFile = new File(new File(plugin.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()); + plugin.getVisitManager().transfer(uuid2, player.getUniqueId()); + plugin.getBanManager().transfer(uuid2, player.getUniqueId()); + plugin.getInviteManager().tranfer(uuid2, player.getUniqueId()); org.bukkit.OfflinePlayer player1 = Bukkit.getServer().getOfflinePlayer(uuid2); @@ -513,7 +512,7 @@ public class IslandManager { Player targetPlayer = Bukkit.getServer().getPlayer(islandMemberList); if (targetPlayer == null) { - File configFile = new File(new File(skyblock.getDataFolder().toString() + "/player-data"), islandMemberList.toString() + ".yml"); + File configFile = new File(new File(plugin.getDataFolder().toString() + "/player-data"), islandMemberList.toString() + ".yml"); configLoad = YamlConfiguration.loadConfiguration(configFile); configLoad.set("Island.Owner", player.getUniqueId().toString()); @@ -533,11 +532,11 @@ public class IslandManager { } public synchronized boolean deleteIsland(Island island, boolean force) { - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - FileManager fileManager = skyblock.getFileManager(); - WorldManager worldManager = skyblock.getWorldManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + FileManager fileManager = plugin.getFileManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!force) { PlayerData data = playerDataManager.getPlayerData(island.getOwnerUUID()); @@ -561,21 +560,21 @@ public class IslandManager { startDeletion(island, worldManager); - skyblock.getVisitManager().deleteIsland(island.getOwnerUUID()); - skyblock.getBanManager().deleteIsland(island.getOwnerUUID()); - skyblock.getVisitManager().removeVisitors(island, VisitManager.Removal.Deleted); + plugin.getVisitManager().deleteIsland(island.getOwnerUUID()); + plugin.getBanManager().deleteIsland(island.getOwnerUUID()); + plugin.getVisitManager().removeVisitors(island, VisitManager.Removal.Deleted); org.bukkit.OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); cooldownManager.removeCooldownPlayer(CooldownType.Levelling, offlinePlayer); cooldownManager.removeCooldownPlayer(CooldownType.Ownership, offlinePlayer); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); 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")); + config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); configLoad = config.getFileConfiguration(); for (Player all : Bukkit.getOnlinePlayers()) { @@ -598,28 +597,28 @@ public class IslandManager { } // TODO - Find a way to delete also offline players - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Deletion.ClearInventory", false)){ all.getInventory().clear(); } - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.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); + plugin.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); + plugin.getCooldownManager().createPlayer(CooldownType.Deletion, all); } } } - InviteManager inviteManager = skyblock.getInviteManager(); + InviteManager inviteManager = plugin.getInviteManager(); if (inviteManager.hasInvite(all.getUniqueId())) { Invite invite = inviteManager.getInvite(all.getUniqueId()); @@ -630,13 +629,13 @@ public class IslandManager { } } - fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/coop-data"), island.getOwnerUUID().toString() + ".yml")); - 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() + fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/coop-data"), island.getOwnerUUID().toString() + ".yml")); + fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), island.getOwnerUUID().toString() + ".yml")); + fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID().toString() + ".yml")); + fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)){ - fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID().toString() + ".yml")); + fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID().toString() + ".yml")); } Bukkit.getServer().getPluginManager().callEvent(new IslandDeleteEvent(island.getAPIWrapper())); @@ -656,8 +655,8 @@ public class IslandManager { final World world = worldManager.getWorld(worldList); - if(skyblock.isPaperAsync()){ - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { + if(plugin.isPaperAsync()){ + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { List positions = new LinkedList<>(); for (CompletableFuture chunk : asyncChunks) { positions.add(chunk.join()); @@ -666,8 +665,8 @@ public class IslandManager { ChunkDeleteSplitter.startDeletion(snapshots); }, null); } else { - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncChunks, syncChunks) -> { - Bukkit.getScheduler().runTask(skyblock, () -> { + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { + Bukkit.getScheduler().runTask(plugin, () -> { final List list = syncChunks.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); snapshots.put(world, list); @@ -680,27 +679,27 @@ public class IslandManager { } public synchronized void deleteIslandData(UUID uuid) { - FileManager fileManager = skyblock.getFileManager(); - fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml")); - fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/ban-data", uuid.toString() + ".yml")); - fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/coop-data", uuid.toString() + ".yml")); - 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() + FileManager fileManager = plugin.getFileManager(); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/ban-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/coop-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/level-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/setting-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/visit-data", uuid.toString() + ".yml")); + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)){ - fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/challenge-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/challenge-data", uuid.toString() + ".yml")); } } public void loadIsland(org.bukkit.OfflinePlayer player) { - VisitManager visitManager = skyblock.getVisitManager(); - FileManager fileManager = skyblock.getFileManager(); - BanManager banManager = skyblock.getBanManager(); + VisitManager visitManager = plugin.getVisitManager(); + FileManager fileManager = plugin.getFileManager(); + BanManager banManager = plugin.getBanManager(); UUID islandOwnerUUID = null; - Config config = fileManager.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); + Config config = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (isIslandExist(player.getUniqueId())) { @@ -723,7 +722,7 @@ public class IslandManager { //return getIsland(player); return; } else { - config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml")); + config = fileManager.getConfig(new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml")); if (config.getFileConfiguration().getString("Location") == null) { deleteIslandData(islandOwnerUUID); @@ -751,7 +750,7 @@ public class IslandManager { banManager.createIsland(island.getOwnerUUID()); } - Bukkit.getScheduler().runTask(skyblock, () -> + Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper()))); return; @@ -767,10 +766,10 @@ public class IslandManager { public void loadIslandPositions() { oldSystemIslands = new HashMap<>(); - FileManager fileManager = skyblock.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/worlds.yml")); + FileManager fileManager = plugin.getFileManager(); + Config config = fileManager.getConfig(new File(plugin.getDataFolder().toString() + "/worlds.yml")); FileConfiguration fileConfig = config.getFileConfiguration(); - Config config2 = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/worlds.oldformat.yml")); + Config config2 = fileManager.getConfig(new File(plugin.getDataFolder().toString() + "/worlds.oldformat.yml")); FileConfiguration fileConfig2 = config2.getFileConfiguration(); // TODO Find a way to automatically @@ -808,8 +807,8 @@ public class IslandManager { } public void loadIslandAtLocation(Location location) { - FileManager fileManager = skyblock.getFileManager(); - File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); + FileManager fileManager = plugin.getFileManager(); + File configFile = new File(plugin.getDataFolder().toString() + "/island-data"); if (!configFile.exists()) return; @@ -842,10 +841,10 @@ public class IslandManager { public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) { if (island.isAlwaysLoaded()) return; - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - FileManager fileManager = skyblock.getFileManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (island.isDeleted()) return; @@ -887,14 +886,14 @@ public class IslandManager { return; } - unloadIsland = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Unload"); + unloadIsland = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Unload"); if (unloadIsland) { - VisitManager visitManager = skyblock.getVisitManager(); + VisitManager visitManager = plugin.getVisitManager(); visitManager.removeVisitors(island, VisitManager.Removal.Unloaded); visitManager.unloadIsland(island.getOwnerUUID()); - BanManager banManager = skyblock.getBanManager(); + BanManager banManager = plugin.getBanManager(); banManager.unloadIsland(island.getOwnerUUID()); } else { int nonIslandMembers = islandVisitors - getCoopPlayersAtIsland(island).size(); @@ -910,27 +909,27 @@ public class IslandManager { } } - fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/coop-data"), island.getOwnerUUID() + ".yml")); - 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")); + fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/coop-data"), island.getOwnerUUID() + ".yml")); + fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID() + ".yml")); + fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID() + ".yml")); - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)){ - fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID() + ".yml")); + fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID() + ".yml")); } islandStorage.remove(island.getOwnerUUID()); - Bukkit.getScheduler().runTask(skyblock, () -> { + Bukkit.getScheduler().runTask(plugin, () -> { Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper())); }); } public void prepareIsland(Island island, IslandWorld world) { - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml")); if (config.getFileConfiguration().getString("Location." + world.name()) == null) { pasteStructure(island, world); @@ -949,7 +948,7 @@ public class IslandManager { island.addLocation(world, environmentList, worldManager.getLocation(location, world)); } - Bukkit.getServer().getScheduler().runTask(skyblock, () -> removeSpawnProtection(island.getLocation(world, IslandEnvironment.Island))); + Bukkit.getServer().getScheduler().runTask(plugin, () -> removeSpawnProtection(island.getLocation(world, IslandEnvironment.Island))); } public void resetIsland(Island island) { @@ -963,8 +962,8 @@ public class IslandManager { public void pasteStructure(Island island, IslandWorld world) { if (!isIslandWorldUnlocked(island, world)) return; - StructureManager structureManager = skyblock.getStructureManager(); - FileManager fileManager = skyblock.getFileManager(); + StructureManager structureManager = plugin.getStructureManager(); + FileManager fileManager = plugin.getFileManager(); Structure structure; @@ -976,7 +975,7 @@ public class IslandManager { org.bukkit.Location islandLocation = prepareNextAvailableLocation(world); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder().toString() + "/island-data", island.getOwnerUUID() + ".yml")); for (IslandEnvironment environmentList : IslandEnvironment.values()) { if (environmentList == IslandEnvironment.Island) { @@ -988,8 +987,8 @@ public class IslandManager { } } - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { - Bukkit.getServer().getScheduler().runTask(skyblock, () -> islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE)); + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { + Bukkit.getServer().getScheduler().runTask(plugin, () -> islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE)); } try { @@ -1007,7 +1006,7 @@ public class IslandManager { } boolean isStructureFile = structureFileName.endsWith(".structure"); - File structureFile = new File(new File(skyblock.getDataFolder().toString() + "/" + (isStructureFile ? "structures" : "schematics")), structureFileName); + File structureFile = new File(new File(plugin.getDataFolder().toString() + "/" + (isStructureFile ? "structures" : "schematics")), structureFileName); Float[] direction; if (isStructureFile) { @@ -1036,8 +1035,8 @@ public class IslandManager { * @param islandWorld The island world type to unlock */ public void unlockIslandWorld(Island island, IslandWorld islandWorld) { - FileManager fileManager = skyblock.getFileManager(); - Config islandData = fileManager.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); + FileManager fileManager = plugin.getFileManager(); + Config islandData = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); FileConfiguration configLoadIslandData = islandData.getFileConfiguration(); configLoadIslandData.set("Unlocked." + islandWorld.name(), true); @@ -1045,8 +1044,8 @@ public class IslandManager { pasteStructure(island, islandWorld); // Recalculate island level after 5 seconds - if (fileManager.getConfig(new File(this.skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) { - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().startScan(null, island), 100L); + if (fileManager.getConfig(new File(this.plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) { + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> plugin.getLevellingManager().startScan(null, island), 100L); } } @@ -1060,13 +1059,13 @@ public class IslandManager { public boolean isIslandWorldUnlocked(Island island, IslandWorld islandWorld) { if (islandWorld == IslandWorld.Normal) return true; - FileManager fileManager = skyblock.getFileManager(); - Config islandData = fileManager.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); + FileManager fileManager = plugin.getFileManager(); + Config islandData = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); FileConfiguration configLoadIslandData = islandData.getFileConfiguration(); boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + islandWorld.name()); if (!unlocked) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); double price = configLoad.getDouble("Island.World." + islandWorld.name() + ".UnlockPrice"); if (price == -1) unlocked = true; @@ -1076,7 +1075,7 @@ public class IslandManager { } public Set getVisitorsAtIsland(Island island) { - Map playerDataStorage = skyblock.getPlayerDataManager().getPlayerData(); + Map playerDataStorage = plugin.getPlayerDataManager().getPlayerData(); Set islandVisitors = new HashSet<>(); for (UUID playerDataStorageList : playerDataStorage.keySet()) { @@ -1096,10 +1095,10 @@ public class IslandManager { } public void visitIsland(Player player, Island island) { - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - FileManager fileManager = skyblock.getFileManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + FileManager fileManager = plugin.getFileManager(); - Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = languageConfig.getFileConfiguration(); if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { @@ -1111,7 +1110,7 @@ public class IslandManager { } } else { player.sendMessage(ChatColor.translateAlternateColorCodes('&', - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.Teleport.Unsafe.Message"))); } } else { @@ -1120,7 +1119,7 @@ public class IslandManager { if (islandVisitors == 0) { for (Player all : Bukkit.getOnlinePlayers()) { - PlayerData targetPlayerData = skyblock.getPlayerDataManager().getPlayerData(all); + PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(all); if (targetPlayerData.getOwner() != null && targetPlayerData.getOwner().equals(island.getOwnerUUID())) { Scoreboard scoreboard = scoreboardManager.getScoreboard(all); @@ -1152,7 +1151,7 @@ public class IslandManager { } } else { player.sendMessage(ChatColor.translateAlternateColorCodes('&', - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message"))); } if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ @@ -1161,7 +1160,7 @@ public class IslandManager { List islandWelcomeMessage = island.getMessage(IslandMessage.Welcome); - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable") && islandWelcomeMessage.size() != 0) { + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable") && islandWelcomeMessage.size() != 0) { for (String islandWelcomeMessageList : islandWelcomeMessage) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', islandWelcomeMessageList)); } @@ -1172,9 +1171,9 @@ public class IslandManager { } public void closeIsland(Island island) { - MessageManager messageManager = skyblock.getMessageManager(); + MessageManager messageManager = plugin.getMessageManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); island.setStatus(IslandStatus.CLOSED); @@ -1199,9 +1198,9 @@ public class IslandManager { } public void whitelistIsland(Island island) { - MessageManager messageManager = skyblock.getMessageManager(); + MessageManager messageManager = plugin.getMessageManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); island.setStatus(IslandStatus.WHITELISTED); @@ -1226,7 +1225,7 @@ public class IslandManager { } public Island getIsland(org.bukkit.OfflinePlayer offlinePlayer) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); UUID uuid = offlinePlayer.getUniqueId(); if (islandProxies.containsKey(uuid)) uuid = islandProxies.get(uuid); @@ -1279,7 +1278,7 @@ public class IslandManager { } public boolean isIslandExist(UUID uuid) { - return skyblock.getFileManager().isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); + return plugin.getFileManager().isFileExist(new File(new File(plugin.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); } /* @@ -1360,7 +1359,7 @@ public class IslandManager { public Island getIslandPlayerAt(Player player) { Preconditions.checkArgument(player != null, "Cannot get Island to null player"); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); @@ -1377,7 +1376,7 @@ public class IslandManager { } public boolean isPlayerAtAnIsland(Player player) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); @@ -1389,15 +1388,15 @@ public class IslandManager { } public void loadPlayer(Player player) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { if (worldManager.isIslandWorld(player.getWorld())) { IslandWorld world = worldManager.getIslandWorld(player.getWorld()); Island island = getIslandAtLocation(player.getLocation()); if (island != null) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (!island.isWeatherSynchronized()) { @@ -1446,14 +1445,14 @@ public class IslandManager { Island island = getIslandAtLocation(player.getLocation()); - UpgradeManager upgradeManager = skyblock.getUpgradeManager(); + UpgradeManager upgradeManager = plugin.getUpgradeManager(); List flyUpgrades = upgradeManager.getUpgrades(Upgrade.Type.Fly); boolean isFlyUpgradeEnabled = flyUpgrades != null && flyUpgrades.size() > 0 && flyUpgrades.get(0).isEnabled(); boolean setPlayerFlying = false; if (isFlyUpgradeEnabled) { boolean upgradeEnabled = island != null && island.isUpgrade(Upgrade.Type.Fly); setPlayerFlying = upgradeEnabled; - Bukkit.getServer().getScheduler().runTask(skyblock, () -> player.setAllowFlight(upgradeEnabled)); + Bukkit.getServer().getScheduler().runTask(plugin, () -> player.setAllowFlight(upgradeEnabled)); } if (island == null || setPlayerFlying) return; @@ -1461,9 +1460,9 @@ public class IslandManager { boolean hasGlobalFlyPermission = player.hasPermission("fabledskyblock.*") || player.hasPermission("fabledskyblock.fly.*"); boolean hasOwnIslandFlyPermission = player.hasPermission("fabledskyblock.fly") && island.getRole(player) != null && island.getRole(player) != IslandRole.Visitor; if (hasGlobalFlyPermission || hasOwnIslandFlyPermission) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); boolean canFlyInWorld = worldManager.isIslandWorld(player.getWorld()); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> player.setAllowFlight(canFlyInWorld)); + Bukkit.getServer().getScheduler().runTask(plugin, () -> player.setAllowFlight(canFlyInWorld)); } } @@ -1485,13 +1484,13 @@ public class IslandManager { } public boolean removeCoopPlayers(Island island, UUID uuid) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - boolean coopPlayers = island.hasPermission(IslandRole.Operator, skyblock.getPermissionManager().getPermission("CoopPlayers")); + boolean coopPlayers = island.hasPermission(IslandRole.Operator, plugin.getPermissionManager().getPermission("CoopPlayers")); for (Player all : Bukkit.getOnlinePlayers()) { if (uuid != null && all.getUniqueId().equals(uuid)) { @@ -1527,7 +1526,7 @@ public class IslandManager { } public int getIslandSafeLevel(Island island) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); int safeLevel = 0; @@ -1538,7 +1537,7 @@ public class IslandManager { settings.put("Damage", true); for (String settingList : settings.keySet()) { - if (configLoad.getBoolean("Island.Settings." + settingList + ".Enable") && island.hasPermission(IslandRole.Owner, skyblock.getPermissionManager().getPermission(settingList)) == settings.get(settingList)) { + if (configLoad.getBoolean("Island.Settings." + settingList + ".Enable") && island.hasPermission(IslandRole.Owner, plugin.getPermissionManager().getPermission(settingList)) == settings.get(settingList)) { safeLevel++; } } @@ -1547,10 +1546,10 @@ public class IslandManager { } public void updateBorder(Island island) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); if (island.isBorder()) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { if (worldList == IslandWorld.Nether) { if (NMSUtil.getVersionNumber() < 13) { diff --git a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java index 318b728b..ae9059ba 100644 --- a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java +++ b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java @@ -1,21 +1,19 @@ package com.songoda.skyblock.island.removal; +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.blockscanner.BlockInfo; +import com.songoda.skyblock.blockscanner.BlockScanner; +import org.bukkit.ChunkSnapshot; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.scheduler.BukkitRunnable; + import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Queue; -import com.songoda.core.compatibility.CompatibleMaterial; -import org.bukkit.ChunkSnapshot; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.scheduler.BukkitRunnable; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.blockscanner.BlockInfo; -import com.songoda.skyblock.blockscanner.BlockScanner; - public class ChunkDeleteSplitter extends BukkitRunnable { private final Map> snapshots; diff --git a/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java b/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java index e24750fb..b69075b5 100644 --- a/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java +++ b/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java @@ -19,10 +19,10 @@ public class LevelReward { public LevelReward() { } - public void give(Player player, SkyBlock skyblock, long level) { + public void give(Player player, SkyBlock plugin, long level) { if (islandBalance > 0) { - Island island = skyblock.getIslandManager().getIsland(player); + Island island = plugin.getIslandManager().getIsland(player); island.addToBank(islandBalance); } @@ -34,8 +34,8 @@ public class LevelReward { cmd = cmd.replace("%level%", String.valueOf(level)) .replace("%player%", player.getName()) .trim(); - - skyblock.getServer().dispatchCommand(skyblock.getConsole(), cmd); + + plugin.getServer().dispatchCommand(plugin.getConsole(), cmd); } } } diff --git a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java index aadfa975..4ad7b286 100644 --- a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java +++ b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java @@ -17,23 +17,23 @@ import java.util.*; public class LeaderboardManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private List leaderboardStorage = new ArrayList<>(); - public LeaderboardManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public LeaderboardManager(SkyBlock plugin) { + this.plugin = plugin; - new LeaderboardTask(skyblock).runTaskTimerAsynchronously(skyblock, 0L, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20); + new LeaderboardTask(plugin).runTaskTimerAsynchronously(plugin, 0L, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20); resetLeaderboard(); setupLeaderHeads(); } public void resetLeaderboard() { - VisitManager visitManager = skyblock.getVisitManager(); - WorldManager worldManager = skyblock.getWorldManager(); + VisitManager visitManager = plugin.getVisitManager(); + WorldManager worldManager = plugin.getWorldManager(); visitManager.loadIslands(); @@ -43,7 +43,7 @@ public class LeaderboardManager { List islandBanks = new ArrayList<>(arraySize); List islandVotes = new ArrayList<>(arraySize); - boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + boolean enableExemptions = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Leaderboard.Exemptions.Enable"); for (UUID ownerUUID : new LinkedHashSet<>(visitManager.getIslands().keySet())) { @@ -79,7 +79,7 @@ public class LeaderboardManager { } public int getPlayerIslandLeaderboardPosition(OfflinePlayer offlinePlayer, Leaderboard.Type type) { - VisitManager visitManager = skyblock.getVisitManager(); + VisitManager visitManager = plugin.getVisitManager(); visitManager.loadIslands(); List leaderboardPlayers = new ArrayList<>(visitManager.getIslands().size()); @@ -117,9 +117,9 @@ public class LeaderboardManager { public void setupLeaderHeads() { if (Bukkit.getServer().getPluginManager().getPlugin("LeaderHeads") != null) { - new TopLevel(skyblock); - new TopBank(skyblock); - new TopVotes(skyblock); + new TopLevel(plugin); + new TopBank(plugin); + new TopVotes(plugin); } } diff --git a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardTask.java b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardTask.java index b3334236..d6ddba3a 100644 --- a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardTask.java +++ b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardTask.java @@ -5,19 +5,19 @@ import org.bukkit.scheduler.BukkitRunnable; public class LeaderboardTask extends BukkitRunnable { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public LeaderboardTask(SkyBlock skyblock) { - this.skyblock = skyblock; + public LeaderboardTask(SkyBlock plugin) { + this.plugin = plugin; } @Override public void run() { - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); leaderboardManager.clearLeaderboard(); leaderboardManager.resetLeaderboard(); leaderboardManager.setupLeaderHeads(); - - skyblock.getHologramTask().updateHologram(); + + plugin.getHologramTask().updateHologram(); } } diff --git a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopBank.java b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopBank.java index 773b200d..b1693ea9 100644 --- a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopBank.java +++ b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopBank.java @@ -14,21 +14,21 @@ import java.util.Map.Entry; public class TopBank extends DataCollector { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public TopBank(SkyBlock skyblock) { - super("topbank", skyblock.getDescription().getName(), BoardType.DEFAULT, "&bTop Bank", "topbank", + public TopBank(SkyBlock plugin) { + super("topbank", plugin.getDescription().getName(), BoardType.DEFAULT, "&bTop Bank", "topbank", Arrays.asList(ChatColor.DARK_GRAY + "-=+=-", ChatColor.AQUA + "{name}", ChatColor.WHITE + "Bal: ${amount}", ChatColor.DARK_GRAY + "-=+=-"), true, UUID.class); - this.skyblock = skyblock; + this.plugin = plugin; } @Override public List> requestAll() { - List leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Type.Bank); + List leaderboards = plugin.getLeaderboardManager().getLeaderboard(Type.Bank); Map topLevels = new HashMap<>(leaderboards.size()); for (Leaderboard leaderboard : leaderboards) { diff --git a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java index cb3e6883..e4f14baa 100644 --- a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java +++ b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java @@ -13,19 +13,19 @@ import java.util.Map.Entry; public class TopLevel extends DataCollector { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public TopLevel(SkyBlock skyblock) { - super("toplevels", skyblock.getDescription().getName(), BoardType.DEFAULT, "&bTop Level", "toplevel", + public TopLevel(SkyBlock plugin) { + super("toplevels", plugin.getDescription().getName(), BoardType.DEFAULT, "&bTop Level", "toplevel", Arrays.asList(ChatColor.DARK_GRAY + "-=+=-", ChatColor.AQUA + "{name}", ChatColor.WHITE + "{amount} Level", ChatColor.DARK_GRAY + "-=+=-"), true, UUID.class); - this.skyblock = skyblock; + this.plugin = plugin; } @Override public List> requestAll() { - List leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Leaderboard.Type.Level); + List leaderboards = plugin.getLeaderboardManager().getLeaderboard(Leaderboard.Type.Level); Map topLevels = new HashMap<>(leaderboards.size()); for (int i = 0; i < leaderboards.size(); i++) { diff --git a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java index 64c388ec..f2a27e40 100644 --- a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java +++ b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java @@ -14,21 +14,21 @@ import java.util.Map.Entry; public class TopVotes extends DataCollector { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public TopVotes(SkyBlock skyblock) { - super("topvotes", skyblock.getDescription().getName(), BoardType.DEFAULT, "&bTop Votes", "topvotes", + public TopVotes(SkyBlock plugin) { + super("topvotes", plugin.getDescription().getName(), BoardType.DEFAULT, "&bTop Votes", "topvotes", Arrays.asList(ChatColor.DARK_GRAY + "-=+=-", ChatColor.AQUA + "{name}", ChatColor.WHITE + "{amount} Votes", ChatColor.DARK_GRAY + "-=+=-"), true, UUID.class); - this.skyblock = skyblock; + this.plugin = plugin; } @Override public List> requestAll() { - List leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Type.Votes); + List leaderboards = plugin.getLeaderboardManager().getLeaderboard(Type.Votes); Map topLevels = new HashMap<>(leaderboards.size()); for (int i = 0; i < leaderboards.size(); i++) { diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java index 705c66ac..d0faa300 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java @@ -1,21 +1,20 @@ package com.songoda.skyblock.levelling; -import java.io.File; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.ServerVersion; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.blockscanner.BlockInfo; +import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; +import com.songoda.skyblock.levelling.amount.AmountMaterialPair; import com.songoda.skyblock.levelling.calculator.Calculator; import com.songoda.skyblock.levelling.calculator.CalculatorRegistry; import com.songoda.skyblock.levelling.calculator.impl.EpicSpawnerCalculator; import com.songoda.skyblock.levelling.calculator.impl.UltimateStackerCalculator; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.utils.version.CompatibleSpawners; +import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; @@ -26,14 +25,9 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.blockscanner.BlockInfo; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.levelling.amount.AmountMaterialPair; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.stackable.StackableManager; - -import com.songoda.skyblock.utils.version.NMSUtil; +import java.io.File; +import java.util.*; +import java.util.Map.Entry; public final class IslandLevelManager { @@ -242,7 +236,9 @@ public final class IslandLevelManager { if (material == null || material == CompatibleMaterial.AIR) return; if (material == CompatibleMaterial.SPAWNER) { - if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || Bukkit.getPluginManager().isPluginEnabled("WildStacker")) + if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || + Bukkit.getPluginManager().isPluginEnabled("UltimateStacker") || + Bukkit.getPluginManager().isPluginEnabled("WildStacker")) return; CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType()); diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java index 333c86e7..26e2504f 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -5,10 +5,10 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.api.event.island.IslandLevelChangeEvent; import com.songoda.skyblock.blockscanner.BlockInfo; import com.songoda.skyblock.blockscanner.BlockScanner; +import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandWorld; -import com.songoda.skyblock.blockscanner.ChunkLoader; import com.songoda.skyblock.levelling.amount.AmountMaterialPair; import com.songoda.skyblock.levelling.amount.BlockAmount; import com.songoda.skyblock.message.MessageManager; @@ -51,10 +51,10 @@ public final class IslandScan extends BukkitRunnable { } public IslandScan start() { - final SkyBlock skyblock = SkyBlock.getInstance(); + final SkyBlock plugin = SkyBlock.getInstance(); - final FileConfiguration config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); - final FileConfiguration islandData = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), this.island.getOwnerUUID().toString() + ".yml")).getFileConfiguration(); + final FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); + final FileConfiguration islandData = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), this.island.getOwnerUUID().toString() + ".yml")).getFileConfiguration(); final boolean hasNether = config.getBoolean("Island.World.Nether.Enable") && islandData.getBoolean("Unlocked.Nether", false); final boolean hasEnd = config.getBoolean("Island.World.End.Enable") && islandData.getBoolean("Unlocked.End", false); @@ -62,25 +62,25 @@ public final class IslandScan extends BukkitRunnable { final Map> snapshots = new HashMap<>(3); - if (skyblock.isPaperAsync()) { - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - initScan(skyblock, hasNether, hasEnd, snapshots); + if (plugin.isPaperAsync()) { + Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { + initScan(plugin, hasNether, hasEnd, snapshots); }); } else { - initScan(skyblock, hasNether, hasEnd, snapshots); + initScan(plugin, hasNether, hasEnd, snapshots); } return this; } - private void initScan(SkyBlock skyblock, boolean hasNether, boolean hasEnd, Map> snapshots) { - populate(snapshots, IslandWorld.Normal, skyblock.isPaperAsync(), () -> { + private void initScan(SkyBlock plugin, boolean hasNether, boolean hasEnd, Map> snapshots) { + populate(snapshots, IslandWorld.Normal, plugin.isPaperAsync(), () -> { if (hasNether) { - populate(snapshots, IslandWorld.Nether, skyblock.isPaperAsync(), () -> { + populate(snapshots, IslandWorld.Nether, plugin.isPaperAsync(), () -> { if (hasEnd) { - populate(snapshots, IslandWorld.End, skyblock.isPaperAsync(), () -> { + populate(snapshots, IslandWorld.End, plugin.isPaperAsync(), () -> { BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); @@ -195,7 +195,7 @@ public final class IslandScan extends BukkitRunnable { private void populate(Map> snapshots, IslandWorld world, boolean paper, PopulateTask task) { - final SkyBlock skyblock = SkyBlock.getInstance(); + final SkyBlock plugin = SkyBlock.getInstance(); ChunkLoader.startChunkLoading(island, IslandWorld.Normal, paper, (asyncPositions, syncPositions) -> { if(paper){ @@ -203,9 +203,9 @@ public final class IslandScan extends BukkitRunnable { for(CompletableFuture chunk : asyncPositions){ positions.add(chunk.join().getChunkSnapshot()); } - snapshots.put(skyblock.getWorldManager().getWorld(world), positions); + snapshots.put(plugin.getWorldManager().getWorld(world), positions); } else { - snapshots.put(skyblock.getWorldManager().getWorld(world), syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); + snapshots.put(plugin.getWorldManager().getWorld(world), syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); } task.onComplete(); }, null); diff --git a/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java b/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java index 19a2b1bc..62886046 100644 --- a/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java @@ -1,12 +1,12 @@ package com.songoda.skyblock.levelling.calculator; +import com.songoda.core.compatibility.CompatibleMaterial; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.songoda.core.compatibility.CompatibleMaterial; - public final class CalculatorRegistry { private CalculatorRegistry() { diff --git a/src/main/java/com/songoda/skyblock/levelling/calculator/impl/EpicSpawnerCalculator.java b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/EpicSpawnerCalculator.java index 18447f71..d2066eb7 100644 --- a/src/main/java/com/songoda/skyblock/levelling/calculator/impl/EpicSpawnerCalculator.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/EpicSpawnerCalculator.java @@ -1,10 +1,9 @@ package com.songoda.skyblock.levelling.calculator.impl; -import org.bukkit.block.CreatureSpawner; - import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.spawners.spawner.Spawner; import com.songoda.skyblock.levelling.calculator.SpawnerCalculator; +import org.bukkit.block.CreatureSpawner; public class EpicSpawnerCalculator implements SpawnerCalculator { diff --git a/src/main/java/com/songoda/skyblock/levelling/calculator/impl/UltimateStackerCalculator.java b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/UltimateStackerCalculator.java index 1e18b189..93720905 100644 --- a/src/main/java/com/songoda/skyblock/levelling/calculator/impl/UltimateStackerCalculator.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/impl/UltimateStackerCalculator.java @@ -1,10 +1,9 @@ package com.songoda.skyblock.levelling.calculator.impl; -import org.bukkit.block.CreatureSpawner; - import com.songoda.skyblock.levelling.calculator.SpawnerCalculator; import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.spawner.SpawnerStack; +import org.bukkit.block.CreatureSpawner; public class UltimateStackerCalculator implements SpawnerCalculator { diff --git a/src/main/java/com/songoda/skyblock/limit/EnumLimitation.java b/src/main/java/com/songoda/skyblock/limit/EnumLimitation.java index 7a0b6781..0a3ed918 100644 --- a/src/main/java/com/songoda/skyblock/limit/EnumLimitation.java +++ b/src/main/java/com/songoda/skyblock/limit/EnumLimitation.java @@ -1,12 +1,12 @@ package com.songoda.skyblock.limit; +import org.bukkit.configuration.ConfigurationSection; + import java.util.EnumMap; import java.util.Locale; import java.util.Map; import java.util.Set; -import org.bukkit.configuration.ConfigurationSection; - public abstract class EnumLimitation> implements Limitation { private long defaultLimit; diff --git a/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java b/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java index 555478ea..bea798ec 100644 --- a/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java +++ b/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java @@ -1,14 +1,13 @@ package com.songoda.skyblock.limit; -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.configuration.Configuration; - import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.limit.impl.BlockLimitation; import com.songoda.skyblock.limit.impl.EntityLimitaton; +import org.bukkit.configuration.Configuration; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; public final class LimitationInstanceHandler { 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 d772b8c7..6ec563a6 100644 --- a/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java +++ b/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java @@ -6,7 +6,6 @@ import com.songoda.skyblock.island.Island; 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; diff --git a/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitaton.java b/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitaton.java index 984e8b2e..42e05ecb 100644 --- a/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitaton.java +++ b/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitaton.java @@ -1,15 +1,14 @@ package com.songoda.skyblock.limit.impl; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; - import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.limit.EnumLimitation; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; public final class EntityLimitaton extends EnumLimitation { diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 55e28ada..9ac94cb5 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -25,8 +25,8 @@ 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.*; import org.bukkit.entity.Entity; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -39,10 +39,10 @@ import java.util.*; public class Block implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Block(SkyBlock skyblock) { - this.skyblock = skyblock; + public Block(SkyBlock plugin) { + this.plugin = plugin; } @SuppressWarnings("deprecation") @@ -51,9 +51,9 @@ public class Block implements Listener { Player player = event.getPlayer(); org.bukkit.block.Block block = event.getBlock(); - IslandManager islandManager = skyblock.getIslandManager(); - StackableManager stackableManager = skyblock.getStackableManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + StackableManager stackableManager = plugin.getStackableManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!worldManager.isIslandWorld(block.getWorld())) return; @@ -67,7 +67,7 @@ public class Block implements Listener { } // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island) || event.isCancelled()) { + if (!plugin.getPermissionManager().processPermission(event, player, island) || event.isCancelled()) { return; } @@ -95,15 +95,15 @@ public class Block implements Listener { droppedAmount = 1; } - if(skyblock.getCoreProtectAPI() != null) { - skyblock.getCoreProtectAPI().logRemoval(player.getName(), block.getLocation(), material.getMaterial(), null); + if(plugin.getCoreProtectAPI() != null) { + plugin.getCoreProtectAPI().logRemoval(player.getName(), block.getLocation(), material.getMaterial(), null); } if (stackable.getSize() <= 1) { stackableManager.removeStack(stackable); } - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { @@ -126,7 +126,7 @@ public class Block implements Listener { } } - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); IslandWorld world = worldManager.getIslandWorld(block.getWorld()); @@ -135,8 +135,8 @@ public class Block implements Listener { || LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) { if (configLoad.getBoolean("Island.Spawn.Protection")) { event.setCancelled(true); - skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message")); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); } } @@ -184,9 +184,9 @@ public class Block implements Listener { Player player = event.getPlayer(); org.bukkit.block.Block block = event.getBlock(); - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - IslandLevelManager islandLevelManager = skyblock.getLevellingManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandLevelManager islandLevelManager = plugin.getLevellingManager(); if (!worldManager.isIslandWorld(block.getWorld())) return; Location blockLoc = block.getLocation(); @@ -194,7 +194,7 @@ public class Block implements Listener { Island island = islandManager.getIslandAtLocation(blockLoc); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; if (island == null) { @@ -203,13 +203,13 @@ public class Block implements Listener { } if (islandLevelManager.isScanning(island)) { - skyblock.getMessageManager().sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message")); + plugin.getMessageManager().sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message")); event.setCancelled(true); return; } - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); IslandWorld world = worldManager.getIslandWorld(block.getWorld()); @@ -217,7 +217,7 @@ public class Block implements Listener { 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, false)){ - skyblock.getMessageManager().sendMessage(player, Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message"))); event.setCancelled(true); } @@ -229,7 +229,7 @@ public class Block implements Listener { 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")) + plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message"))); event.setCancelled(true); } @@ -260,24 +260,24 @@ public class Block implements Listener { } 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); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message")); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); return; } } - BlockLimitation limits = skyblock.getLimitationHandler().getInstance(BlockLimitation.class); + BlockLimitation limits = plugin.getLimitationHandler().getInstance(BlockLimitation.class); long limit = limits.getBlockLimit(player, block); if (limits.isBlockLimitExceeded(block, limit)) { CompatibleMaterial material = CompatibleMaterial.getMaterial(block.getType()); - skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message") + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.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); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); return; @@ -293,17 +293,17 @@ public class Block implements Listener { @EventHandler public void onBlockFromTo(BlockFromToEvent event) { - if (!skyblock.getWorldManager().isIslandWorld(event.getBlock().getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(event.getBlock().getWorld())) return; - GeneratorManager generatorManager = skyblock.getGeneratorManager(); - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - IslandLevelManager islandLevelManager = skyblock.getLevellingManager(); + GeneratorManager generatorManager = plugin.getGeneratorManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandLevelManager islandLevelManager = plugin.getLevellingManager(); Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld()); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (island == null) return; @@ -402,14 +402,14 @@ public class Block implements Listener { @EventHandler public void onBlockPistonExtend(BlockPistonExtendEvent event) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!worldManager.isIslandWorld(event.getBlock().getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); if (island == null) return; - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (performStackCheck(event.getBlock(), event.getBlocks(), event.getDirection())) { @@ -429,7 +429,7 @@ public class Block implements Listener { return; } - if (skyblock.getStackableManager() != null && skyblock.getStackableManager().isStacked(block.getLocation())) { + if (plugin.getStackableManager() != null && plugin.getStackableManager().isStacked(block.getLocation())) { event.setCancelled(true); return; } @@ -448,7 +448,7 @@ public class Block implements Listener { } } - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Extend")) { + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Extend")) { if (block.getType() == CompatibleMaterial.PISTON.getMaterial() || block.getType() == CompatibleMaterial.STICKY_PISTON.getMaterial()) { event.setCancelled(true); return; @@ -500,14 +500,14 @@ public class Block implements Listener { @EventHandler public void onBlockPistonRetract(BlockPistonRetractEvent event) { - WorldManager worldManager = skyblock.getWorldManager(); - if (!skyblock.getWorldManager().isIslandWorld(event.getBlock().getWorld())) return; + WorldManager worldManager = plugin.getWorldManager(); + if (!plugin.getWorldManager().isIslandWorld(event.getBlock().getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); if (island == null) return; - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (performStackCheck(event.getBlock(), event.getBlocks(), event.getDirection())) { @@ -527,7 +527,7 @@ public class Block implements Listener { return; } - if (skyblock.getStackableManager() != null && skyblock.getStackableManager().isStacked(block.getLocation())) { + if (plugin.getStackableManager() != null && plugin.getStackableManager().isStacked(block.getLocation())) { event.setCancelled(true); return; } @@ -537,7 +537,7 @@ public class Block implements Listener { return; } - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Retract")) { + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Retract")) { if (block.getType() == CompatibleMaterial.PISTON.getMaterial() || block.getType() == CompatibleMaterial.STICKY_PISTON.getMaterial()) { event.setCancelled(true); return; @@ -549,10 +549,10 @@ public class Block implements Listener { @EventHandler public void onBlockForm(BlockFormEvent event) { org.bukkit.block.Block block = event.getBlock(); - WorldManager worldManager = skyblock.getWorldManager(); - IslandLevelManager islandLevelManager = skyblock.getLevellingManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandLevelManager islandLevelManager = plugin.getLevellingManager(); - FileConfiguration config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); + FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); if (!worldManager.isIslandWorld(block.getWorld())) return; @@ -563,7 +563,7 @@ public class Block implements Listener { return; } - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(block.getLocation()); if (island == null) return; @@ -571,7 +571,7 @@ public class Block implements Listener { // Check spawn block protection IslandWorld world = worldManager.getIslandWorld(block.getWorld()); if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { event.setCancelled(true); return; } @@ -587,7 +587,7 @@ public class Block implements Listener { if (type != Material.COBBLESTONE && type != Material.STONE) return; - GeneratorManager generatorManager = skyblock.getGeneratorManager(); + GeneratorManager generatorManager = plugin.getGeneratorManager(); if (generatorManager == null) return; List generators = Lists.newArrayList(generatorManager.getGenerators()); @@ -626,15 +626,15 @@ public class Block implements Listener { double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation()); // Find highest generator available for (Generator generator : generators) { - if(onlyOwner && skyblock.getVaultPermission() != null) { + if(onlyOwner && plugin.getVaultPermission() != null) { OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); event.setCancelled(true); World finalWorld = event.getBlock().getWorld(); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - if(skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || - skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || - skyblock.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { - Bukkit.getScheduler().runTask(skyblock, () -> { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { + Bukkit.getScheduler().runTask(plugin, () -> { if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ BlockState genState = generatorManager.generateBlock(generator, block); block.setType(genState.getType()); @@ -648,7 +648,7 @@ public class Block implements Listener { } }); } else { - Bukkit.getScheduler().runTask(skyblock, () -> { + Bukkit.getScheduler().runTask(plugin, () -> { block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); }); } @@ -687,11 +687,11 @@ public class Block implements Listener { @EventHandler public void onBlockBurn(BlockBurnEvent event) { org.bukkit.block.Block block = event.getBlock(); - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!worldManager.isIslandWorld(block.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); if (!permissionManager.hasPermission( islandManager.getIslandAtLocation(block.getLocation()),"FireSpread", IslandRole.Owner)) event.setCancelled(true); @@ -699,11 +699,11 @@ public class Block implements Listener { @EventHandler public void onPortalCreate(PortalCreateEvent event) { - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return; - WorldManager worldManager = skyblock.getWorldManager(); - IslandManager islandManager = skyblock.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); // PortalCreateEvent.getBlocks() changed from ArrayList to // ArrayList in 1.14.1 if (NMSUtil.getVersionNumber() > 13) { @@ -751,21 +751,21 @@ public class Block implements Listener { if (player == null) return; - if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { - IslandManager islandManager = skyblock.getIslandManager(); + if (plugin.getWorldManager().isIslandWorld(player.getWorld())) { + IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, island); + plugin.getPermissionManager().processPermission(event, player, island); } } @EventHandler public void onDispenserDispenseBlock(BlockDispenseEvent event) { - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return; - WorldManager worldManager = skyblock.getWorldManager(); - IslandManager islandManager = skyblock.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); @SuppressWarnings("deprecation") BlockFace dispenserDirection = ((org.bukkit.material.Dispenser) event.getBlock().getState().getData()).getFacing(); org.bukkit.block.Block placeLocation = event.getBlock().getRelative(dispenserDirection); diff --git a/src/main/java/com/songoda/skyblock/listeners/Bucket.java b/src/main/java/com/songoda/skyblock/listeners/Bucket.java index 1c1af994..40045fe0 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Bucket.java +++ b/src/main/java/com/songoda/skyblock/listeners/Bucket.java @@ -6,7 +6,6 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; - import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; import org.bukkit.entity.Player; @@ -19,10 +18,10 @@ import java.io.File; public class Bucket implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Bucket(SkyBlock skyblock) { - this.skyblock = skyblock; + public Bucket(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler @@ -30,16 +29,16 @@ public class Bucket implements Listener { Player player = event.getPlayer(); org.bukkit.block.Block block = event.getBlockClicked(); - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); CompatibleMaterial clickedBlock = CompatibleMaterial.getBlockMaterial(event.getBlockClicked().getType()); if (clickedBlock == CompatibleMaterial.WATER || clickedBlock == CompatibleMaterial.LAVA) { - if (skyblock.getWorldManager().isIslandWorld(block.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(block.getWorld())) { Island island = islandManager.getIslandAtLocation(block.getLocation()); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; } } @@ -50,17 +49,17 @@ public class Bucket implements Listener { Player player = event.getPlayer(); org.bukkit.block.Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - WorldManager worldManager = skyblock.getWorldManager(); - IslandManager islandManager = skyblock.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); - if (skyblock.getWorldManager().isIslandWorld(block.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(block.getWorld())) { Island island = islandManager.getIslandAtLocation(block.getLocation()); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; } - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return; Island island = islandManager.getIslandAtLocation(block.getLocation()); @@ -72,10 +71,10 @@ public class Bucket implements Listener { IslandWorld world = worldManager.getIslandWorld(block.getWorld()); if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) { event.setCancelled(true); - skyblock.getMessageManager().sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getMessageManager().sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.SpawnProtection.Place.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index 510bd76c..46891371 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -26,28 +26,28 @@ import java.util.UUID; public class Chat implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Chat(SkyBlock skyblock) { - this.skyblock = skyblock; + public Chat(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); - PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); Island island = null; if (playerData.getOwner() != null) { - island = skyblock.getIslandManager().getIsland(player); + island = plugin.getIslandManager().getIsland(player); } String messageFormat = event.getFormat(); @@ -66,7 +66,7 @@ public class Chat implements Listener { if (playerData.isChat()) { event.setCancelled(true); - Config language = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration languageLoad = language.getFileConfiguration(); String islandRole = ""; @@ -105,7 +105,7 @@ public class Chat implements Listener { } } - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName()) .replace("%message", islandChatEvent.getMessage())); } @@ -116,15 +116,15 @@ public class Chat implements Listener { @EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true) public void onIslandChat(PlayerIslandChatEvent event) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); Island island = event.getIsland().getIsland(); Player player = event.getPlayer(); - Config language = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration languageLoad = language.getFileConfiguration(); String islandRole = null; @@ -164,7 +164,7 @@ public class Chat implements Listener { } } - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { messageManager.sendMessage(Bukkit.getConsoleSender(), event.getFormat().replace("%role", islandRole).replace("%player", player.getName()) .replace("%message", event.getMessage())); } diff --git a/src/main/java/com/songoda/skyblock/listeners/Death.java b/src/main/java/com/songoda/skyblock/listeners/Death.java index 178c0b4b..05c1f34f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Death.java +++ b/src/main/java/com/songoda/skyblock/listeners/Death.java @@ -14,24 +14,24 @@ import java.io.File; public class Death implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Death(SkyBlock skyblock) { - this.skyblock = skyblock; + public Death(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onPlayerDeath(PlayerDeathEvent event) { Player player = event.getEntity(); - if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + if (plugin.getWorldManager().isIslandWorld(player.getWorld())) { + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); boolean keepInventory = false; if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) { - if (skyblock.getPermissionManager().hasPermission(player.getLocation(),"KeepItemsOnDeath", + if (plugin.getPermissionManager().hasPermission(player.getLocation(),"KeepItemsOnDeath", IslandRole.Owner)) { keepInventory = true; } @@ -45,7 +45,7 @@ public class Death implements Listener { } if (configLoad.getBoolean("Island.Death.AutoRespawn")) { - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> { + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { player.spigot().respawn(); player.setFallDistance(0.0F); player.setFireTicks(0); diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 2f570d2d..194ae9d3 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -17,8 +17,8 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.*; import org.bukkit.entity.Projectile; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -42,28 +42,28 @@ import java.util.*; public class Entity implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; private Set preventFireTicks = new HashSet<>(); - public Entity(SkyBlock skyblock) { - this.skyblock = skyblock; + public Entity(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onFireWorkBoom(EntityDamageByEntityEvent event) { if (event.getDamager().getType() == EntityType.FIREWORK - && skyblock.getWorldManager().isIslandWorld(event.getEntity().getWorld())) + && plugin.getWorldManager().isIslandWorld(event.getEntity().getWorld())) event.setCancelled(true); } @EventHandler public void onEntityDamage(EntityDamageEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); if(event.getEntity() instanceof Blaze){ - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if(configLoad.getBoolean("Island.Nether.BlazeImmuneToWaterInNether", false) && @@ -75,9 +75,9 @@ public class Entity implements Listener { } else if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); - if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(player.getWorld())) { // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); + plugin.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); } // Fix a bug in minecraft where arrows with flame still apply fire ticks even if @@ -91,16 +91,16 @@ public class Entity implements Listener { @EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); if (event.getDamager() instanceof Player) { Player player = (Player) event.getDamager(); org.bukkit.entity.Entity entity = event.getEntity(); - if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(entity.getWorld())) { // Check permissions. - skyblock.getPermissionManager() + plugin.getPermissionManager() .processPermission(event, player, islandManager.getIslandAtLocation(entity.getLocation())); } @@ -111,19 +111,19 @@ public class Entity implements Listener { Player player = (Player) event.getEntity(); // Check permissions. - skyblock.getPermissionManager() + plugin.getPermissionManager() .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true); } else if((event.getDamager() instanceof org.bukkit.entity.Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player)){ Player player = (Player) ((Projectile) event.getDamager()).getShooter(); - skyblock.getPermissionManager() + plugin.getPermissionManager() .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); } else { // Make it work with all the entities, not just TNT org.bukkit.entity.Entity entity = event.getEntity(); // Check permissions. - skyblock.getPermissionManager() + plugin.getPermissionManager() .processPermission(event, islandManager.getIslandAtLocation(entity.getLocation())); } @@ -147,12 +147,12 @@ public class Entity implements Listener { public void onPlayerShearEntity(PlayerShearEntityEvent event) { Player player = event.getPlayer(); - if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { - IslandManager islandManager = skyblock.getIslandManager(); + if (plugin.getWorldManager().isIslandWorld(player.getWorld())) { + IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(event.getEntity().getLocation()); // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, island); + plugin.getPermissionManager().processPermission(event, player, island); } } @@ -164,14 +164,14 @@ public class Entity implements Listener { @EventHandler public void onEntityTarget(EntityTargetEvent event) { org.bukkit.entity.Entity entity = event.getEntity(); - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!worldManager.isIslandWorld(entity.getWorld())) return; org.bukkit.entity.Entity target = event.getTarget(); // Somehow the target can be null, thanks Spigot. if (target == null) return; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Island entityIsland = islandManager.getIslandAtLocation(entity.getLocation()); Island targetIsland = islandManager.getIslandAtLocation(target.getLocation()); // Event not related to Skyblock islands. @@ -191,11 +191,11 @@ public class Entity implements Listener { @EventHandler public void onStackableInteract(PlayerArmorStandManipulateEvent event) { Player player = event.getPlayer(); - if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; + IslandManager islandManager = plugin.getIslandManager(); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, + if (!plugin.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(event.getRightClicked().getLocation()))) return; @@ -216,11 +216,11 @@ public class Entity implements Listener { @EventHandler public void onHangingPlace(HangingPlaceEvent event) { Player player = event.getPlayer(); - if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; + IslandManager islandManager = plugin.getIslandManager(); // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, + plugin.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(event.getEntity().getLocation())); } @@ -228,11 +228,11 @@ public class Entity implements Listener { public void onHangingBreak(HangingBreakEvent event) { Hanging hanging = event.getEntity(); - if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + if (!plugin.getWorldManager().isIslandWorld(hanging.getWorld())) return; + IslandManager islandManager = plugin.getIslandManager(); // Check permissions. - skyblock.getPermissionManager().processPermission(event, null, + plugin.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(hanging.getLocation())); } @@ -240,15 +240,15 @@ public class Entity implements Listener { public void onHangingBreak(HangingBreakByEntityEvent event) { Hanging hanging = event.getEntity(); - if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + if (!plugin.getWorldManager().isIslandWorld(hanging.getWorld())) return; + IslandManager islandManager = plugin.getIslandManager(); Player p = null; if(event.getRemover() instanceof Player){ p = (Player) event.getRemover(); } // Check permissions. - skyblock.getPermissionManager().processPermission(event, p, + plugin.getPermissionManager().processPermission(event, p, islandManager.getIslandAtLocation(hanging.getLocation())); } @@ -259,11 +259,11 @@ public class Entity implements Listener { LivingEntity entity = event.getEntity(); - if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + if (!plugin.getWorldManager().isIslandWorld(entity.getWorld())) return; + IslandManager islandManager = plugin.getIslandManager(); // Check permissions. - skyblock.getPermissionManager().processPermission(event, (Player) event.getOwner(), + plugin.getPermissionManager().processPermission(event, (Player) event.getOwner(), islandManager.getIslandAtLocation(entity.getLocation())); } @@ -276,16 +276,16 @@ public class Entity implements Listener { return; } - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation()); - if (island == null || !skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return; + if (island == null || !plugin.getWorldManager().isIslandWorld(entity.getWorld())) return; if (event.isCancelled()) return; - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld()); @@ -297,7 +297,7 @@ public class Entity implements Listener { if ((LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0, 1, 0)) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0, 1, 0))) - && skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + && plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Spawn.Protection")) { event.setCancelled(true); return; @@ -329,17 +329,17 @@ public class Entity implements Listener { if (entity instanceof FallingBlock) return; // Check entities interacting with spawn - if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { + if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { event.setCancelled(true); return; } // Check permissions. - skyblock.getPermissionManager().processPermission(event, null, island); + plugin.getPermissionManager().processPermission(event, null, island); - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Block.Level.Enable")) return; @@ -368,24 +368,24 @@ public class Entity implements Listener { public void onEntityExplode(EntityExplodeEvent event) { org.bukkit.entity.Entity entity = event.getEntity(); - WorldManager worldManager = skyblock.getWorldManager(); - IslandManager islandManager = skyblock.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); - if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(entity.getWorld())) { // Check permissions. Island island = islandManager.getIslandAtLocation(entity.getLocation()); - skyblock.getPermissionManager().processPermission(event, null, island); + plugin.getPermissionManager().processPermission(event, null, island); if (!event.isCancelled()) { - StackableManager stackableManager = skyblock.getStackableManager(); + StackableManager stackableManager = plugin.getStackableManager(); boolean removed; Iterator it = event.blockList().iterator(); while (it.hasNext()){ removed = false; org.bukkit.block.Block block = it.next(); - if (SkyBlock.getInstance().getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Spawn.Protection")) { IslandWorld world = worldManager.getIslandWorld(event.getEntity().getWorld()); if (LocationUtil.isLocationLocation(block.getLocation(), @@ -405,7 +405,7 @@ public class Entity implements Listener { int removedAmount = (int) (Math.random() * Math.min(64, stackable.getSize()-1)); stackable.take(removedAmount); - Bukkit.getScheduler().runTask(skyblock, () -> { + Bukkit.getScheduler().runTask(plugin, () -> { block.getWorld().dropItemNaturally(blockLocation.clone().add(.5, 1, .5), new ItemStack(material.getMaterial(), (int) (Math.random() * removedAmount), data)); }); @@ -414,15 +414,15 @@ public class Entity implements Listener { stackableManager.removeStack(stackable); } - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { removeBlockFromLevel(island, block); } - if(skyblock.getCoreProtectAPI() != null) { - skyblock.getCoreProtectAPI().logRemoval("#" + entity.getType().toString().toLowerCase(), block.getLocation(), material.getMaterial(), null); + if(plugin.getCoreProtectAPI() != null) { + plugin.getCoreProtectAPI().logRemoval("#" + entity.getType().toString().toLowerCase(), block.getLocation(), material.getMaterial(), null); } it.remove(); @@ -431,7 +431,7 @@ public class Entity implements Listener { } } } - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Block.Level.Enable")) { if(!removed){ removeBlockFromLevel(island, block); @@ -491,13 +491,13 @@ public class Entity implements Listener { if (livingEntity.hasMetadata("SkyBlock")) return; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); - if (skyblock.getWorldManager().isIslandWorld(livingEntity.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(livingEntity.getWorld())) { Island island = islandManager.getIslandAtLocation(livingEntity.getLocation()); if (island != null) { - List upgrades = skyblock.getUpgradeManager().getUpgrades(Upgrade.Type.Drops); + List upgrades = plugin.getUpgradeManager().getUpgrades(Upgrade.Type.Drops); if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled() && island.isUpgrade(Upgrade.Type.Drops)) { Set dontMultiply = new HashSet<>(); @@ -534,11 +534,11 @@ public class Entity implements Listener { return; Player player = (Player) event.getTarget(); - if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; + IslandManager islandManager = plugin.getIslandManager(); // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, + plugin.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(event.getEntity().getLocation())); } @@ -565,23 +565,23 @@ public class Entity implements Listener { Location entityLocation = entity.getLocation(); - Island island = skyblock.getIslandManager().getIslandAtLocation(entityLocation); + Island island = plugin.getIslandManager().getIslandAtLocation(entityLocation); if (island == null) return; - EntityLimitaton limits = skyblock.getLimitationHandler().getInstance(EntityLimitaton.class); + EntityLimitaton limits = plugin.getLimitationHandler().getInstance(EntityLimitaton.class); EntityType type = entity.getType(); if (limits.isBeingTracked(type)) { - FileManager fileManager = skyblock.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager fileManager = plugin.getFileManager(); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); 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); + long count = limits.getEntityCount(island, plugin.getWorldManager().getIslandWorld(entityLocation.getWorld()), type); if (limits.hasTooMuch(count + 1, type)) { entity.remove(); event.setCancelled(true); @@ -594,13 +594,13 @@ public class Entity implements Listener { if (!CHECKED_REASONS.contains(spawnReason)) return; - if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return; - if (skyblock.getPermissionManager().hasPermission(null, island, "NaturalMobSpawning")) return; + if (!plugin.getWorldManager().isIslandWorld(entity.getWorld())) return; + if (plugin.getPermissionManager().hasPermission(null, island, "NaturalMobSpawning")) return; if (spawnReason != SpawnReason.JOCKEY && spawnReason != SpawnReason.MOUNT) { entity.remove(); // Older versions ignore the event being cancelled, so this fixes that issue. return; } - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> { + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { if (NMSUtil.getVersionNumber() > 10) { // getPassengers() was added in 1.11 for (org.bukkit.entity.Entity passenger : entity.getPassengers()) passenger.remove(); @@ -615,16 +615,16 @@ public class Entity implements Listener { @EventHandler public void onDamageVehicle(VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player)) { - IslandManager islandManager = skyblock.getIslandManager(); - skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation())); + IslandManager islandManager = plugin.getIslandManager(); + plugin.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation())); } } @EventHandler public void onDestroyVehicle(VehicleDestroyEvent event) { if (!(event.getAttacker() instanceof Player)) { - IslandManager islandManager = skyblock.getIslandManager(); - skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation())); + IslandManager islandManager = plugin.getIslandManager(); + plugin.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation())); } } diff --git a/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java b/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java index d6d437ce..e6d55d84 100644 --- a/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java +++ b/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java @@ -8,7 +8,6 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandManager; - import com.songoda.skyblock.utils.version.CompatibleSpawners; import com.songoda.skyblock.world.WorldManager; import org.bukkit.Bukkit; @@ -23,17 +22,17 @@ import java.io.File; public class EpicSpawners implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public EpicSpawners(SkyBlock skyblock) { - this.skyblock = skyblock; + public EpicSpawners(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSpawnerPlace(SpawnerPlaceEvent event) { Bukkit.getScheduler().scheduleSyncDelayedTask(SkyBlock.getInstance(), () -> { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); Location location = event.getSpawner().getLocation(); if (!worldManager.isIslandWorld(location.getWorld())) return; @@ -43,7 +42,7 @@ public class EpicSpawners implements Listener { int amount = event.getSpawner().getFirstStack().getStackSize(); EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { @@ -67,8 +66,8 @@ public class EpicSpawners implements Listener { if (event.getChange() != SpawnerChangeEvent.ChangeType.STACK_SIZE) return; - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); Location location = event.getSpawner().getLocation(); if (!worldManager.isIslandWorld(location.getWorld())) return; @@ -78,7 +77,7 @@ public class EpicSpawners implements Listener { int amount = event.getStackSize() - event.getOldStackSize(); EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { @@ -102,8 +101,8 @@ public class EpicSpawners implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSpawnerBreak(SpawnerBreakEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); Location location = event.getSpawner().getLocation(); if (!worldManager.isIslandWorld(location.getWorld())) return; @@ -113,7 +112,7 @@ public class EpicSpawners implements Listener { int amount = event.getSpawner().getFirstStack().getStackSize(); EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { diff --git a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java index 0fbecfa3..8f157433 100644 --- a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java +++ b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java @@ -19,10 +19,10 @@ import java.util.List; public class FallBreak implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public FallBreak(SkyBlock skyblock) { - this.skyblock = skyblock; + public FallBreak(SkyBlock plugin) { + this.plugin = plugin; } /* @@ -36,12 +36,12 @@ public class FallBreak implements Listener { public void onItemSpawn(ItemSpawnEvent event) { // Basic world and island checks - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!worldManager.isIslandWorld(event.getEntity().getWorld())) return; - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (!configLoad.getBoolean("Island.Block.Level.Enable")) return; diff --git a/src/main/java/com/songoda/skyblock/listeners/Food.java b/src/main/java/com/songoda/skyblock/listeners/Food.java index b4821104..61683de8 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Food.java +++ b/src/main/java/com/songoda/skyblock/listeners/Food.java @@ -8,19 +8,19 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; public class Food implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Food(SkyBlock skyblock) { - this.skyblock = skyblock; + public Food(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onFoodLevelChange(FoodLevelChangeEvent event) { Player player = (Player) event.getEntity(); - if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(player.getWorld())) { // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, player.getLocation()); + plugin.getPermissionManager().processPermission(event, player, player.getLocation()); } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Grow.java b/src/main/java/com/songoda/skyblock/listeners/Grow.java index 5e684435..75b78988 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Grow.java +++ b/src/main/java/com/songoda/skyblock/listeners/Grow.java @@ -1,12 +1,16 @@ package com.songoda.skyblock.listeners; -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.util.Iterator; -import java.util.List; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.permission.PermissionManager; +import com.songoda.skyblock.upgrade.Upgrade; +import com.songoda.skyblock.utils.version.NMSUtil; +import com.songoda.skyblock.utils.world.LocationUtil; +import com.songoda.skyblock.world.WorldManager; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.event.EventHandler; @@ -17,23 +21,18 @@ import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.material.Crops; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.island.IslandWorld; -import com.songoda.skyblock.upgrade.Upgrade; -import com.songoda.skyblock.utils.version.NMSUtil; -import com.songoda.skyblock.utils.world.LocationUtil; -import com.songoda.skyblock.world.WorldManager; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.util.Iterator; +import java.util.List; @SuppressWarnings("deprecation") public class Grow implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Grow(SkyBlock skyblock) { - this.skyblock = skyblock; + public Grow(SkyBlock plugin) { + this.plugin = plugin; } /** @@ -44,10 +43,10 @@ public class Grow implements Listener { */ @EventHandler(ignoreCancelled = true) public void onStructureGrow(StructureGrowEvent event) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!worldManager.isIslandWorld(event.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Island origin = islandManager.getIslandAtLocation(event.getLocation()); for (Iterator it = event.getBlocks().iterator(); it.hasNext();) { BlockState state = it.next(); @@ -77,23 +76,23 @@ public class Grow implements Listener { @EventHandler(ignoreCancelled = true) public void onCropUpgrade(BlockGrowEvent event) { org.bukkit.block.Block block = event.getBlock(); - WorldManager worldManager = skyblock.getWorldManager(); - if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return; + WorldManager worldManager = plugin.getWorldManager(); + if (!plugin.getWorldManager().isIslandWorld(block.getWorld())) return; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(block.getLocation()); if (island == null) return; // Check spawn block protection IslandWorld world = worldManager.getIslandWorld(block.getWorld()); if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { event.setCancelled(true); return; } } - List upgrades = skyblock.getUpgradeManager().getUpgrades(Upgrade.Type.Crop); + List upgrades = plugin.getUpgradeManager().getUpgrades(Upgrade.Type.Crop); if (upgrades == null || upgrades.size() == 0 || !upgrades.get(0).isEnabled() || !island.isUpgrade(Upgrade.Type.Crop)) return; if (NMSUtil.getVersionNumber() > 12) { @@ -128,12 +127,12 @@ public class Grow implements Listener { */ @EventHandler(ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent event) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); BlockState state = event.getNewState(); if (!worldManager.isIslandWorld(state.getWorld())) return; if (CompatibleMaterial.getBlockMaterial(state.getType()) != CompatibleMaterial.PUMPKIN && CompatibleMaterial.getBlockMaterial(state.getType()) != CompatibleMaterial.MELON) return; - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Island origin = islandManager.getIslandAtLocation(event.getBlock().getLocation()); Island growingTo = islandManager.getIslandAtLocation(state.getLocation()); // This block is ok to continue as it's not related to Skyblock islands. @@ -156,13 +155,13 @@ public class Grow implements Listener { */ @EventHandler(ignoreCancelled = true) public void onStructureCreate(StructureGrowEvent event) { - if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return; + if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return; List blocks = event.getBlocks(); if (blocks.isEmpty()) return; - WorldManager worldManager = skyblock.getWorldManager(); - IslandManager islandManager = skyblock.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); Island island = islandManager.getIslandAtLocation(event.getLocation()); if (island == null) return; @@ -181,18 +180,18 @@ public class Grow implements Listener { if (event.getSource().getType() != Material.FIRE) return; org.bukkit.block.Block block = event.getBlock(); - if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(block.getWorld())) return; - PermissionManager permissionManager = skyblock.getPermissionManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); if (!permissionManager.hasPermission(block.getLocation(), "FireSpread", IslandRole.Owner)) event.setCancelled(true); } @EventHandler public void onLeavesDecay(LeavesDecayEvent event) { org.bukkit.block.Block block = event.getBlock(); - if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(block.getWorld())) return; - PermissionManager permissionManager = skyblock.getPermissionManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); if (!permissionManager.hasPermission(block.getLocation(), "LeafDecay", IslandRole.Owner)) event.setCancelled(true); } diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index d5976759..5b11faca 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -21,7 +21,10 @@ 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.*; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -41,10 +44,10 @@ import java.util.HashMap; public class Interact implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Interact(SkyBlock skyblock) { - this.skyblock = skyblock; + public Interact(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @@ -53,9 +56,9 @@ public class Interact implements Listener { 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(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); if (!worldManager.isIslandWorld(block.getWorld())) return; if (event.getAction() == Action.RIGHT_CLICK_BLOCK && @@ -66,7 +69,7 @@ public class Interact implements Listener { Island island = islandManager.getIslandAtLocation(blockLoc); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; if (island == null) { @@ -75,13 +78,13 @@ public class Interact implements Listener { } 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")); + plugin.getMessageManager().sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.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")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); IslandWorld world = worldManager.getIslandWorld(block.getWorld()); @@ -94,24 +97,24 @@ public class Interact implements Listener { } 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); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message")); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); return; } } - BlockLimitation limits = skyblock.getLimitationHandler().getInstance(BlockLimitation.class); + BlockLimitation limits = plugin.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") + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.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); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); return; @@ -134,13 +137,13 @@ public class Interact implements Listener { Player player = event.getPlayer(); org.bukkit.block.Block block = event.getClickedBlock(); - if (block != null && !skyblock.getWorldManager().isIslandWorld(block.getWorld())) { + if (block != null && !plugin.getWorldManager().isIslandWorld(block.getWorld())) { return; } - IslandManager islandManager = skyblock.getIslandManager(); - StackableManager stackableManager = skyblock.getStackableManager(); - IslandLevelManager levellingManager = skyblock.getLevellingManager(); + IslandManager islandManager = plugin.getIslandManager(); + StackableManager stackableManager = plugin.getStackableManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); Island island = islandManager.getIslandAtLocation(player.getLocation()); if (island == null) { @@ -151,7 +154,7 @@ public class Interact implements Listener { CompatibleMaterial material = block == null ? null : CompatibleMaterial.getMaterial(block.getType()); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { @@ -172,26 +175,26 @@ public class Interact implements Listener { } if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType - && !player.isSneaking() && skyblock.getPermissionManager().hasPermission(player, island, "Place") - && (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission") + && !player.isSneaking() && plugin.getPermissionManager().hasPermission(player, island, "Place") + && (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission") || player.hasPermission("fabledskyblock.stackable"))) { 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")); + plugin.getMessageManager().sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message")); event.setCancelled(true); return; } - BlockLimitation limits = skyblock.getLimitationHandler().getInstance(BlockLimitation.class); + BlockLimitation limits = plugin.getLimitationHandler().getInstance(BlockLimitation.class); long limit = limits.getBlockLimit(player, block); if (limits.isBlockLimitExceeded(block, limit)) { - skyblock.getMessageManager().sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message") + plugin.getMessageManager().sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.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); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); event.setCancelled(true); return; @@ -201,7 +204,7 @@ public class Interact implements Listener { Stackable stackable = stackableManager.getStack(location, blockType); int itemAmount = event.getItem().getAmount(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Stackable.Limit.Enable")) { @@ -240,8 +243,8 @@ public class Interact implements Listener { event.setCancelled(true); } - if(skyblock.getCoreProtectAPI() != null && material != null) { - skyblock.getCoreProtectAPI().logPlacement(player.getName(), location, material.getMaterial(), null); + if(plugin.getCoreProtectAPI() != null && material != null) { + plugin.getCoreProtectAPI().logPlacement(player.getName(), location, material.getMaterial(), null); } if (player.getGameMode() != GameMode.CREATIVE) @@ -268,7 +271,7 @@ public class Interact implements Listener { } // Check if the clicked block is outside of the border. - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); org.bukkit.block.Block clickedBlock = event.getClickedBlock(); IslandWorld world = worldManager.getIslandWorld(clickedBlock.getWorld()); if (!islandManager.isLocationAtIsland(island, clickedBlock.getLocation(), world)) { @@ -281,10 +284,10 @@ public class Interact implements Listener { && event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")) { - skyblock.getSoundManager().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 1.0F); + plugin.getSoundManager().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 1.0F); block.setType(CompatibleMaterial.AIR.getBlockMaterial()); ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event)); @@ -296,7 +299,7 @@ public class Interact implements Listener { return; } } else if (material == CompatibleMaterial.END_PORTAL_FRAME) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")) { if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) { @@ -333,7 +336,7 @@ public class Interact implements Listener { } player.updateInventory(); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { @@ -351,7 +354,7 @@ public class Interact implements Listener { } } - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 10.0F, 10.0F); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 10.0F, 10.0F); event.setCancelled(true); return; @@ -378,8 +381,8 @@ public class Interact implements Listener { public void onPlayerInteractStructure(PlayerInteractEvent event) { Player player = event.getPlayer(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); if (event.getItem() != null) { try { @@ -393,10 +396,10 @@ public class Interact implements Listener { || player.hasPermission("fabledskyblock.*")) { event.setCancelled(true); - skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1, event.getClickedBlock().getLocation()); + plugin.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1, event.getClickedBlock().getLocation()); messageManager.sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message") + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message") .replace("%position", "1")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); } @@ -411,10 +414,10 @@ public class Interact implements Listener { || player.hasPermission("fabledskyblock.*")) { event.setCancelled(true); - skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2, event.getClickedBlock().getLocation()); + plugin.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2, event.getClickedBlock().getLocation()); messageManager.sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message") + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message") .replace("%position", "2")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); } @@ -431,14 +434,14 @@ public class Interact implements Listener { Player player = event.getPlayer(); org.bukkit.entity.Entity entity = event.getRightClicked(); - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); - if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(entity.getWorld())) return; Island island = islandManager.getIslandAtLocation(entity.getLocation()); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; } @@ -448,16 +451,16 @@ public class Interact implements Listener { return; } - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Player player = (Player) event.getAttacker(); - if (!skyblock.getWorldManager().isIslandWorld(event.getVehicle().getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(event.getVehicle().getWorld())) return; Island island = islandManager.getIslandAtLocation(event.getVehicle().getLocation()); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; } @@ -467,22 +470,22 @@ public class Interact implements Listener { return; } - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Player player = (Player) event.getAttacker(); - if (!skyblock.getWorldManager().isIslandWorld(event.getVehicle().getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(event.getVehicle().getWorld())) return; Island island = islandManager.getIslandAtLocation(event.getVehicle().getLocation()); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; } @EventHandler(ignoreCancelled = true) public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) { - if (skyblock.getStackableManager() != null && skyblock.getStackableManager().isStacked(event.getRightClicked().getLocation().getBlock().getLocation())) { + if (plugin.getStackableManager() != null && plugin.getStackableManager().isStacked(event.getRightClicked().getLocation().getBlock().getLocation())) { event.setCancelled(true); } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Inventory.java b/src/main/java/com/songoda/skyblock/listeners/Inventory.java index f97eb152..efdfc244 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Inventory.java +++ b/src/main/java/com/songoda/skyblock/listeners/Inventory.java @@ -8,20 +8,20 @@ import org.bukkit.event.inventory.InventoryOpenEvent; public class Inventory implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Inventory(SkyBlock skyblock) { - this.skyblock = skyblock; + public Inventory(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onInventoryOpen(InventoryOpenEvent event) { Player player = (Player) event.getPlayer(); - if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(player.getWorld())) { // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, - skyblock.getIslandManager().getIsland(player)); + plugin.getPermissionManager().processPermission(event, player, + plugin.getIslandManager().getIsland(player)); } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Item.java b/src/main/java/com/songoda/skyblock/listeners/Item.java index 00917de8..084e2c67 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Item.java +++ b/src/main/java/com/songoda/skyblock/listeners/Item.java @@ -2,7 +2,6 @@ package com.songoda.skyblock.listeners; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -12,33 +11,33 @@ import org.bukkit.event.player.PlayerPickupItemEvent; @SuppressWarnings("deprecation") public class Item implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Item(SkyBlock skyblock) { - this.skyblock = skyblock; + public Item(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Player player = event.getPlayer(); - if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, + plugin.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(event.getItemDrop().getLocation())); } @EventHandler public void onPlayerPickupItem(PlayerPickupItemEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); Player player = event.getPlayer(); - if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return; + if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, + plugin.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(event.getItem().getLocation())); } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index b0ed53f8..02d49c83 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -7,17 +7,17 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.cooldown.CooldownManager; import com.songoda.skyblock.cooldown.CooldownType; -import com.songoda.skyblock.island.*; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandEnvironment; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.scoreboard.Scoreboard; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.usercache.UserCacheManager; import com.songoda.skyblock.utils.world.LocationUtil; import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -29,23 +29,23 @@ import java.lang.reflect.Method; public class Join implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Join(SkyBlock skyblock) { - this.skyblock = skyblock; + public Join(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Player player = event.getPlayer(); - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - UserCacheManager userCacheManager = skyblock.getUserCacheManager(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - IslandManager islandManager = skyblock.getIslandManager(); - FileManager fileManager = skyblock.getFileManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + UserCacheManager userCacheManager = plugin.getUserCacheManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); userCacheManager.addUser(player.getUniqueId(), player.getName()); userCacheManager.saveAsync(); @@ -55,13 +55,13 @@ public class Join implements Listener { Island island = islandManager.getIsland(player); boolean teleportedToIsland = false; - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Join.Spawn")) { LocationUtil.teleportPlayerToSpawn(player); } else if (configLoad.getBoolean("Island.Join.Island") && island != null) { - Bukkit.getScheduler().runTask(skyblock, () -> { + Bukkit.getScheduler().runTask(plugin, () -> { PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); player.setFallDistance(0.0F); }); diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index d568f5d8..5c996c9d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -2,7 +2,6 @@ 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.*; @@ -15,9 +14,11 @@ import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.world.WorldManager; import io.papermc.lib.PaperLib; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; 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; @@ -29,17 +30,15 @@ import org.bukkit.potion.PotionEffect; import java.io.File; import java.util.Objects; -import java.util.concurrent.CompletableFuture; public class Move implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Move(SkyBlock skyblock) { - this.skyblock = skyblock; + public Move(SkyBlock plugin) { + this.plugin = plugin; } - - @SuppressWarnings("deprecation") + @EventHandler public void onPlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); @@ -47,25 +46,25 @@ public class Move implements Listener { Location from = event.getFrom(); Location to = event.getTo(); - if (to == null || (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ())) { + if (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ()) { return; } - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); if (!worldManager.isIslandWorld(player.getWorld())) return; IslandWorld world = worldManager.getIslandWorld(player.getWorld()); if (world == IslandWorld.Nether || world == IslandWorld.End) { - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + world.name() + ".Enable")) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + world.name() + ".Enable")) { + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); messageManager.sendMessage(player, configLoad.getString("Island.World.Message").replace(configLoad.getString("Island.World.Word." + world.name()), world.name())); @@ -97,7 +96,7 @@ public class Move implements Listener { if (island != null) { if (islandManager.isLocationAtIsland(island, to)) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); boolean keepItemsOnDeath; @@ -152,7 +151,7 @@ public class Move implements Listener { } else { 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")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -160,7 +159,7 @@ public class Move implements Listener { player.setFallDistance(0.0F); } - messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration() + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration() .getString("Island.WorldBorder.Outside.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); } @@ -189,7 +188,7 @@ public class Move implements Listener { LocationUtil.teleportPlayerToSpawn(player); messageManager.sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); } } @@ -205,7 +204,7 @@ public class Move implements Listener { } } else { loc = island.getLocation(world, IslandEnvironment.Main); - LocationUtil.removeWaterFromLoc(skyblock, loc); + LocationUtil.removeWaterFromLoc(plugin, loc); } } else { if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { @@ -223,7 +222,7 @@ public class Move implements Listener { } else { LocationUtil.teleportPlayerToSpawn(player); player.sendMessage(ChatColor.translateAlternateColorCodes('&', - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message"))); } } @@ -235,8 +234,8 @@ public class Move implements Listener { 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")); + FileManager fileManager = plugin.getFileManager(); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){ @@ -248,19 +247,19 @@ public class Move implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTeleport(PlayerTeleportEvent e) { // TODO We should wait for the player island to be loaded in 1.8.8 - Fabrimat final Player player = e.getPlayer(); - final WorldManager worldManager = skyblock.getWorldManager(); + final WorldManager worldManager = plugin.getWorldManager(); if(e.getTo() != null && e.getTo().getWorld() != null){ if(!e.isAsynchronous()){ e.getTo().getWorld().loadChunk(e.getTo().getChunk()); // Is that needed? } if(worldManager.isIslandWorld(e.getTo().getWorld()) && (!e.getTo().getWorld().equals(e.getFrom().getWorld()) || e.getTo().distance(e.getFrom()) > 1.0d)){ // We should not care of self block tp - if(skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null){ + if(plugin.getIslandManager().getIslandAtLocation(e.getTo()) == null){ e.setCancelled(true); - skyblock.getMessageManager().sendMessage(player, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getMessageManager().sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Piston.java b/src/main/java/com/songoda/skyblock/listeners/Piston.java index c8694f05..9a994997 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Piston.java +++ b/src/main/java/com/songoda/skyblock/listeners/Piston.java @@ -17,10 +17,10 @@ import java.io.File; public class Piston implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Piston(SkyBlock skyblock) { - this.skyblock = skyblock; + public Piston(SkyBlock plugin) { + this.plugin = plugin; } // Prevent point farming dragon eggs. @@ -29,8 +29,8 @@ public class Piston implements Listener { Block block = event.getBlock().getRelative(event.getDirection()); - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); if (!worldManager.isIslandWorld(block.getWorld())) return; @@ -38,7 +38,7 @@ public class Piston implements Listener { if (island == null || CompatibleMaterial.DRAGON_EGG != CompatibleMaterial.getMaterial(block)) return; - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (!configLoad.getBoolean("Island.Block.Level.Enable")) return; diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 4657f983..03e3208a 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -2,7 +2,6 @@ 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; @@ -26,21 +25,19 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.player.PlayerMoveEvent; -import java.awt.print.Paper; import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import java.util.concurrent.CompletableFuture; public class Portal implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; private Map tickCounter = new HashMap<>(); - public Portal(SkyBlock skyblock) { - this.skyblock = skyblock; + public Portal(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler @@ -49,7 +46,7 @@ public class Portal implements Listener { org.bukkit.block.Block from = event.getFrom().getBlock(); org.bukkit.block.Block to = event.getTo().getBlock(); - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) return; @@ -58,7 +55,7 @@ public class Portal implements Listener { if (island == null) return; // Check permissions. - skyblock.getPermissionManager().processPermission(event, player, + plugin.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(event.getTo())); } @@ -69,11 +66,11 @@ public class Portal implements Listener { Player player = (Player) event.getEntity(); org.bukkit.block.Block block = event.getLocation().getBlock(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); if (!worldManager.isIslandWorld(player.getWorld())) return; @@ -81,7 +78,7 @@ public class Portal implements Listener { if (island == null) return; - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); IslandEnvironment spawnEnvironment; @@ -111,7 +108,7 @@ public class Portal implements Listener { tick.setLast(System.currentTimeMillis()); } if (tick.getTick() >= 100) { - messageManager.sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Portal.Stuck.Message")); + messageManager.sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Portal.Stuck.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); LocationUtil.teleportPlayerToSpawn(player); return; @@ -122,7 +119,7 @@ public class Portal implements Listener { PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat // Check permissions. - boolean perms = !skyblock.getPermissionManager().processPermission(playerEnterPortalEvent, + boolean perms = !plugin.getPermissionManager().processPermission(playerEnterPortalEvent, player, island); IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld()); @@ -146,7 +143,7 @@ public class Portal implements Listener { default: IslandWorld toWorldF = toWorld; - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> PaperLib.teleportAsync(player, island.getLocation(toWorldF, spawnEnvironment)), 1L); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> PaperLib.teleportAsync(player, island.getLocation(toWorldF, spawnEnvironment)), 1L); soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); player.setFallDistance(0.0F); tick.setTick(1); @@ -164,7 +161,7 @@ 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().runTaskLater(skyblock, () -> { + Bukkit.getScheduler().runTaskLater(plugin, () -> { Location loc = island.getLocation(toWorldF, spawnEnvironment); Location tempSafeLoc = LocationUtil.getSafeLocation(loc); Location safeLoc = null; diff --git a/src/main/java/com/songoda/skyblock/listeners/Projectile.java b/src/main/java/com/songoda/skyblock/listeners/Projectile.java index e3bbdeae..8790fadd 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Projectile.java +++ b/src/main/java/com/songoda/skyblock/listeners/Projectile.java @@ -1,9 +1,6 @@ package com.songoda.skyblock.listeners; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,10 +10,10 @@ import org.bukkit.projectiles.ProjectileSource; public class Projectile implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Projectile(SkyBlock skyblock) { - this.skyblock = skyblock; + public Projectile(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler @@ -28,11 +25,11 @@ public class Projectile implements Listener { Player player = (Player) shooter; - if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) + if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; // Check permissions. - skyblock.getPermissionManager().processPermission(new ProjectileLaunchByPlayerEvent(event.getEntity()), player, player.getLocation()); + plugin.getPermissionManager().processPermission(new ProjectileLaunchByPlayerEvent(event.getEntity()), player, player.getLocation()); } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Quit.java b/src/main/java/com/songoda/skyblock/listeners/Quit.java index 6e4b735f..bde39add 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Quit.java +++ b/src/main/java/com/songoda/skyblock/listeners/Quit.java @@ -2,7 +2,6 @@ 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; @@ -30,23 +29,23 @@ import java.util.UUID; public class Quit implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Quit(SkyBlock skyblock) { - this.skyblock = skyblock; + public Quit(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Player player = event.getPlayer(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - MessageManager messageManager = skyblock.getMessageManager(); - InviteManager inviteManager = skyblock.getInviteManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PlayerManager challengePlayerManager = skyblock.getFabledChallenge().getPlayerManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + InviteManager inviteManager = plugin.getInviteManager(); + IslandManager islandManager = plugin.getIslandManager(); + PlayerManager challengePlayerManager = plugin.getFabledChallenge().getPlayerManager(); PlayerData playerData = playerDataManager.getPlayerData(player); @@ -76,8 +75,8 @@ public class Quit implements Listener { if (targetPlayerData.isChat()) { targetPlayerData.setChat(false); messageManager.sendMessage(targetPlayer, - skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration().getString("Island.Chat.Untoggled.Message")); } } @@ -85,7 +84,7 @@ public class Quit implements Listener { } final Island is = island; - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> islandManager.unloadIsland(is, player)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> islandManager.unloadIsland(is, player)); } cooldownManager.setCooldownPlayer(CooldownType.Biome, player); @@ -101,7 +100,7 @@ public class Quit implements Listener { playerDataManager.unloadPlayerData(player); boolean offline = true; - if(island != null && skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if(island != null && plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", false)){ if(island.getRole(IslandRole.Member) != null){ for(UUID uuid : island.getRole(IslandRole.Member)){ @@ -131,7 +130,7 @@ public class Quit implements Listener { } for (Island islandList : islandManager.getCoopIslands(player)) { - if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Coop.Unload") || islandList.getCoopType(player.getUniqueId()) == IslandCoop.TEMP) { islandList.removeCoopPlayer(player.getUniqueId()); } @@ -144,7 +143,7 @@ public class Quit implements Listener { && !island.hasRole(IslandRole.Operator, player.getUniqueId()) && !island.hasRole(IslandRole.Owner, player.getUniqueId())) { final Island is = island; - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> islandManager.unloadIsland(is, null)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> islandManager.unloadIsland(is, null)); } } @@ -154,11 +153,11 @@ public class Quit implements Listener { if (targetPlayer != null) { messageManager.sendMessage(targetPlayer, - skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")) + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration() .getString("Command.Island.Invite.Invited.Sender.Disconnected.Message") .replace("%player", player.getName())); - skyblock.getSoundManager().playSound(targetPlayer, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + plugin.getSoundManager().playSound(targetPlayer, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); } inviteManager.removeInvite(player.getUniqueId()); diff --git a/src/main/java/com/songoda/skyblock/listeners/Respawn.java b/src/main/java/com/songoda/skyblock/listeners/Respawn.java index a7a255b5..8ca34dee 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Respawn.java +++ b/src/main/java/com/songoda/skyblock/listeners/Respawn.java @@ -19,22 +19,22 @@ import java.util.logging.Level; public class Respawn implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Respawn(SkyBlock skyblock) { - this.skyblock = skyblock; + public Respawn(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); if (worldManager.isIslandWorld(player.getWorld())) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Death.Respawn.Island")) { @@ -63,7 +63,7 @@ public class Respawn implements Listener { } } - config = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")); + config = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")); if (config.getFileConfiguration().getString("Location.Spawn") == null) { Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set."); diff --git a/src/main/java/com/songoda/skyblock/listeners/Spawner.java b/src/main/java/com/songoda/skyblock/listeners/Spawner.java index 0c934716..3c05ed9b 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Spawner.java +++ b/src/main/java/com/songoda/skyblock/listeners/Spawner.java @@ -16,24 +16,24 @@ import java.util.List; public class Spawner implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Spawner(SkyBlock skyblock) { - this.skyblock = skyblock; + public Spawner(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onSpawnSpawn(SpawnerSpawnEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); CreatureSpawner spawner = event.getSpawner(); org.bukkit.Location location = spawner.getBlock().getLocation(); - if (skyblock.getWorldManager().isIslandWorld(location.getWorld())) { + if (plugin.getWorldManager().isIslandWorld(location.getWorld())) { Island island = islandManager.getIslandAtLocation(location); if (island != null) { - List upgrades = skyblock.getUpgradeManager().getUpgrades(Upgrade.Type.Spawner); + List upgrades = plugin.getUpgradeManager().getUpgrades(Upgrade.Type.Spawner); if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled() && island.isUpgrade(Upgrade.Type.Spawner)) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index 16073290..251c104c 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -35,29 +35,29 @@ import java.util.UUID; public class Teleport implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public Teleport(SkyBlock skyblock) { - this.skyblock = skyblock; + public Teleport(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onPlayerTeleport(PlayerTeleportEvent event) { Player player = event.getPlayer(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if(worldManager.isIslandWorld(event.getFrom().getWorld()) || (event.getTo() != null && worldManager.isIslandWorld(event.getTo().getWorld()))) { - Bukkit.getScheduler().runTaskLater(skyblock, () -> islandManager.updateFlight(player), 1L); + Bukkit.getScheduler().runTaskLater(plugin, () -> islandManager.updateFlight(player), 1L); } islandManager.loadPlayer(player); @@ -87,7 +87,7 @@ public class Teleport implements Listener { com.songoda.skyblock.island.Island island = islandManager.getIslandAtLocation(event.getTo()); // Check permissions. - if (!skyblock.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)) return; } @@ -108,7 +108,7 @@ public class Teleport implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; - } else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && island.getBan().isBanned(player.getUniqueId())) { + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && island.getBan().isBanned(player.getUniqueId())) { event.setCancelled(true); messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Teleport.Message")); @@ -136,7 +136,7 @@ public class Teleport implements Listener { if (worldManager.getIslandWorld(event.getTo().getWorld()) == IslandWorld.Normal) { if (!island.isWeatherSynchronized()) { - player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); + player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); player.setPlayerWeather(island.getWeather()); } } @@ -187,7 +187,7 @@ public class Teleport implements Listener { @EventHandler public void onEntityTeleport(EntityPortalEvent e) { - WorldManager worldManager = skyblock.getWorldManager(); + WorldManager worldManager = plugin.getWorldManager(); // Do not handle player if (e.getEntityType() == EntityType.PLAYER) diff --git a/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java b/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java index 254b688d..bca32ed9 100644 --- a/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java +++ b/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java @@ -5,7 +5,6 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandManager; - import com.songoda.skyblock.utils.version.CompatibleSpawners; import com.songoda.skyblock.world.WorldManager; import com.songoda.ultimatestacker.events.SpawnerBreakEvent; @@ -20,24 +19,24 @@ import java.io.File; public class UltimateStacker implements Listener { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public UltimateStacker(SkyBlock skyblock) { - this.skyblock = skyblock; + public UltimateStacker(SkyBlock plugin) { + this.plugin = plugin; } @EventHandler public void onSpawnerPlace(SpawnerPlaceEvent event) { Bukkit.getScheduler().scheduleSyncDelayedTask(SkyBlock.getInstance(), () -> { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); Location location = event.getBlock().getLocation(); if (!worldManager.isIslandWorld(location.getWorld())) return; Island island = islandManager.getIslandAtLocation(location); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { @@ -58,15 +57,15 @@ public class UltimateStacker implements Listener { @EventHandler public void onSpawnerBreak(SpawnerBreakEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); Location location = event.getBlock().getLocation(); if (!worldManager.isIslandWorld(location.getWorld())) return; Island island = islandManager.getIslandAtLocation(location); - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Island.Block.Level.Enable")) { diff --git a/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java b/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java index e5e1fe97..82c86615 100644 --- a/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java +++ b/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java @@ -1,21 +1,18 @@ package com.songoda.skyblock.localization; -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import com.songoda.core.compatibility.CompatibleMaterial; -import org.bukkit.Material; -import org.bukkit.configuration.Configuration; - import com.google.common.collect.Sets; +import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.localization.type.Localization; import com.songoda.skyblock.localization.type.impl.BlankLocalization; import com.songoda.skyblock.localization.type.impl.EnumLocalization; import com.songoda.skyblock.localization.type.impl.MaterialsLocalization; -import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.Configuration; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; public final class LocalizationManager { diff --git a/src/main/java/com/songoda/skyblock/localization/type/Localization.java b/src/main/java/com/songoda/skyblock/localization/type/Localization.java index 5a74b9a9..bce7d5be 100644 --- a/src/main/java/com/songoda/skyblock/localization/type/Localization.java +++ b/src/main/java/com/songoda/skyblock/localization/type/Localization.java @@ -1,10 +1,10 @@ package com.songoda.skyblock.localization.type; +import org.bukkit.configuration.ConfigurationSection; + import java.util.Map; import java.util.Objects; -import org.bukkit.configuration.ConfigurationSection; - public abstract class Localization { private final Class type; diff --git a/src/main/java/com/songoda/skyblock/localization/type/impl/BlankLocalization.java b/src/main/java/com/songoda/skyblock/localization/type/impl/BlankLocalization.java index 790bcaf8..62a5aa74 100644 --- a/src/main/java/com/songoda/skyblock/localization/type/impl/BlankLocalization.java +++ b/src/main/java/com/songoda/skyblock/localization/type/impl/BlankLocalization.java @@ -1,12 +1,11 @@ package com.songoda.skyblock.localization.type.impl; +import com.songoda.skyblock.localization.type.Localization; +import org.bukkit.configuration.ConfigurationSection; + import java.util.HashMap; import java.util.Map; -import org.bukkit.configuration.ConfigurationSection; - -import com.songoda.skyblock.localization.type.Localization; - public final class BlankLocalization extends Localization { public BlankLocalization(String keysPath, Class type) { diff --git a/src/main/java/com/songoda/skyblock/localization/type/impl/EnumLocalization.java b/src/main/java/com/songoda/skyblock/localization/type/impl/EnumLocalization.java index 577fd5ab..752dd0eb 100644 --- a/src/main/java/com/songoda/skyblock/localization/type/impl/EnumLocalization.java +++ b/src/main/java/com/songoda/skyblock/localization/type/impl/EnumLocalization.java @@ -1,12 +1,11 @@ package com.songoda.skyblock.localization.type.impl; +import com.songoda.skyblock.localization.type.Localization; +import org.bukkit.configuration.ConfigurationSection; + import java.util.EnumMap; import java.util.Map; -import org.bukkit.configuration.ConfigurationSection; - -import com.songoda.skyblock.localization.type.Localization; - public class EnumLocalization> extends Localization { public EnumLocalization(String keysPath, Class type) { diff --git a/src/main/java/com/songoda/skyblock/localization/type/impl/MaterialsToMaterialLocalization.java b/src/main/java/com/songoda/skyblock/localization/type/impl/MaterialsToMaterialLocalization.java index 5bd0780c..28d0b031 100644 --- a/src/main/java/com/songoda/skyblock/localization/type/impl/MaterialsToMaterialLocalization.java +++ b/src/main/java/com/songoda/skyblock/localization/type/impl/MaterialsToMaterialLocalization.java @@ -1,7 +1,6 @@ package com.songoda.skyblock.localization.type.impl; import com.songoda.core.compatibility.CompatibleMaterial; -import org.bukkit.Material; diff --git a/src/main/java/com/songoda/skyblock/menus/Bans.java b/src/main/java/com/songoda/skyblock/menus/Bans.java index e82d1019..295b5e7c 100644 --- a/src/main/java/com/songoda/skyblock/menus/Bans.java +++ b/src/main/java/com/songoda/skyblock/menus/Bans.java @@ -17,7 +17,6 @@ import com.songoda.skyblock.utils.AbstractAnvilGUI; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -43,19 +42,19 @@ public class Bans { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); - Island island = skyblock.getIslandManager().getIsland(player); + Island island = plugin.getIslandManager().getIsland(player); - Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = languageConfig.getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -69,7 +68,7 @@ public class Bans { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; - } else if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + } else if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visitor.Banning")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Disabled.Message")); @@ -96,7 +95,7 @@ public class Bans { configLoad.getString("Menu.Bans.Item.Information.Displayname"))))) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { Bukkit.getServer().dispatchCommand(player, @@ -131,21 +130,21 @@ public class Bans { playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Bans.Item.Next.Displayname")))) { playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { if ((island1.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island1,"Unban", IslandRole.Operator)) + && plugin.getPermissionManager().hasPermission(island1,"Unban", IslandRole.Operator)) || island1.hasRole(IslandRole.Owner, player.getUniqueId())) { String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); Bukkit.getServer().dispatchCommand(player, "island unban " + playerName); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 3L); } else { messageManager.sendMessage(player, @@ -236,7 +235,7 @@ public class Bans { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } } diff --git a/src/main/java/com/songoda/skyblock/menus/Biome.java b/src/main/java/com/songoda/skyblock/menus/Biome.java index bfa1be90..2b137c2c 100644 --- a/src/main/java/com/songoda/skyblock/menus/Biome.java +++ b/src/main/java/com/songoda/skyblock/menus/Biome.java @@ -16,7 +16,6 @@ import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; - import com.songoda.skyblock.utils.version.SBiome; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -42,18 +41,18 @@ public class Biome { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - BiomeManager biomeManager = skyblock.getBiomeManager(); - SoundManager soundManager = skyblock.getSoundManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + BiomeManager biomeManager = plugin.getBiomeManager(); + SoundManager soundManager = plugin.getSoundManager(); if (playerDataManager.hasPlayerData(player)) { - FileConfiguration langConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); + FileConfiguration langConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { Island island = islandManager.getIsland(player); @@ -147,7 +146,7 @@ public class Biome { soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_SPLASH.getSound(), 1.0F, 1.0F); } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } }); @@ -172,7 +171,7 @@ public class Biome { null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17); - FileConfiguration settings = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); + FileConfiguration settings = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); boolean allowNetherBiome = settings.getBoolean("Island.Biome.AllowOtherWorldlyBiomes.Nether"); boolean allowEndBiome = settings.getBoolean("Island.Biome.AllowOtherWorldlyBiomes.End"); @@ -214,7 +213,7 @@ public class Biome { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', langConfig.getString("Menu.Biome.Title"))); nInv.setRows(4); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } } diff --git a/src/main/java/com/songoda/skyblock/menus/Border.java b/src/main/java/com/songoda/skyblock/menus/Border.java index f03bacef..e940bc5a 100644 --- a/src/main/java/com/songoda/skyblock/menus/Border.java +++ b/src/main/java/com/songoda/skyblock/menus/Border.java @@ -11,7 +11,6 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.item.nInventoryUtil; - import com.songoda.skyblock.utils.world.WorldBorder; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -36,14 +35,14 @@ public class Border { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -55,14 +54,14 @@ public class Border { return; } else if (!((island.hasRole(IslandRole.Operator, player.getUniqueId()) - && skyblock.getPermissionManager().hasPermission(island,"Border", IslandRole.Operator)) + && plugin.getPermissionManager().hasPermission(island,"Border", IslandRole.Operator)) || island.hasRole(IslandRole.Owner, player.getUniqueId()))) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Border.Permission.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); return; - } else if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + } else if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Border.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -88,7 +87,7 @@ public class Border { islandManager.updateBorder(island); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == CompatibleMaterial.LIGHT_BLUE_DYE.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', @@ -105,7 +104,7 @@ public class Border { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } else if ((is.getType() == CompatibleMaterial.LIME_DYE.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() @@ -123,7 +122,7 @@ public class Border { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } else if ((is.getType() == CompatibleMaterial.RED_DYE.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() @@ -141,7 +140,7 @@ public class Border { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } }); @@ -231,6 +230,6 @@ public class Border { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Border.Title"))); nInv.setType(InventoryType.HOPPER); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } diff --git a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java index db91e5f0..554d0285 100644 --- a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java +++ b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java @@ -1,9 +1,13 @@ package com.songoda.skyblock.menus; -import java.io.File; - 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.Island; +import com.songoda.skyblock.utils.item.MenuClickRegistry; +import com.songoda.skyblock.utils.item.MenuClickRegistry.RegistryKey; +import com.songoda.skyblock.utils.item.nInventoryUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -12,12 +16,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.utils.item.MenuClickRegistry; -import com.songoda.skyblock.utils.item.MenuClickRegistry.RegistryKey; -import com.songoda.skyblock.utils.item.nInventoryUtil; +import java.io.File; public final class ControlPanel { @@ -89,9 +88,9 @@ public final class ControlPanel { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -182,6 +181,6 @@ public final class ControlPanel { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title"))); nInv.setRows(2); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } diff --git a/src/main/java/com/songoda/skyblock/menus/Coop.java b/src/main/java/com/songoda/skyblock/menus/Coop.java index 732d2879..cd81115e 100644 --- a/src/main/java/com/songoda/skyblock/menus/Coop.java +++ b/src/main/java/com/songoda/skyblock/menus/Coop.java @@ -19,7 +19,6 @@ import com.songoda.skyblock.utils.AbstractAnvilGUI; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -45,17 +44,17 @@ public class Coop { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); String normal = configLoad.getString("Menu.Coop.Item.Word.Normal"); @@ -72,7 +71,7 @@ public class Coop { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; - } else if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + } else if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Coop.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Disabled.Message")); @@ -100,7 +99,7 @@ public class Coop { configLoad.getString("Menu.Coop.Item.Information.Displayname"))))) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -154,13 +153,13 @@ public class Coop { playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Coop.Item.Next.Displayname")))) { playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "CoopPlayers", IslandRole.Operator)) @@ -174,7 +173,7 @@ public class Coop { Bukkit.getServer().dispatchCommand(player, "island coop " + playerName); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 3L); } else { messageManager.sendMessage(player, @@ -270,7 +269,7 @@ public class Coop { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Coop.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, nInv::open); + Bukkit.getServer().getScheduler().runTask(plugin, nInv::open); } } } diff --git a/src/main/java/com/songoda/skyblock/menus/Creator.java b/src/main/java/com/songoda/skyblock/menus/Creator.java index 28a6c0ef..91dfb31c 100644 --- a/src/main/java/com/songoda/skyblock/menus/Creator.java +++ b/src/main/java/com/songoda/skyblock/menus/Creator.java @@ -37,20 +37,20 @@ public class Creator { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); List availableStructures = new ArrayList<>(); - for (Structure structureList : skyblock.getStructureManager().getStructures()) { + for (Structure structureList : plugin.getStructureManager().getStructures()) { if (structureList.getDisplayname() == null || structureList.getDisplayname().isEmpty() || structureList.getOverworldFile() == null || structureList.getOverworldFile().isEmpty() || structureList.getNetherFile() == null || structureList.getNetherFile().isEmpty()) { @@ -70,9 +70,9 @@ public class Creator { int inventoryRows = 0; if (availableStructures.size() == 0) { - skyblock.getMessageManager().sendMessage(player, + plugin.getMessageManager().sendMessage(player, configLoad.getString("Island.Creator.Selector.None.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; } else if (availableStructures.size() <= 9) { @@ -97,10 +97,10 @@ public class Creator { return; } - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { ItemStack is = event.getItem(); - for (Structure structureList : skyblock.getStructureManager().getStructures()) { + for (Structure structureList : plugin.getStructureManager().getStructures()) { if ((is.getType() == structureList.getMaterial().getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad @@ -115,7 +115,7 @@ public class Creator { configLoad.getString("Island.Creator.Selector.Permission.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; @@ -123,7 +123,7 @@ public class Creator { } if (!fileManager.isFileExist( - new File(new File(skyblock.getDataFolder().toString() + "/" + + new File(new File(plugin.getDataFolder().toString() + "/" + (structureList.getOverworldFile().endsWith(".structure") ? "structures" : "schematics")), structureList.getOverworldFile()))) { messageManager.sendMessage(player, @@ -135,7 +135,7 @@ public class Creator { return; } else if (!fileManager.isFileExist( - new File(new File(skyblock.getDataFolder().toString() + "/" + + new File(new File(plugin.getDataFolder().toString() + "/" + (structureList.getNetherFile().endsWith(".structure") ? "structures" : "schematics")), structureList.getNetherFile()))) { messageManager.sendMessage(player, @@ -147,7 +147,7 @@ public class Creator { return; } else if (!fileManager.isFileExist( - new File(new File(skyblock.getDataFolder().toString() + "/" + + new File(new File(plugin.getDataFolder().toString() + "/" + (structureList.getEndFile().endsWith(".structure") ? "structures" : "schematics")), structureList.getEndFile()))) { messageManager.sendMessage(player, @@ -158,7 +158,7 @@ public class Creator { event.setWillDestroy(false); return; - } else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable") && cooldownManager.hasPlayer(CooldownType.Creation, player)) { CooldownPlayer cooldownPlayer = cooldownManager @@ -239,6 +239,6 @@ public class Creator { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Title"))); nInv.setRows(inventoryRows); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } diff --git a/src/main/java/com/songoda/skyblock/menus/Information.java b/src/main/java/com/songoda/skyblock/menus/Information.java index bdb31da7..6bb30373 100644 --- a/src/main/java/com/songoda/skyblock/menus/Information.java +++ b/src/main/java/com/songoda/skyblock/menus/Information.java @@ -17,7 +17,6 @@ import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; - import com.songoda.skyblock.visit.Visit; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -46,13 +45,13 @@ public class Information { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); @@ -65,7 +64,7 @@ public class Information { islandManager.loadIsland(targetOfflinePlayer); } - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(viewer.getOwner())); @@ -132,7 +131,7 @@ public class Information { Viewer.Type.Members)); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == CompatibleMaterial.MAP.getMaterial()) && (is.hasItemMeta()) @@ -152,7 +151,7 @@ public class Information { Viewer.Type.Visitors)); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } @@ -170,7 +169,7 @@ public class Information { configLoad.getStringList("Menu.Information.Categories.Item.Visitors.Lore"), null, null, null), 3); - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); List itemLore = new ArrayList<>(); String safety = ""; @@ -264,7 +263,7 @@ public class Information { configLoad.getString("Menu.Information.Categories.Title"))); nInv.setType(InventoryType.HOPPER); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else if (viewer.getType() == Information.Viewer.Type.Members) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (playerDataManager.hasPlayerData(player)) { @@ -280,7 +279,7 @@ public class Information { Viewer.Type.Categories)); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == CompatibleMaterial.PAINTING.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals( @@ -307,7 +306,7 @@ public class Information { playerData1.setPage(MenuType.INFORMATION, playerData1.getPage(MenuType.INFORMATION) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad @@ -315,7 +314,7 @@ public class Information { playerData1.setPage(MenuType.INFORMATION, playerData1.getPage(MenuType.INFORMATION) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, @@ -397,7 +396,7 @@ public class Information { playerTexture = offlinePlayer.getTexture(); } else { playerName = targetPlayer.getName(); - playerData = skyblock.getPlayerDataManager().getPlayerData(targetPlayer); + playerData = plugin.getPlayerDataManager().getPlayerData(targetPlayer); playerTexture = playerData.getTexture(); } @@ -423,7 +422,7 @@ public class Information { configLoad.getString("Menu.Information.Members.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else if (viewer.getType() == Information.Viewer.Type.Visitors) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (playerDataManager.hasPlayerData(player)) { @@ -439,7 +438,7 @@ public class Information { Viewer.Type.Categories)); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == CompatibleMaterial.PAINTING.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals( @@ -466,7 +465,7 @@ public class Information { playerData12.setPage(MenuType.INFORMATION, playerData12.getPage(MenuType.INFORMATION) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad @@ -474,7 +473,7 @@ public class Information { playerData12.setPage(MenuType.INFORMATION, playerData12.getPage(MenuType.INFORMATION) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, @@ -542,7 +541,7 @@ public class Information { playerTexture = offlinePlayer.getTexture(); } else { playerName = targetPlayer.getName(); - playerData = skyblock.getPlayerDataManager().getPlayerData(targetPlayer); + playerData = plugin.getPlayerDataManager().getPlayerData(targetPlayer); playerTexture = playerData.getTexture(); } @@ -559,7 +558,7 @@ public class Information { configLoad.getString("Menu.Information.Visitors.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } islandManager.unloadIsland(island, null); diff --git a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java index 05f969a2..9ee9519a 100644 --- a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java +++ b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java @@ -12,7 +12,6 @@ import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; - import com.songoda.skyblock.visit.Visit; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -39,14 +38,14 @@ public class Leaderboard { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); Viewer viewer = (Viewer) playerDataManager.getPlayerData(player).getViewer(); @@ -92,7 +91,7 @@ public class Leaderboard { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } }); @@ -110,7 +109,7 @@ public class Leaderboard { null), 1); - if(fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")){ + if(fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")){ nInv.addItem( nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad .getString( @@ -140,7 +139,7 @@ public class Leaderboard { configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Title"))); nInv.setType(InventoryType.HOPPER); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else { nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (playerDataManager.hasPlayerData(player)) { @@ -153,14 +152,14 @@ public class Leaderboard { } else if (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname")))) { - if (skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visitor.Vote")) { playerDataManager.getPlayerData(player) .setViewer(new Viewer(Viewer.Type.Browse)); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F); } @@ -195,7 +194,7 @@ public class Leaderboard { } if (leaderboardPosition != -1) { - List leaderboardIslands = skyblock + List leaderboardIslands = plugin .getLeaderboardManager().getLeaderboard( com.songoda.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name())); @@ -204,7 +203,7 @@ public class Leaderboard { Visit visit = leaderboard.getVisit(); OfflinePlayer offlinePlayer = new OfflinePlayer(visit.getOwnerUUID()); - Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> Bukkit.dispatchCommand(player, "island teleport " + offlinePlayer.getName())); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.dispatchCommand(player, "island teleport " + offlinePlayer.getName())); } event.setWillClose(false); @@ -220,7 +219,7 @@ public class Leaderboard { } }); - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Visitor.Vote")) { nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname"), null, null, @@ -231,7 +230,7 @@ public class Leaderboard { null, null), 0, 8); } - List leaderboardIslands = skyblock + List leaderboardIslands = plugin .getLeaderboardManager().getLeaderboard( com.songoda.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name())); @@ -338,7 +337,7 @@ public class Leaderboard { viewer.getType().name()))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } } diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index b6cea6e6..2d268243 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -1,23 +1,7 @@ package com.songoda.skyblock.menus; -import java.io.File; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import com.songoda.core.compatibility.CompatibleSound; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -38,6 +22,21 @@ import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.version.NMSUtil; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; + +import java.io.File; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; public class Levelling { @@ -52,21 +51,21 @@ public class Levelling { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - IslandLevelManager levellingManager = skyblock.getLevellingManager(); - CooldownManager cooldownManager = skyblock.getCooldownManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (!playerDataManager.hasPlayerData(player)) return; - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (islandManager.getIsland(player) == null) { @@ -135,7 +134,7 @@ public class Levelling { return; } - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Processing.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F); @@ -143,18 +142,18 @@ public class Levelling { levellingManager.startScan(player, island); }); } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { - PlayerData playerData1 = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData1 = plugin.getPlayerDataManager().getPlayerData(player); if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) { playerData1.setPage(MenuType.LEVELLING, playerData1.getPage(MenuType.LEVELLING) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Next.Displayname")))) { playerData1.setPage(MenuType.LEVELLING, playerData1.getPage(MenuType.LEVELLING) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, 1.0F); @@ -176,8 +175,8 @@ public class Levelling { List testIslandMaterialKeysOrdered = testIslandMaterials.keySet().stream().sorted().collect(Collectors.toList()); LinkedHashMap islandMaterials = new LinkedHashMap<>(); - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml")); - Config settingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "levelling.yml")); + Config settingsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); // Filter out ItemStacks that can't be displayed in the inventory Inventory testInventory = Bukkit.createInventory(null, 9); @@ -269,7 +268,7 @@ public class Levelling { long pointsEarned = materialAmountCounted * pointsMultiplier; - String name = skyblock.getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(materials); + String name = plugin.getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(materials); if (materials == CompatibleMaterial.FARMLAND && NMSUtil.getVersionNumber() < 9) materials = CompatibleMaterial.DIRT; @@ -293,6 +292,6 @@ public class Levelling { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } \ No newline at end of file diff --git a/src/main/java/com/songoda/skyblock/menus/Members.java b/src/main/java/com/songoda/skyblock/menus/Members.java index 5e92ee3f..7d33171a 100644 --- a/src/main/java/com/songoda/skyblock/menus/Members.java +++ b/src/main/java/com/songoda/skyblock/menus/Members.java @@ -17,7 +17,6 @@ import com.songoda.skyblock.utils.StringUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -45,16 +44,16 @@ public class Members { } public void open(Player player, Members.Type type, Members.Sort sort) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -70,7 +69,7 @@ public class Members { Island island = islandManager.getIsland(player); if (island == null) { - skyblock.getMessageManager().sendMessage(player, + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Members.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -111,7 +110,7 @@ public class Members { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', @@ -133,14 +132,14 @@ public class Members { playerData.setPage(MenuType.MEMBERS, playerData.getPage(MenuType.MEMBERS) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Members.Item.Next.Displayname")))) { playerData.setPage(MenuType.MEMBERS, playerData.getPage(MenuType.MEMBERS) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else { String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); @@ -166,7 +165,7 @@ public class Members { "island demote " + playerName); } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 3L); @@ -174,7 +173,7 @@ public class Members { } else if (event.getClick() == ClickType.RIGHT) { Bukkit.getServer().dispatchCommand(player, "island kick " + playerName); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 3L); @@ -184,7 +183,7 @@ public class Members { && permissionManager.hasPermission(island, "Kick", IslandRole.Operator)) { Bukkit.getServer().dispatchCommand(player, "island kick " + playerName); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 3L); @@ -229,11 +228,11 @@ public class Members { if (targetPlayer == null) { sortedPlaytimes.put(YamlConfiguration .loadConfiguration( - new File(new File(skyblock.getDataFolder().toString() + "/player-data"), + new File(new File(plugin.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")) .getInt("Statistics.Island.Playtime"), displayedMemberList); } else { - sortedPlaytimes.put(skyblock.getPlayerDataManager().getPlayerData(targetPlayer).getPlaytime(), + sortedPlaytimes.put(plugin.getPlayerDataManager().getPlayerData(targetPlayer).getPlaytime(), displayedMemberList); } } @@ -255,14 +254,14 @@ public class Members { .put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss") .parse(YamlConfiguration .loadConfiguration(new File( - new File(skyblock.getDataFolder().toString() + new File(plugin.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")) .getString("Statistics.Island.Join")), displayedMemberList); } else { sortedDates.put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse( - skyblock.getPlayerDataManager().getPlayerData(targetPlayer).getMemberSince()), + plugin.getPlayerDataManager().getPlayerData(targetPlayer).getMemberSince()), displayedMemberList); } } catch (ParseException e) { @@ -290,7 +289,7 @@ public class Members { .put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss") .parse(YamlConfiguration .loadConfiguration(new File( - new File(skyblock.getDataFolder().toString() + new File(plugin.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")) .getString("Statistics.Island.LastOnline")), @@ -334,7 +333,7 @@ public class Members { new Placeholder("%island_members", "" + (islandMembers.size() + islandOperators.size() + 1)), new Placeholder("%island_capacity", - "" + fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + "" + fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Member.Capacity")), new Placeholder("%members", "" + islandMembers.size()), new Placeholder("%operators", "" + islandOperators.size())}, @@ -408,7 +407,7 @@ public class Members { } else { playerName = targetPlayer.getName(); - playerData = skyblock.getPlayerDataManager().getPlayerData(targetPlayer); + playerData = plugin.getPlayerDataManager().getPlayerData(targetPlayer); playerTexture = playerData.getTexture(); islandPlaytime = playerData.getPlaytime(); playTimeDurationTime = NumberUtil.getDuration(Integer.valueOf(islandPlaytime)); @@ -579,7 +578,7 @@ public class Members { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } diff --git a/src/main/java/com/songoda/skyblock/menus/Ownership.java b/src/main/java/com/songoda/skyblock/menus/Ownership.java index cd0817f0..788a27a0 100644 --- a/src/main/java/com/songoda/skyblock/menus/Ownership.java +++ b/src/main/java/com/songoda/skyblock/menus/Ownership.java @@ -16,7 +16,6 @@ import com.songoda.skyblock.utils.AbstractAnvilGUI; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -43,21 +42,21 @@ public class Ownership { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (playerDataManager.hasPlayerData(player)) { - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); Island island = islandManager.getIsland(player); if (island == null) { @@ -104,7 +103,7 @@ public class Ownership { configLoad.getString("Menu.Ownership.Item.Assign.Displayname"))))) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { if (playerDataManager.hasPlayerData(player)) { @@ -127,7 +126,7 @@ public class Ownership { return; } - Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().dispatchCommand(player, + Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(player, "island ownership " + event1.getName())); } } else { @@ -159,7 +158,7 @@ public class Ownership { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; @@ -167,7 +166,7 @@ public class Ownership { island.setPassword(null); soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_EXPLODE.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; @@ -181,7 +180,7 @@ public class Ownership { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event12 -> { if (event12.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { if (playerDataManager.hasPlayerData(player)) { @@ -210,7 +209,7 @@ public class Ownership { 1.0F); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, () -> open(player), 1L); + .runTaskLater(plugin, () -> open(player), 1L); } } else { event12.setWillClose(false); @@ -231,7 +230,7 @@ public class Ownership { } }); - Island island = skyblock.getIslandManager().getIsland(player); + Island island = plugin.getIslandManager().getIsland(player); UUID originalOwnerUUID = island.getOriginalOwnerUUID(); @@ -287,7 +286,7 @@ public class Ownership { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Title"))); nInv.setType(InventoryType.HOPPER); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } diff --git a/src/main/java/com/songoda/skyblock/menus/Settings.java b/src/main/java/com/songoda/skyblock/menus/Settings.java index 274a0292..81990404 100644 --- a/src/main/java/com/songoda/skyblock/menus/Settings.java +++ b/src/main/java/com/songoda/skyblock/menus/Settings.java @@ -13,7 +13,6 @@ import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.AbstractAnvilGUI; import com.songoda.skyblock.utils.item.nInventoryUtil; - import com.songoda.skyblock.visit.Visit; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -42,21 +41,21 @@ public class Settings { } public void open(Player player, Settings.Type menuType, IslandRole role, Settings.Panel panel) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { Island island = islandManager.getIsland(player); - Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); if (menuType == Settings.Type.Categories) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -89,7 +88,7 @@ public class Settings { && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Settings.Categories.Item.Coop.Displayname"))))) { - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Coop.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Disabled.Message")); @@ -112,7 +111,7 @@ public class Settings { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Coop, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Coop, null), 1L); } else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Settings.Categories.Item.Visitor.Displayname"))))) { @@ -130,7 +129,7 @@ public class Settings { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad @@ -149,7 +148,7 @@ public class Settings { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Member, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Member, null), 1L); } else if ((is.getType() == Material.ITEM_FRAME) && (is.hasItemMeta()) && (is.getItemMeta() .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Settings.Categories.Item.Operator.Displayname"))))) { @@ -166,7 +165,7 @@ public class Settings { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Operator, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Operator, null), 1L); } else if ((is.getType() == CompatibleMaterial.OAK_SAPLING.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad @@ -185,7 +184,7 @@ public class Settings { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Owner, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Owner, null), 1L); } } }); @@ -200,7 +199,7 @@ public class Settings { configLoad.getString("Menu.Settings.Categories.Item.Operator.Displayname"), configLoad.getStringList("Menu.Settings.Categories.Item.Operator.Lore"), null, null, null), 4); - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Coop.Enable")) { nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"), null, null, null, @@ -224,7 +223,7 @@ public class Settings { configLoad.getString("Menu.Settings.Categories.Title"))); nInv.setRows(1); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else if (menuType == Settings.Type.Role && role != null) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (playerDataManager.hasPlayerData(player)) { @@ -251,7 +250,7 @@ public class Settings { return; } else if (role == IslandRole.Coop) { - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Coop.Enable")) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Disabled.Message")); @@ -269,20 +268,20 @@ public class Settings { "Menu.Settings." + role.name() + ".Item.Return.Displayname"))))) { soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Categories, null, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Categories, null, null), 1L); } else if ((is.getType() == Material.PAPER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Settings.Visitor.Item.Signature.Displayname"))))) { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Panel, null, Panel.Signature), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Panel, null, Panel.Signature), 1L); } else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Visitor.Item.Welcome.Displayname"))))) { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Panel, null, Panel.Welcome), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Panel, null, Panel.Welcome), 1L); } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta() .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Settings.Visitor.Item.Statistics.Displayname"))))) { @@ -301,7 +300,7 @@ public class Settings { break; } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); } else if (is.hasItemMeta()) { String roleName = getRoleName(role); @@ -337,15 +336,15 @@ public class Settings { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, role, null), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, role, null), 1L); } } }); if (role == IslandRole.Visitor || role == IslandRole.Member || role == IslandRole.Coop) { if (role == IslandRole.Visitor) { - Config config = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")); Visit visit = island.getVisit(); if (config.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) { @@ -1037,7 +1036,7 @@ public class Settings { configLoad.getString("Menu.Settings." + role.name() + ".Item.Return.Displayname"), null, null, null, null), 0, 8); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else if (menuType == Settings.Type.Panel) { if (panel == Settings.Panel.Welcome) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -1059,8 +1058,8 @@ public class Settings { return; } - if (!skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (!plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable")) { messageManager.sendMessage(player, configLoad.getString("Island.Settings.Visitor.Welcome.Disabled.Message")); @@ -1077,7 +1076,7 @@ public class Settings { "Menu.Settings.Visitor.Panel.Welcome.Item.Return.Displayname"))))) { soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals( @@ -1098,7 +1097,7 @@ public class Settings { break; } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); } else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( @@ -1111,8 +1110,8 @@ public class Settings { .getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( "Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.Displayname"))))) { - if (island15.getMessage(IslandMessage.Welcome).size() >= skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (island15.getMessage(IslandMessage.Welcome).size() >= plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Visitor.Welcome.Lines")) { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -1121,7 +1120,7 @@ public class Settings { } else { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -1155,8 +1154,8 @@ public class Settings { event1.setWillDestroy(true); return; - } else if (!skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), + } else if (!plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration() .getBoolean("Island.Visitor.Welcome.Enable")) { @@ -1173,8 +1172,8 @@ public class Settings { return; } - Config config1 = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), + Config config1 = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad1 = config1 .getFileConfiguration(); @@ -1199,7 +1198,7 @@ public class Settings { } Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player, Type.Panel, null, @@ -1240,7 +1239,7 @@ public class Settings { island15.getMessageAuthor(IslandMessage.Welcome), welcomeMessage); soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_EXPLODE.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Panel, null, Panel.Welcome), 1L); } } @@ -1296,7 +1295,7 @@ public class Settings { configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Title"))); nInv.setType(InventoryType.HOPPER); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else if (panel == Settings.Panel.Signature) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (playerDataManager.hasPlayerData(player)) { @@ -1317,8 +1316,8 @@ public class Settings { return; } - if (!skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (!plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) { messageManager.sendMessage(player, configLoad.getString("Island.Settings.Visitor.Signature.Disabled.Message")); @@ -1335,7 +1334,7 @@ public class Settings { "Menu.Settings.Visitor.Panel.Signature.Item.Return.Displayname"))))) { soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals( @@ -1356,7 +1355,7 @@ public class Settings { break; } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L); } else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( @@ -1369,8 +1368,8 @@ public class Settings { .getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString( "Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.Displayname"))))) { - if (island12.getMessage(IslandMessage.Signature).size() >= skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) + if (island12.getMessage(IslandMessage.Signature).size() >= plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Visitor.Signature.Lines")) { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -1379,7 +1378,7 @@ public class Settings { } else { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -1413,8 +1412,8 @@ public class Settings { event1.setWillDestroy(true); return; - } else if (!skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), + } else if (!plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean( "Island.Visitor.Signature.Enable")) { @@ -1431,8 +1430,8 @@ public class Settings { return; } - Config config1 = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), + Config config1 = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad1 = config1 .getFileConfiguration(); @@ -1457,7 +1456,7 @@ public class Settings { } Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player, Type.Panel, null, @@ -1498,7 +1497,7 @@ public class Settings { island12.getMessageAuthor(IslandMessage.Signature), signatureMessage); soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_EXPLODE.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Panel, null, Panel.Signature), 1L); } @@ -1556,17 +1555,17 @@ public class Settings { configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Title"))); nInv.setType(InventoryType.HOPPER); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } } } private ItemStack createItem(Island island, IslandRole role, String setting, ItemStack is) { - SkyBlock skyblock = SkyBlock.getInstance(); - PermissionManager permissionManager = skyblock.getPermissionManager(); + SkyBlock plugin = SkyBlock.getInstance(); + PermissionManager permissionManager = plugin.getPermissionManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); List itemLore = new ArrayList<>(); diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java index 7d4b10d8..ad970c76 100644 --- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java @@ -17,7 +17,6 @@ import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.upgrade.UpgradeManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; - import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -48,16 +47,16 @@ public class Upgrade { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - UpgradeManager upgradeManager = skyblock.getUpgradeManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + UpgradeManager upgradeManager = plugin.getUpgradeManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); if (!EconomyManager.isEnabled()) { @@ -108,7 +107,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { List upgrades = upgradeManager @@ -127,7 +126,7 @@ public class Upgrade { island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Speed, true); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -163,7 +162,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { List upgrades = upgradeManager @@ -182,7 +181,7 @@ public class Upgrade { island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Jump, true); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -214,7 +213,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { List upgrades = upgradeManager .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Crop); @@ -232,7 +231,7 @@ public class Upgrade { island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Crop, true); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -265,7 +264,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { List upgrades = upgradeManager .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Fly); @@ -285,7 +284,7 @@ public class Upgrade { islandManager.updateFlightAtIsland(island); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -317,7 +316,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { List upgrades = upgradeManager .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Drops); @@ -335,7 +334,7 @@ public class Upgrade { island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Drops, true); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -383,7 +382,7 @@ public class Upgrade { island.getAPIWrapper(), player, APIUtil.fromImplementation( com.songoda.skyblock.upgrade.Upgrade.Type.Members))); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -437,7 +436,7 @@ public class Upgrade { island.getAPIWrapper(), player, APIUtil.fromImplementation( com.songoda.skyblock.upgrade.Upgrade.Type.Size))); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -475,7 +474,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { List upgrades = upgradeManager .getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner); @@ -493,7 +492,7 @@ public class Upgrade { island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner, true); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, @@ -909,9 +908,9 @@ public class Upgrade { } private String getStatus(Island island, com.songoda.skyblock.upgrade.Upgrade.Type type) { - SkyBlock skyblock = SkyBlock.getInstance(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); + SkyBlock plugin = SkyBlock.getInstance(); + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); String upgradeStatus; if (island.isUpgrade(type)) { diff --git a/src/main/java/com/songoda/skyblock/menus/Visit.java b/src/main/java/com/songoda/skyblock/menus/Visit.java index 38c681f7..1cb345fe 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visit.java +++ b/src/main/java/com/songoda/skyblock/menus/Visit.java @@ -20,7 +20,6 @@ import com.songoda.skyblock.utils.StringUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; - import com.songoda.skyblock.visit.VisitManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -46,16 +45,16 @@ public class Visit { } public void open(Player player, Visit.Type type, Visit.Sort sort) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - SoundManager soundManager = skyblock.getSoundManager(); - VisitManager visitManager = skyblock.getVisitManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + VisitManager visitManager = plugin.getVisitManager(); + FileManager fileManager = plugin.getFileManager(); - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -110,7 +109,7 @@ public class Visit { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Nothing.Displayname"))))) { @@ -124,13 +123,13 @@ public class Visit { playerData.setPage(MenuType.VISIT, playerData.getPage(MenuType.VISIT) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Next.Displayname")))) { playerData.setPage(MenuType.VISIT, playerData.getPage(MenuType.VISIT) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else { String targetPlayerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); UUID targetPlayerUUID; @@ -172,7 +171,7 @@ public class Visit { if ((!island.hasRole(IslandRole.Member, player.getUniqueId()) && !island.hasRole(IslandRole.Operator, player.getUniqueId()) && !island.hasRole(IslandRole.Owner, player.getUniqueId())) - && fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visitor.Vote")) { if (event.getClick() == ClickType.RIGHT) { if (playerData.getIsland() != null @@ -203,7 +202,7 @@ public class Visit { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } else { @@ -248,7 +247,7 @@ public class Visit { targetPlayerName)); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } @@ -260,7 +259,7 @@ public class Visit { .replace("%player", targetPlayerName)); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L); } } } @@ -269,7 +268,7 @@ public class Visit { Map openIslands = visitManager.getOpenIslands(); List visitIslands = new ArrayList<>(); - boolean keepBannedIslands = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + boolean keepBannedIslands = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visit.Menu.Bans"); for (int i = 0; i < openIslands.size(); i++) { @@ -384,7 +383,7 @@ public class Visit { nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Visit.Item.Nothing.Displayname"), null, null, null, null), 31); } else { - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); int index = playerMenuPage * 36 - 36, endIndex = index >= visitIslands.size() ? visitIslands.size() - 1 : index + 36, inventorySlot = 17, @@ -539,7 +538,7 @@ public class Visit { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } public enum Type { diff --git a/src/main/java/com/songoda/skyblock/menus/Visitors.java b/src/main/java/com/songoda/skyblock/menus/Visitors.java index 135734e7..9d5f747a 100644 --- a/src/main/java/com/songoda/skyblock/menus/Visitors.java +++ b/src/main/java/com/songoda/skyblock/menus/Visitors.java @@ -15,7 +15,6 @@ import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.SkullUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -40,25 +39,25 @@ public class Visitors { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (playerDataManager.hasPlayerData(player)) { - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); Island island = islandManager.getIsland(player); if (island == null) { - skyblock.getMessageManager().sendMessage(player, + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Visitors.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -98,20 +97,20 @@ public class Visitors { playerData.setPage(MenuType.VISITORS, playerData.getPage(MenuType.VISITORS) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( '&', configLoad.getString("Menu.Visitors.Item.Next.Displayname")))) { playerData.setPage(MenuType.VISITORS, playerData.getPage(MenuType.VISITORS) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { boolean isOperator = island.hasRole(IslandRole.Operator, player.getUniqueId()), isOwner = island.hasRole(IslandRole.Owner, player.getUniqueId()), canKick = permissionManager.hasPermission(island, "Kick", IslandRole.Operator), canBan = permissionManager.hasPermission(island, "Ban", IslandRole.Operator), banningEnabled = fileManager - .getConfig(new File(skyblock.getDataFolder(), "config.yml")) + .getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visitor.Banning"); String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); @@ -147,14 +146,14 @@ public class Visitors { } } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } } }); PlayerData playerData = playerDataManager.getPlayerData(player); - Island island = skyblock.getIslandManager().getIsland(player); + Island island = plugin.getIslandManager().getIsland(player); Set islandVisitors = islandManager.getVisitorsAtIsland(island); Map sortedIslandVisitors = new TreeMap<>(); @@ -212,9 +211,9 @@ public class Visitors { } else { boolean isOperator = island.hasRole(IslandRole.Operator, player.getUniqueId()), isOwner = island.hasRole(IslandRole.Owner, player.getUniqueId()), - canKick = skyblock.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator), - canBan = skyblock.getPermissionManager().hasPermission(island, "Ban", IslandRole.Operator), - banningEnabled = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + canKick = plugin.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator), + canBan = plugin.getPermissionManager().hasPermission(island, "Ban", IslandRole.Operator), + banningEnabled = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Visitor.Banning"); int index = playerMenuPage * 36 - 36, endIndex = index >= islandVisitors.size() ? islandVisitors.size() - 1 : index + 36, @@ -294,7 +293,7 @@ public class Visitors { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } } diff --git a/src/main/java/com/songoda/skyblock/menus/Weather.java b/src/main/java/com/songoda/skyblock/menus/Weather.java index 47b560b8..e1174d9a 100644 --- a/src/main/java/com/songoda/skyblock/menus/Weather.java +++ b/src/main/java/com/songoda/skyblock/menus/Weather.java @@ -14,7 +14,6 @@ import com.songoda.skyblock.placeholder.Placeholder; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.item.nInventoryUtil; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -39,17 +38,17 @@ public class Weather { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - PermissionManager permissionManager = skyblock.getPermissionManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, event -> { @@ -119,7 +118,7 @@ public class Weather { all.resetPlayerTime(); all.resetPlayerWeather(); all.setPlayerTime(island.getTime(), - fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); all.setPlayerWeather(island.getWeather()); } @@ -127,7 +126,7 @@ public class Weather { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == Material.GHAST_TEAR) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Weather.Displayname"))))) { @@ -142,7 +141,7 @@ public class Weather { all.resetPlayerTime(); all.resetPlayerWeather(); all.setPlayerTime(island.getTime(), - fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); all.setPlayerWeather(island.getWeather()); } @@ -150,7 +149,7 @@ public class Weather { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == Material.TRIPWIRE_HOOK) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Synchronised.Displayname"))))) { @@ -162,7 +161,7 @@ public class Weather { for (Player all : islandManager.getPlayersAtIsland(island, IslandWorld.Normal)) { all.setPlayerTime(islandTime, - fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); all.setPlayerWeather(islandWeather); } @@ -177,7 +176,7 @@ public class Weather { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } }); @@ -263,7 +262,7 @@ public class Weather { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Title"))); nInv.setType(InventoryType.HOPPER); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } } diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Creator.java b/src/main/java/com/songoda/skyblock/menus/admin/Creator.java index 93c456c3..11253c25 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Creator.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Creator.java @@ -48,14 +48,14 @@ public class Creator implements Listener { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - StructureManager structureManager = skyblock.getStructureManager(); - FileManager fileManager = skyblock.getFileManager(); + StructureManager structureManager = plugin.getStructureManager(); + FileManager fileManager = plugin.getFileManager(); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, null); @@ -248,7 +248,7 @@ public class Creator implements Listener { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Creator.Title"))); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } @SuppressWarnings("deprecation") @@ -258,14 +258,14 @@ public class Creator implements Listener { ItemStack is = event.getCurrentItem(); if (event.getCurrentItem() != null && event.getCurrentItem().getType() != CompatibleMaterial.AIR.getMaterial()) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - StructureManager structureManager = skyblock.getStructureManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + StructureManager structureManager = plugin.getStructureManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); String inventoryName = ""; @@ -282,7 +282,7 @@ public class Creator implements Listener { if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Creator.Title")))) { event.setCancelled(true); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); if (!(player.hasPermission("fabledskyblock.admin.create") || player.hasPermission("fabledskyblock.admin.*") || player.hasPermission("fabledskyblock.*"))) { @@ -314,7 +314,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; } @@ -348,9 +348,9 @@ public class Creator implements Listener { .replace("%structure", event1.getName())); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config111 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + .getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad111 = config111.getFileConfiguration(); configLoad111.set("Structures." + event1.getName() + ".Name", event1.getName()); @@ -364,7 +364,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } event1.setWillClose(true); @@ -400,7 +400,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -422,7 +422,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (!structureManager.containsStructure(name)) { messageManager.sendMessage(player, @@ -431,7 +431,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { Structure structure = structureManager.getStructure(name); @@ -439,10 +439,10 @@ public class Creator implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config1 = fileManager.getConfig( - new File(skyblock.getDataFolder(), "structures.yml")); + new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad1 = config1.getFileConfiguration(); configLoad1.set( @@ -458,7 +458,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } @@ -487,7 +487,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } @@ -502,7 +502,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -514,9 +514,9 @@ public class Creator implements Listener { structure.removeLine(structure.getDescription().size() - 1); soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_EXPLODE.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config12 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + .getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad12 = config12.getFileConfiguration(); configLoad12.set("Structures." + structure.getName() + ".Description", @@ -531,7 +531,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; @@ -557,7 +557,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (!structureManager.containsStructure(name)) { messageManager.sendMessage(player, @@ -566,17 +566,17 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { structure.addLine(event1.getName()); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config13 = fileManager.getConfig( - new File(skyblock.getDataFolder(), "structures.yml")); + new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad13 = config13.getFileConfiguration(); configLoad13.set( @@ -592,7 +592,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } @@ -621,7 +621,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } @@ -636,7 +636,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -648,9 +648,9 @@ public class Creator implements Listener { structure.removeCommand(structure.getCommands().size() - 1); soundManager.playSound(player, CompatibleSound.ENTITY_GENERIC_EXPLODE.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config14 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + .getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad14 = config14.getFileConfiguration(); configLoad14.set("Structures." + structure.getName() + ".Commands", @@ -665,7 +665,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; @@ -691,7 +691,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (!structureManager.containsStructure(name)) { messageManager.sendMessage(player, @@ -700,17 +700,17 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { structure.addCommand(event1.getName()); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config15 = fileManager.getConfig( - new File(skyblock.getDataFolder(), "structures.yml")); + new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad15 = config15.getFileConfiguration(); configLoad15.set( @@ -726,7 +726,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } @@ -755,7 +755,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } @@ -771,7 +771,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -786,9 +786,9 @@ public class Creator implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config16 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + .getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad16 = config16.getFileConfiguration(); configLoad16.set("Structures." + structure.getName() + ".Permission", @@ -803,7 +803,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { playerData.setViewer(null); @@ -813,7 +813,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } @@ -830,7 +830,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -852,7 +852,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (!structureManager.containsStructure(name)) { messageManager.sendMessage(player, @@ -861,12 +861,12 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String fileName = event1.getName(); - if (fileManager.isFileExist(new File(skyblock.getDataFolder().toString() + "/structures", fileName)) || - fileManager.isFileExist(new File(skyblock.getDataFolder().toString() + "/schematics", fileName))) { + if (fileManager.isFileExist(new File(plugin.getDataFolder().toString() + "/structures", fileName)) || + fileManager.isFileExist(new File(plugin.getDataFolder().toString() + "/schematics", fileName))) { if (event.getClick() == ClickType.LEFT) { Structure structure = structureManager.getStructure(name); structure.setOverworldFile(fileName); @@ -874,10 +874,10 @@ public class Creator implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config17 = fileManager.getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad17 = config17 .getFileConfiguration(); @@ -897,10 +897,10 @@ public class Creator implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config18 = fileManager.getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad18 = config18 .getFileConfiguration(); @@ -921,10 +921,10 @@ public class Creator implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config19 = fileManager.getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad19 = config19 .getFileConfiguration(); @@ -948,7 +948,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } @@ -977,7 +977,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } } @@ -993,7 +993,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { Creator.Viewer viewer = (Viewer) playerData.getViewer(); String name = viewer.getName(); @@ -1018,7 +1018,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } } @@ -1034,7 +1034,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -1058,7 +1058,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; @@ -1069,7 +1069,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; @@ -1092,9 +1092,9 @@ public class Creator implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config112 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + .getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad112 = config112.getFileConfiguration(); configLoad112.set("Structures." + structure.getName() + ".Deletion.Cost", @@ -1107,7 +1107,7 @@ public class Creator implements Listener { } }); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { event1.setWillClose(false); @@ -1132,7 +1132,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } @@ -1151,9 +1151,9 @@ public class Creator implements Listener { if (materials != null) { structure.setMaterial(materials); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config113 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + .getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad113 = config113.getFileConfiguration(); configLoad113.set("Structures." + structure.getName() + ".Item.Material", @@ -1175,7 +1175,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { playerData.setViewer(null); @@ -1185,7 +1185,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } return; @@ -1203,7 +1203,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (event.getClick() == ClickType.RIGHT) { structureManager.removeStructure(structureList); @@ -1212,9 +1212,9 @@ public class Creator implements Listener { .replace("%structure", structureList.getName())); soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config110 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + .getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad110 = config110.getFileConfiguration(); configLoad110.set("Structures." + structureList.getName(), null); @@ -1228,7 +1228,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } return; @@ -1240,7 +1240,7 @@ public class Creator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } } @@ -1250,9 +1250,9 @@ public class Creator implements Listener { public void onInventoryClose(InventoryCloseEvent event) { Player player = (Player) event.getPlayer(); - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); String inventoryName = ""; @@ -1267,7 +1267,7 @@ public class Creator implements Listener { } if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Creator.Title")))) { - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); if (playerDataManager.hasPlayerData(player)) { Creator.Viewer viewer = (Viewer) playerDataManager.getPlayerData(player).getViewer(); @@ -1275,9 +1275,9 @@ public class Creator implements Listener { if (viewer != null) { if (viewer.isItem()) { viewer.setItem(false); - skyblock.getMessageManager().sendMessage(player, + plugin.getMessageManager().sendMessage(player, configLoad.getString("Island.Admin.Creator.Item.Removed.Message")); - skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); + plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); } } } 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 f8d8841d..8c75f51a 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java @@ -48,14 +48,14 @@ public class Generator implements Listener { } public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - GeneratorManager generatorManager = skyblock.getGeneratorManager(); - FileManager fileManager = skyblock.getFileManager(); + GeneratorManager generatorManager = plugin.getGeneratorManager(); + FileManager fileManager = plugin.getFileManager(); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, null); @@ -173,10 +173,9 @@ public class Generator implements Listener { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Generator.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, nInv::open); + Bukkit.getServer().getScheduler().runTask(plugin, nInv::open); } - - @SuppressWarnings("deprecation") + @EventHandler public void onInventoryClick(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); @@ -184,14 +183,14 @@ public class Generator implements Listener { if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) return; - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - GeneratorManager generatorManager = skyblock.getGeneratorManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + GeneratorManager generatorManager = plugin.getGeneratorManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); String inventoryName = ""; @@ -209,7 +208,7 @@ public class Generator implements Listener { return; event.setCancelled(true); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); if (!(player.hasPermission("fabledskyblock.admin.generator") || player.hasPermission("fabledskyblock.admin.*") || player.hasPermission("fabledskyblock.*"))) { @@ -253,7 +252,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; } @@ -286,9 +285,9 @@ public class Generator implements Listener { .replace("%generator", event1.getName())); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config14 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "generators.yml")); + .getConfig(new File(plugin.getDataFolder(), "generators.yml")); FileConfiguration configLoad14 = config14.getFileConfiguration(); configLoad14.set("Generators." + event1.getName() + ".Name", event1.getName()); @@ -302,7 +301,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } event1.setWillClose(true); @@ -334,7 +333,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { String name = ((Generator.Viewer) playerData.getViewer()).getName(); @@ -349,9 +348,9 @@ public class Generator implements Listener { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config1 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "generators.yml")); + .getConfig(new File(plugin.getDataFolder(), "generators.yml")); FileConfiguration configLoad1 = config1.getFileConfiguration(); configLoad1.set("Generators." + generator.getName() + ".Permission", @@ -366,7 +365,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { playerData.setViewer(null); @@ -376,7 +375,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } @@ -400,7 +399,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', @@ -410,7 +409,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; } @@ -490,9 +489,9 @@ public class Generator implements Listener { 1.0F, 1.0F); Bukkit.getServer().getScheduler() - .runTaskAsynchronously(skyblock, () -> { + .runTaskAsynchronously(plugin, () -> { Config config12 = fileManager.getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "generators.yml")); FileConfiguration configLoad12 = config12 .getFileConfiguration(); @@ -513,7 +512,7 @@ public class Generator implements Listener { player.closeInventory(); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, () -> open(player), 1L); + .runTaskLater(plugin, () -> open(player), 1L); } } @@ -536,10 +535,10 @@ public class Generator implements Listener { } else if (event.getClick() == ClickType.RIGHT) { generator.getGeneratorMaterials().remove(generatorMaterialList); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config15 = fileManager.getConfig( - new File(skyblock.getDataFolder(), "generators.yml")); + new File(plugin.getDataFolder(), "generators.yml")); FileConfiguration configLoad15 = config15.getFileConfiguration(); configLoad15.set( @@ -557,7 +556,7 @@ public class Generator implements Listener { soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } @@ -593,9 +592,9 @@ public class Generator implements Listener { .replace("%generator", generator.getName())); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config16 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "generators.yml")); + .getConfig(new File(plugin.getDataFolder(), "generators.yml")); FileConfiguration configLoad16 = config16.getFileConfiguration(); configLoad16.set("Generators." + generator.getName() + ".Materials." @@ -610,7 +609,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } return; @@ -623,7 +622,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } return; @@ -640,7 +639,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (event.getClick() == ClickType.RIGHT) { generatorManager.removeGenerator(generatorList); @@ -649,9 +648,9 @@ public class Generator implements Listener { .replace("%generator", generatorList.getName())); soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config13 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "generators.yml")); + .getConfig(new File(plugin.getDataFolder(), "generators.yml")); FileConfiguration configLoad13 = config13.getFileConfiguration(); configLoad13.set("Generators." + generatorList.getName(), null); @@ -665,7 +664,7 @@ public class Generator implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } return; diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java index 61bb1df3..a43445b6 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java @@ -49,12 +49,12 @@ public class Levelling implements Listener { @SuppressWarnings("deprecation") public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - IslandLevelManager levellingManager = skyblock.getLevellingManager(); - FileManager fileManager = skyblock.getFileManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); + FileManager fileManager = plugin.getFileManager(); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); List levellingMaterials = levellingManager.getWorthsAsLevelingMaterials(); @@ -72,7 +72,7 @@ public class Levelling implements Listener { return testInventory.getItem(0) != null; }).collect(Collectors.toList()); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); nInventoryUtil nInv = new nInventoryUtil(player, null); @@ -86,7 +86,7 @@ public class Levelling implements Listener { configLoad.getStringList("Menu.Admin.Levelling.Item.Information.Lore"), new Placeholder[]{new Placeholder("%materials", "" + levellingMaterials.size()), new Placeholder("%division", - "" + fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) + "" + fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Levelling.Division"))}, null, null), 4); @@ -145,7 +145,7 @@ public class Levelling implements Listener { nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Title"))); nInv.setRows(6); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } @SuppressWarnings("deprecation") @@ -155,14 +155,14 @@ public class Levelling implements Listener { ItemStack is = event.getCurrentItem(); if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - IslandLevelManager levellingManager = skyblock.getLevellingManager(); - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); String inventoryName = ""; @@ -178,7 +178,7 @@ public class Levelling implements Listener { if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Title")))) { event.setCancelled(true); - PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player); + PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); if (!(player.hasPermission("fabledskyblock.admin.level") || player.hasPermission("fabledskyblock.admin.*") || player.hasPermission("fabledskyblock.*"))) { @@ -224,9 +224,9 @@ public class Levelling implements Listener { .replace("%division", NumberUtil.formatNumberByDecimal(pointDivision))); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config12 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "config.yml")); + .getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad12 = config12.getFileConfiguration(); configLoad12.set("Island.Levelling.Division", pointDivision); @@ -240,7 +240,7 @@ public class Levelling implements Listener { player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Numerical.Message")); @@ -279,7 +279,7 @@ public class Levelling implements Listener { playerData.setPage(MenuType.ADMIN_LEVELLING, playerData.getPage(MenuType.ADMIN_LEVELLING) - 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', @@ -289,7 +289,7 @@ public class Levelling implements Listener { playerData.setPage(MenuType.ADMIN_LEVELLING, playerData.getPage(MenuType.ADMIN_LEVELLING) + 1); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); return; } @@ -327,15 +327,15 @@ public class Levelling implements Listener { 1.0F); player.closeInventory(); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); levellingManager.addWorth(materials, materialPoints); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config1 = fileManager.getConfig(new File( - skyblock.getDataFolder(), "levelling.yml")); + plugin.getDataFolder(), "levelling.yml")); FileConfiguration configLoad1 = config1 .getFileConfiguration(); @@ -386,9 +386,9 @@ public class Levelling implements Listener { .replace("%material", materials.name())); soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config13 = fileManager - .getConfig(new File(skyblock.getDataFolder(), "levelling.yml")); + .getConfig(new File(plugin.getDataFolder(), "levelling.yml")); FileConfiguration configLoad13 = config13.getFileConfiguration(); configLoad13.set("Materials." + materials.name(), null); @@ -425,8 +425,8 @@ public class Levelling implements Listener { .replace("%material", materials.name())); soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { - Config config14 = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml")); + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { + Config config14 = fileManager.getConfig(new File(plugin.getDataFolder(), "levelling.yml")); FileConfiguration configLoad14 = config14.getFileConfiguration(); configLoad14.set("Materials." + materials.name() + ".Points", 0); diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java index 8e45690e..6a255052 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java @@ -14,7 +14,6 @@ import com.songoda.skyblock.upgrade.UpgradeManager; import com.songoda.skyblock.utils.AbstractAnvilGUI; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.item.nInventoryUtil; - import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -47,16 +46,16 @@ public class Upgrade { @SuppressWarnings("deprecation") public void open(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); - MessageManager messageManager = skyblock.getMessageManager(); - UpgradeManager upgradeManager = skyblock.getUpgradeManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + UpgradeManager upgradeManager = plugin.getUpgradeManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player) && playerDataManager.getPlayerData(player).getViewer() != null) { - FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) + FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); Viewer viewer = (Upgrade.Viewer) playerDataManager.getPlayerData(player).getViewer(); @@ -118,7 +117,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == Material.BOOKSHELF) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Members.Displayname"))))) { @@ -127,7 +126,7 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == CompatibleMaterial.SPAWNER.getMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName() .equals(ChatColor.translateAlternateColorCodes('&', configLoad @@ -150,10 +149,10 @@ public class Upgrade { .getPlayerData(player).getViewer()).getUpgrade(); boolean enabled = upgrade.isEnabled(); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config = fileManager.getConfig(new File( - skyblock.getDataFolder(), "upgrades.yml")); + plugin.getDataFolder(), "upgrades.yml")); FileConfiguration configLoad1 = config .getFileConfiguration(); @@ -171,11 +170,11 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if (event.getClick() == ClickType.RIGHT) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("fabledskyblock.admin.upgrade") @@ -211,10 +210,10 @@ public class Upgrade { soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { Config config = fileManager.getConfig(new File( - skyblock.getDataFolder(), "upgrades.yml")); + plugin.getDataFolder(), "upgrades.yml")); FileConfiguration configLoad1 = config .getFileConfiguration(); @@ -230,7 +229,7 @@ public class Upgrade { }); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, () -> open(player), 1L); + .runTaskLater(plugin, () -> open(player), 1L); } event1.setWillClose(true); @@ -378,7 +377,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Upgrades.Title"))); nInv.setRows(1); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else if (viewer.getType() == Upgrade.Viewer.Type.Size) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (!(player.hasPermission("fabledskyblock.admin.upgrade") || player.hasPermission("fabledskyblock.admin.*") @@ -401,7 +400,7 @@ public class Upgrade { playerData.setViewer(new Viewer(Viewer.Type.Upgrades, null)); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta() .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Admin.Upgrade.Size.Item.Information.Displayname"))))) { @@ -418,7 +417,7 @@ public class Upgrade { } else { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -451,7 +450,7 @@ public class Upgrade { 1.0F); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); return; @@ -495,7 +494,7 @@ public class Upgrade { size); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); } @@ -537,7 +536,7 @@ public class Upgrade { if (event.getClick() == ClickType.LEFT) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -580,7 +579,7 @@ public class Upgrade { 1.0F); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); return; @@ -623,14 +622,14 @@ public class Upgrade { .get(tier).setValue(size); fileManager .getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "upgrades.yml")) .getFileConfiguration() .set("Upgrades.Size." + tier + ".Value", size); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); } @@ -660,7 +659,7 @@ public class Upgrade { } else if (event.getClick() == ClickType.RIGHT) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -705,7 +704,7 @@ public class Upgrade { 1.0F); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); return; @@ -720,14 +719,14 @@ public class Upgrade { .get(tier).setCost(cost); fileManager .getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "upgrades.yml")) .getFileConfiguration() .set("Upgrades.Size." + tier + ".Cost", cost); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); } @@ -758,7 +757,7 @@ public class Upgrade { } } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } }); @@ -805,7 +804,7 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Size.Title"))); nInv.setRows(1); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } else if (viewer.getType() == Viewer.Type.Members) { nInventoryUtil nInv = new nInventoryUtil(player, event -> { if (!(player.hasPermission("fabledskyblock.admin.upgrade") || player.hasPermission("fabledskyblock.admin.*") @@ -828,7 +827,7 @@ public class Upgrade { playerData.setViewer(new Viewer(Viewer.Type.Upgrades, null)); soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta() .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad .getString("Menu.Admin.Upgrade.Members.Item.Information.Displayname"))))) { @@ -845,7 +844,7 @@ public class Upgrade { } else { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -878,7 +877,7 @@ public class Upgrade { 1.0F); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); return; @@ -1007,7 +1006,7 @@ public class Upgrade { 1.0F); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); return; @@ -1087,7 +1086,7 @@ public class Upgrade { } else if (event.getClick() == ClickType.RIGHT) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -1185,7 +1184,7 @@ public class Upgrade { } } - Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L); + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } } }); @@ -1232,15 +1231,15 @@ public class Upgrade { configLoad.getString("Menu.Admin.Upgrade.Members.Title"))); nInv.setRows(1); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open()); + Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open()); } } } private String getStatus(com.songoda.skyblock.upgrade.Upgrade upgrade) { - SkyBlock skyblock = SkyBlock.getInstance(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration(); + SkyBlock plugin = SkyBlock.getInstance(); + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); if (upgrade.isEnabled()) { return configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Word.Disable"); diff --git a/src/main/java/com/songoda/skyblock/message/MessageManager.java b/src/main/java/com/songoda/skyblock/message/MessageManager.java index 7eff3a4a..061f910d 100644 --- a/src/main/java/com/songoda/skyblock/message/MessageManager.java +++ b/src/main/java/com/songoda/skyblock/message/MessageManager.java @@ -11,10 +11,10 @@ import java.util.List; public class MessageManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public MessageManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public MessageManager(SkyBlock plugin) { + this.plugin = plugin; } public void sendMessage(CommandSender sender, String message) { @@ -22,7 +22,7 @@ public class MessageManager { if (message == null) return; if (sender instanceof Player) { - PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); Player player = (Player) sender; if (placeholderManager.isPlaceholderAPIEnabled()) { @@ -60,7 +60,7 @@ public class MessageManager { } public String replaceMessage(Player player, String message) { - PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); if (placeholderManager.isPlaceholderAPIEnabled()) { message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message.replace("&", "clr")).replace("clr", "&"); diff --git a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java index bfb179bc..81194392 100644 --- a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java @@ -6,7 +6,6 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandRole; -import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 3e600359..da139af3 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -7,12 +7,10 @@ import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.permission.event.Stoppable; import com.songoda.skyblock.permission.permissions.basic.*; import com.songoda.skyblock.permission.permissions.listening.*; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; -import org.bukkit.event.player.PlayerMoveEvent; import java.io.File; import java.io.IOException; diff --git a/src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java b/src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java index fda7715c..b6912d63 100644 --- a/src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java +++ b/src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java @@ -1,9 +1,7 @@ package com.songoda.skyblock.permission.event.events; import com.songoda.skyblock.permission.event.Stoppable; -import org.bukkit.Location; import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.entity.ProjectileLaunchEvent; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java index 74c68845..cf15c3ee 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/BrewingPermission.java @@ -7,11 +7,8 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; public class BrewingPermission extends ListeningPermission { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java index e91520a5..6f0356e1 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java @@ -7,7 +7,6 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.utils.version.NMSUtil; -import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java index b6f1439e..2606b0b4 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DestroyPermission.java @@ -6,8 +6,9 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.Bukkit; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/EntityPlacementPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/EntityPlacementPermission.java index cd583fca..66445e0e 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/EntityPlacementPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/EntityPlacementPermission.java @@ -7,8 +7,6 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; public class EntityPlacementPermission extends ListeningPermission { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java index 80e8e1b8..313975a4 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java @@ -1,12 +1,10 @@ package com.songoda.skyblock.permission.permissions.listening; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.Bukkit; import org.bukkit.entity.Creeper; import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.minecart.ExplosiveMinecart; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java index 8acd6da6..eaaafa74 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FirePermission.java @@ -6,7 +6,6 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.block.Action; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java index a3f8b54b..efea4ec7 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java @@ -10,7 +10,6 @@ import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent; import org.bukkit.entity.FishHook; import org.bukkit.entity.Player; -import org.bukkit.event.entity.ProjectileLaunchEvent; public class FishingPermission extends ListeningPermission { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/HangingDestroyPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/HangingDestroyPermission.java index fee55ad7..1f81acef 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/HangingDestroyPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/HangingDestroyPermission.java @@ -6,7 +6,10 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Hanging; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java index 9d7bc164..2c3d1212 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/HungerPermission.java @@ -8,8 +8,6 @@ import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import org.bukkit.event.entity.FoodLevelChangeEvent; -import java.io.File; - public class HungerPermission extends ListeningPermission { private final SkyBlock plugin; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ItemPickupPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ItemPickupPermission.java index 58fef4b4..2c0928d7 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ItemPickupPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ItemPickupPermission.java @@ -4,7 +4,6 @@ import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent; public class ItemPickupPermission extends ListeningPermission { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java index 75fea9e8..2c5f0084 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MonsterHurtingPermission.java @@ -7,8 +7,10 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionPriority; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.Bukkit; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; public class MonsterHurtingPermission extends ListeningPermission { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index c5fb8811..7b4e2be1 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -10,15 +10,11 @@ import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; import com.songoda.skyblock.utils.world.LocationUtil; -import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import java.util.concurrent.CompletableFuture; - public class PortalPermission extends ListeningPermission { private final SkyBlock plugin; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java index a73af766..84545b19 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java @@ -10,7 +10,6 @@ import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; -import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerInteractEvent; public class ProjectilePermission extends ListeningPermission { diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java index 684ac8b3..989a11cb 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/StoragePermission.java @@ -1,13 +1,11 @@ package com.songoda.skyblock.permission.permissions.listening; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.minecart.StorageMinecart; diff --git a/src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java b/src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java index b15c0902..16655c31 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java +++ b/src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java @@ -19,10 +19,10 @@ import java.util.List; public class EZPlaceholder extends PlaceholderExpansion { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public EZPlaceholder(SkyBlock skyblock) { - this.skyblock = skyblock; + public EZPlaceholder(SkyBlock plugin) { + this.plugin = plugin; } public String getIdentifier() { @@ -34,11 +34,11 @@ public class EZPlaceholder extends PlaceholderExpansion { } public String getAuthor() { - return skyblock.getDescription().getAuthors().get(0); + return plugin.getDescription().getAuthors().get(0); } public String getVersion() { - return skyblock.getDescription().getVersion(); + return plugin.getDescription().getVersion(); } public boolean persist() { @@ -46,10 +46,10 @@ public class EZPlaceholder extends PlaceholderExpansion { } public String onPlaceholderRequest(Player player, String identifier) { - PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); List leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level); @@ -58,7 +58,7 @@ public class EZPlaceholder extends PlaceholderExpansion { if (identifier.equalsIgnoreCase("islands")) { - return "" + skyblock.getVisitManager().getIslands().size(); + return "" + plugin.getVisitManager().getIslands().size(); } else { for (int i = 0; i < 10; i++) { if (identifier.equalsIgnoreCase("leaderboard_votes_" + (i + 1))) { diff --git a/src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java b/src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java index 3c87bd20..133e03e3 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java +++ b/src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java @@ -20,27 +20,27 @@ import java.util.logging.Level; public class MVdWPlaceholder { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public MVdWPlaceholder(SkyBlock skyblock) { - this.skyblock = skyblock; + public MVdWPlaceholder(SkyBlock plugin) { + this.plugin = plugin; } public void register() { - PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); List leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level); List leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank); List leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes); - PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_islands", event -> "" + skyblock.getVisitManager().getIslands().size()); + PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_islands", event -> "" + plugin.getVisitManager().getIslands().size()); for (int i = 0; i < 10; i++) { - PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_leaderboard_votes_" + (i + 1), + PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_leaderboard_votes_" + (i + 1), event -> { int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_votes_", "")); @@ -68,7 +68,7 @@ public class MVdWPlaceholder { configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty.Message")); }); - PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_leaderboard_bank_" + (i + 1), + PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_leaderboard_bank_" + (i + 1), event -> { int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_bank_", "")); @@ -96,7 +96,7 @@ public class MVdWPlaceholder { configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty.Message")); }); - PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_leaderboard_level_" + (i + 1), + PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_leaderboard_level_" + (i + 1), event -> { int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_level_", "")); @@ -127,7 +127,7 @@ public class MVdWPlaceholder { } for (String placeholderList : placeholderManager.getPlaceholders()) { - PlaceholderAPI.registerPlaceholder(skyblock, placeholderList, event -> { + PlaceholderAPI.registerPlaceholder(plugin, placeholderList, event -> { try { Player player = event.getPlayer(); diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java index 8f4d1463..b0405a70 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java @@ -1,45 +1,43 @@ package com.songoda.skyblock.placeholder; +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.invite.Invite; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.IslandStatus; +import com.songoda.skyblock.leaderboard.Leaderboard; +import com.songoda.skyblock.leaderboard.LeaderboardManager; +import com.songoda.skyblock.levelling.IslandLevelManager; +import com.songoda.skyblock.upgrade.Upgrade; +import com.songoda.skyblock.upgrade.Upgrade.Type; +import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.skyblock.visit.VisitManager; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginManager; + import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.skyblock.island.IslandStatus; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.PluginManager; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.invite.Invite; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.leaderboard.Leaderboard; -import com.songoda.skyblock.leaderboard.LeaderboardManager; -import com.songoda.skyblock.levelling.IslandLevelManager; -import com.songoda.skyblock.upgrade.Upgrade; -import com.songoda.skyblock.upgrade.Upgrade.Type; -import com.songoda.skyblock.utils.NumberUtil; - -import com.songoda.skyblock.visit.VisitManager; - public class PlaceholderManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private boolean PlaceholderAPI = false; private boolean MVdWPlaceholderAPI = false; - public PlaceholderManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public PlaceholderManager(SkyBlock plugin) { + this.plugin = plugin; - PluginManager pluginManager = skyblock.getServer().getPluginManager(); + PluginManager pluginManager = plugin.getServer().getPluginManager(); if (pluginManager.getPlugin("PlaceholderAPI") != null) { PlaceholderAPI = true; @@ -52,11 +50,11 @@ public class PlaceholderManager { public void registerPlaceholders() { if (PlaceholderAPI) { - new EZPlaceholder(skyblock).register(); + new EZPlaceholder(plugin).register(); } if (MVdWPlaceholderAPI) { - new MVdWPlaceholder(skyblock).register(); + new MVdWPlaceholder(plugin).register(); } } @@ -69,13 +67,13 @@ public class PlaceholderManager { } public String getPlaceholder(Player player, String placeholder) { - IslandManager islandManager = skyblock.getIslandManager(); - VisitManager visitManager = skyblock.getVisitManager(); - IslandLevelManager levellingManager = skyblock.getLevellingManager(); + IslandManager islandManager = plugin.getIslandManager(); + VisitManager visitManager = plugin.getVisitManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); Island island = islandManager.getIsland(player); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (placeholder.equalsIgnoreCase("fabledskyblock_island_exists")) { @@ -148,7 +146,7 @@ public class PlaceholderManager { if (island.hasRole(roleList, player.getUniqueId())) { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_role.Non-empty.Message") - .replace("%placeholder", skyblock.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList))); + .replace("%placeholder", plugin.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList))); } } } @@ -281,7 +279,7 @@ public class PlaceholderManager { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_invites.Empty.Message")); } else { - Map invites = skyblock.getInviteManager().getInvites(); + Map invites = plugin.getInviteManager().getInvites(); int invitedPlayers = 0; for (int i = 0; i < invites.size(); i++) { @@ -320,7 +318,7 @@ public class PlaceholderManager { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty.Message")); } else { - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level); return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty.Message") @@ -331,7 +329,7 @@ public class PlaceholderManager { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty.Message")); } else { - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank); return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty.Message") @@ -342,7 +340,7 @@ public class PlaceholderManager { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty.Message")); } else { - LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes); return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty.Message") diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 0036824c..47c4d276 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -8,7 +8,6 @@ import com.songoda.skyblock.confirmation.Confirmation; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.menus.MenuType; import com.songoda.skyblock.utils.structure.Area; - import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -19,7 +18,7 @@ import java.util.*; public class PlayerData { - private final SkyBlock skyblock; + private final SkyBlock plugin; private UUID uuid; private UUID islandOwnerUUID; private UUID ownershipUUID; @@ -47,7 +46,7 @@ public class PlayerData { private List transactions; public PlayerData(Player player) { - this.skyblock = SkyBlock.getInstance(); + this.plugin = SkyBlock.getInstance(); uuid = player.getUniqueId(); islandOwnerUUID = null; @@ -316,8 +315,8 @@ public class PlayerData { } private Config getConfig() { - SkyBlock skyblock = SkyBlock.getInstance(); - return skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); + SkyBlock plugin = SkyBlock.getInstance(); + return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); } public Player getPlayer() { @@ -338,12 +337,12 @@ public class PlayerData { public void setChatSpy(boolean chatSpy) { this.chatSpy = chatSpy; - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public void addChatSpyIsland(UUID uuid) { spiedIslands.add(uuid); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public boolean isChatSpyIsland(UUID uuid) { @@ -352,7 +351,7 @@ public class PlayerData { public void removeChatSpyIsland(UUID uuid) { spiedIslands.remove(uuid); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public Set getChatSpyIslands() { @@ -377,6 +376,6 @@ public class PlayerData { public void enableGlobalChatSpy() { spiedIslands.clear(); - Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } } diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index 7e3b5c29..0b9cdb85 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -28,11 +28,11 @@ import java.util.UUID; public class PlayerDataManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private Map playerDataStorage = new HashMap<>(); - public PlayerDataManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public PlayerDataManager(SkyBlock plugin) { + this.plugin = plugin; for (Player all : Bukkit.getOnlinePlayers()) { loadPlayerData(all); @@ -53,7 +53,7 @@ public class PlayerDataManager { } public void createPlayerData(Player player) { - Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); String[] playerTexture; @@ -82,7 +82,7 @@ public class PlayerDataManager { } public void loadPlayerData(Player player) { - if (skyblock.getFileManager().isFileExist(new File(skyblock.getDataFolder().toString() + "/player-data", player.getUniqueId().toString() + ".yml"))) { + if (plugin.getFileManager().isFileExist(new File(plugin.getDataFolder().toString() + "/player-data", player.getUniqueId().toString() + ".yml"))) { PlayerData playerData = new PlayerData(player); playerDataStorage.put(player.getUniqueId(), playerData); } @@ -90,14 +90,14 @@ public class PlayerDataManager { public void unloadPlayerData(Player player) { if (hasPlayerData(player)) { - skyblock.getFileManager().unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); + plugin.getFileManager().unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); playerDataStorage.remove(player.getUniqueId()); } } public void savePlayerData(Player player) { if (hasPlayerData(player)) { - Config config = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); + Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml")); try { config.getFileConfiguration().save(config.getFile()); @@ -128,13 +128,13 @@ public class PlayerDataManager { } public void storeIsland(Player player) { - MessageManager messageManager = skyblock.getMessageManager(); - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); - BanManager banManager = skyblock.getBanManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); + BanManager banManager = plugin.getBanManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (hasPlayerData(player)) { @@ -152,7 +152,7 @@ public class PlayerDataManager { targetPlayerName = targetPlayer.getName(); } - if (banManager.hasIsland(island.getOwnerUUID()) && fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") + if (banManager.hasIsland(island.getOwnerUUID()) && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && banManager.getIsland(island.getOwnerUUID()).isBanned(player.getUniqueId())) { if (messageManager != null) messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Island.Message").replace("%player", targetPlayerName)); @@ -163,7 +163,7 @@ public class PlayerDataManager { if (world == IslandWorld.Normal) { if (!island.isWeatherSynchronized()) { - player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); + player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); player.setPlayerWeather(island.getWeather()); } } @@ -183,14 +183,14 @@ public class PlayerDataManager { if (world == IslandWorld.Normal) { if (!island.isWeatherSynchronized()) { - player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); + player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); player.setPlayerWeather(island.getWeather()); } } islandManager.updateFlight(player); - ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); if (scoreboardManager != null) { for (Player all : Bukkit.getOnlinePlayers()) { @@ -226,7 +226,7 @@ public class PlayerDataManager { return; } - HashMap visitIslands = skyblock.getVisitManager().getIslands(); + HashMap visitIslands = plugin.getVisitManager().getIslands(); for (UUID visitIslandList : visitIslands.keySet()) { Visit visit = visitIslands.get(visitIslandList); @@ -242,7 +242,7 @@ public class PlayerDataManager { targetPlayerName = targetPlayer.getName(); } - if (banManager.hasIsland(visitIslandList) && fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") + if (banManager.hasIsland(visitIslandList) && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && banManager.getIsland(visitIslandList).isBanned(player.getUniqueId())) { if (messageManager != null) messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Island.Message").replace("%player", targetPlayerName)); @@ -267,7 +267,7 @@ public class PlayerDataManager { if (world == IslandWorld.Normal) { if (!island.isWeatherSynchronized()) { - player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); + player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle")); player.setPlayerWeather(island.getWeather()); } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java index 98a9b161..1d2168f4 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java @@ -1,16 +1,5 @@ package com.songoda.skyblock.scoreboard; -import java.util.*; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Team; - import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; @@ -20,6 +9,18 @@ import com.songoda.skyblock.localization.type.Localization; import com.songoda.skyblock.placeholder.PlaceholderManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.version.NMSUtil; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Team; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; public class Scoreboard { @@ -167,9 +168,9 @@ public class Scoreboard { } private String replaceDisplayLine(String displayLine) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - IslandManager islandManager = skyblock.getIslandManager(); + IslandManager islandManager = plugin.getIslandManager(); displayLine = displayLine.replace("%players_online", String.valueOf(Bukkit.getServer().getOnlinePlayers().size())); displayLine = displayLine.replace("%players_max", String.valueOf(Bukkit.getServer().getMaxPlayers())); @@ -187,7 +188,7 @@ public class Scoreboard { String islandRole = ""; - Localization locale = skyblock.getLocalizationManager().getLocalizationFor(IslandRole.class); + Localization locale = plugin.getLocalizationManager().getLocalizationFor(IslandRole.class); if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { islandRole = locale.getLocale(IslandRole.Owner); @@ -206,7 +207,7 @@ public class Scoreboard { .replace("%island_size", ChatColor.RED + "0").replace("%island_radius", ChatColor.RED + "0"); } - PlaceholderManager placeholderManager = skyblock.getPlaceholderManager(); + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); if (placeholderManager.isPlaceholderAPIEnabled()) { displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine); diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 1f94c4e2..194d39c3 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -26,7 +26,7 @@ import java.util.*; public class ScoreboardManager extends BukkitRunnable { private final static int VERSION = NMSUtil.getVersionNumber(); - private final SkyBlock skyblock; + private final SkyBlock plugin; private final Map scoreboardStorage = new HashMap<>(); private final PlayerDataManager playerDataManager; @@ -36,10 +36,10 @@ public class ScoreboardManager extends BukkitRunnable { private final List teamNames = new ArrayList<>(); private final List objectiveNames = new ArrayList<>(); - public ScoreboardManager(SkyBlock skyblock) { - this.skyblock = skyblock; - this.playerDataManager = skyblock.getPlayerDataManager(); - this.runTaskTimer(skyblock, 20, 40); + public ScoreboardManager(SkyBlock plugin) { + this.plugin = plugin; + this.playerDataManager = plugin.getPlayerDataManager(); + this.runTaskTimer(plugin, 20, 40); } @SuppressWarnings("deprecation") @@ -150,9 +150,9 @@ public class ScoreboardManager extends BukkitRunnable { public void updateScoreboards(boolean createNew) { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) return; for (Player all : Bukkit.getOnlinePlayers()) { @@ -164,15 +164,15 @@ public class ScoreboardManager extends BukkitRunnable { scoreboard = getScoreboard(all); else { if (createNew) { - scoreboard = new Scoreboard(skyblock, all); + scoreboard = new Scoreboard(plugin, all); store = true; } } if (scoreboard == null) continue; - IslandManager islandManager = skyblock.getIslandManager(); - Config language = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")); + IslandManager islandManager = plugin.getIslandManager(); + Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); Island island = islandManager.getIsland(all); if (island == null) { @@ -228,12 +228,12 @@ public class ScoreboardManager extends BukkitRunnable { } public void addPlayer(Player player){ - CooldownManager cooldownManager = skyblock.getCooldownManager(); - FileManager fileManager = skyblock.getFileManager(); - IslandManager islandManager = skyblock.getIslandManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + FileManager fileManager = plugin.getFileManager(); + IslandManager islandManager = plugin.getIslandManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); - Scoreboard scoreboard = new Scoreboard(skyblock, player); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); + Scoreboard scoreboard = new Scoreboard(plugin, player); Island island = islandManager.getIsland(player); if (island != null) { diff --git a/src/main/java/com/songoda/skyblock/sound/SoundManager.java b/src/main/java/com/songoda/skyblock/sound/SoundManager.java index 4f588acd..7c5a044e 100644 --- a/src/main/java/com/songoda/skyblock/sound/SoundManager.java +++ b/src/main/java/com/songoda/skyblock/sound/SoundManager.java @@ -12,15 +12,15 @@ import java.io.File; public class SoundManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; - public SoundManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public SoundManager(SkyBlock plugin) { + this.plugin = plugin; } public void playSound(CommandSender sender, Sound sound, float volume, float pitch) { if (sender instanceof Player) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Sound.Enable")) { @@ -31,7 +31,7 @@ public class SoundManager { } public void playSound(Location location, Sound sound, float volume, float pitch) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getBoolean("Sound.Enable")) { diff --git a/src/main/java/com/songoda/skyblock/stackable/Stackable.java b/src/main/java/com/songoda/skyblock/stackable/Stackable.java index 948b1665..d760fc0a 100644 --- a/src/main/java/com/songoda/skyblock/stackable/Stackable.java +++ b/src/main/java/com/songoda/skyblock/stackable/Stackable.java @@ -1,10 +1,11 @@ package com.songoda.skyblock.stackable; -import java.io.File; -import java.util.UUID; - import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; @@ -14,11 +15,8 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.metadata.FixedMetadataValue; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.utils.NumberUtil; - -import com.songoda.skyblock.utils.version.NMSUtil; +import java.io.File; +import java.util.UUID; public class Stackable { diff --git a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java index d429e4ff..ca83c253 100644 --- a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java +++ b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java @@ -1,40 +1,33 @@ package com.songoda.skyblock.stackable; -import java.io.File; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; +import java.io.File; +import java.util.*; public class StackableManager { // ToDO: Should pobably be a GUI for this - private final SkyBlock skyblock; + private final SkyBlock plugin; private Set stackableMaterials = EnumSet.noneOf(CompatibleMaterial.class); private Map stacks = new HashMap<>(); - public StackableManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public StackableManager(SkyBlock plugin) { + this.plugin = plugin; registerStackables(); } public void registerStackables() { - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "stackables.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "stackables.yml")); FileConfiguration configLoad = config.getFileConfiguration(); List stackableList = configLoad.getStringList("Stackables"); @@ -68,13 +61,13 @@ public class StackableManager { @SuppressWarnings("deprecation") public void loadSavedStackables() { - final File path = new File(skyblock.getDataFolder(), "island-data"); + final File path = new File(plugin.getDataFolder(), "island-data"); final File[] files = path.listFiles(); if (files == null) return; for (File file : files) { - final FileConfiguration config = skyblock.getFileManager().getConfig(file).getFileConfiguration(); + final FileConfiguration config = plugin.getFileManager().getConfig(file).getFileConfiguration(); ConfigurationSection stackableSection = config.getConfigurationSection("Stackables"); diff --git a/src/main/java/com/songoda/skyblock/structure/Structure.java b/src/main/java/com/songoda/skyblock/structure/Structure.java index 23523534..ca09b8e6 100644 --- a/src/main/java/com/songoda/skyblock/structure/Structure.java +++ b/src/main/java/com/songoda/skyblock/structure/Structure.java @@ -1,7 +1,6 @@ package com.songoda.skyblock.structure; import com.songoda.core.compatibility.CompatibleMaterial; - import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/songoda/skyblock/structure/StructureManager.java b/src/main/java/com/songoda/skyblock/structure/StructureManager.java index ba2ef219..8bf54871 100644 --- a/src/main/java/com/songoda/skyblock/structure/StructureManager.java +++ b/src/main/java/com/songoda/skyblock/structure/StructureManager.java @@ -3,7 +3,6 @@ package com.songoda.skyblock.structure; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager.Config; - import org.bukkit.configuration.file.FileConfiguration; import java.io.File; @@ -15,8 +14,8 @@ public class StructureManager { public List knownStructures; private List structureStorage = new ArrayList<>(); - public StructureManager(SkyBlock skyblock) { - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "structures.yml")); + public StructureManager(SkyBlock plugin) { + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "structures.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString("Structures") != null) { @@ -32,7 +31,7 @@ public class StructureManager { } } - String structureFile = null, overworldFile = null, netherFile = null, endFile = null; + String structureFile, overworldFile = null, netherFile = null, endFile = null; if (configLoad.getString("Structures." + structureList + ".File.Overworld") == null && configLoad.getString("Structures." + structureList + ".File.Nether") == null diff --git a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java index f3897214..ca9c76d7 100644 --- a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java @@ -2,30 +2,19 @@ package com.songoda.skyblock.tasks; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.compatibility.ServerVersion; -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.version.NMSUtil; -import com.songoda.skyblock.utils.world.LocationUtil; -import com.songoda.skyblock.visit.Visit; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.*; import org.bukkit.scheduler.BukkitRunnable; import java.io.File; -import java.util.ArrayList; -import java.util.List; public class MobNetherWaterTask extends BukkitRunnable { diff --git a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java index 9a0f5814..b01e5f78 100644 --- a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java +++ b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java @@ -16,13 +16,13 @@ import java.util.*; public class UpgradeManager { - private SkyBlock skyblock; + private SkyBlock plugin; private Map> upgradeStorage = new HashMap<>(); - public UpgradeManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public UpgradeManager(SkyBlock plugin) { + this.plugin = plugin; - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "upgrades.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "upgrades.yml")); FileConfiguration configLoad = config.getFileConfiguration(); for (Upgrade.Type typeList : Upgrade.Type.values()) { @@ -83,7 +83,7 @@ public class UpgradeManager { public void addUpgrade(Upgrade.Type type, int value) { List upgrades = new ArrayList<>(); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "upgrades.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "upgrades.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString("Upgrades.Size") != null) { @@ -133,7 +133,7 @@ public class UpgradeManager { List upgrades = upgradeStorage.get(type); upgrades.remove(upgradeList); - Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "upgrades.yml")); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "upgrades.yml")); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Upgrades.Size", null); @@ -176,8 +176,8 @@ public class UpgradeManager { } private void applyUpgrades() { - IslandManager islandManager = skyblock.getIslandManager(); - UpgradeManager upgradeManager = skyblock.getUpgradeManager(); + IslandManager islandManager = plugin.getIslandManager(); + UpgradeManager upgradeManager = plugin.getUpgradeManager(); for (Player player : Bukkit.getOnlinePlayers()) { Island island = islandManager.getIslandAtLocation(player.getLocation()); diff --git a/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java b/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java index 63698c53..b352778a 100644 --- a/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java +++ b/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java @@ -1,5 +1,12 @@ package com.songoda.skyblock.usercache; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.utils.player.NameFetcher; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; + import java.io.File; import java.io.IOException; import java.util.HashSet; @@ -7,27 +14,19 @@ import java.util.Set; import java.util.UUID; import java.util.logging.Level; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.FileConfiguration; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.utils.player.NameFetcher; - public final class UserCacheManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private final Config config; - public UserCacheManager(SkyBlock skyblock) { - this.skyblock = skyblock; - this.config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "usercache.yml")); + public UserCacheManager(SkyBlock plugin) { + this.plugin = plugin; + this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "usercache.yml")); - final FileManager fileManager = skyblock.getFileManager(); - final File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); + final FileManager fileManager = plugin.getFileManager(); + final File configFile = new File(plugin.getDataFolder().toString() + "/island-data"); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> { + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { if (configFile.exists()) { int usersIgnored = 0; @@ -129,7 +128,7 @@ public final class UserCacheManager { } public void saveAsync() { - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> save()); + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> save()); } public synchronized void save() { diff --git a/src/main/java/com/songoda/skyblock/utils/Compression.java b/src/main/java/com/songoda/skyblock/utils/Compression.java index 53c1027a..9ddbf1be 100644 --- a/src/main/java/com/songoda/skyblock/utils/Compression.java +++ b/src/main/java/com/songoda/skyblock/utils/Compression.java @@ -1,10 +1,6 @@ package com.songoda.skyblock.utils; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; +import java.io.*; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; diff --git a/src/main/java/com/songoda/skyblock/utils/Reflections.java b/src/main/java/com/songoda/skyblock/utils/Reflections.java index db4fe5e2..07cb3028 100644 --- a/src/main/java/com/songoda/skyblock/utils/Reflections.java +++ b/src/main/java/com/songoda/skyblock/utils/Reflections.java @@ -1,14 +1,14 @@ package com.songoda.skyblock.utils; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + public class Reflections { public static String cbVer() { diff --git a/src/main/java/com/songoda/skyblock/utils/StringUtil.java b/src/main/java/com/songoda/skyblock/utils/StringUtil.java index 7f3671a3..65e60847 100644 --- a/src/main/java/com/songoda/skyblock/utils/StringUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/StringUtil.java @@ -1,10 +1,10 @@ package com.songoda.skyblock.utils; +import net.md_5.bungee.api.ChatColor; + import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.md_5.bungee.api.ChatColor; - public final class StringUtil { public static String capatilizeUppercaseLetters(String string) { diff --git a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java index c608c4da..b1555f3d 100644 --- a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java @@ -1,11 +1,10 @@ package com.songoda.skyblock.utils.item; - + import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Material; -import org.bukkit.Server; import org.bukkit.inventory.ItemStack; import java.io.*; diff --git a/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java b/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java index f1526be5..4ebaff7c 100644 --- a/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java +++ b/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java @@ -1,20 +1,15 @@ package com.songoda.skyblock.utils.item; -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.utils.StringUtil; +import com.songoda.skyblock.utils.item.nInventoryUtil.ClickEvent; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.utils.StringUtil; -import com.songoda.skyblock.utils.item.nInventoryUtil.ClickEvent; +import java.io.File; +import java.util.*; public final class MenuClickRegistry { @@ -72,7 +67,7 @@ public final class MenuClickRegistry { public static interface MenuExecutor { - void onClick(SkyBlock skyblock, Player clicker, ClickEvent e); + void onClick(SkyBlock plugin, Player clicker, ClickEvent e); } diff --git a/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java b/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java index 2c4c3cb7..8ce7a12f 100644 --- a/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java @@ -3,8 +3,6 @@ package com.songoda.skyblock.utils.item; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.skyblock.utils.version.NMSUtil; -import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; diff --git a/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java b/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java index 9d18a20e..7f18116e 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java +++ b/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java @@ -1,13 +1,13 @@ package com.songoda.skyblock.utils.player; +import com.google.gson.Gson; + import java.io.IOException; import java.net.URL; import java.util.Date; import java.util.Scanner; import java.util.UUID; -import com.google.gson.Gson; - public final class NameFetcher { private NameFetcher() { diff --git a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java index 3ecdd7af..9ee02fde 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java +++ b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java @@ -23,8 +23,8 @@ public class OfflinePlayer { private final int playtime; public OfflinePlayer(String name) { - SkyBlock skyblock = SkyBlock.getInstance(); - UserCacheManager userCacheManager = skyblock.getUserCacheManager(); + SkyBlock plugin = SkyBlock.getInstance(); + UserCacheManager userCacheManager = plugin.getUserCacheManager(); bukkitOfflinePlayer = Bukkit.getServer().getOfflinePlayer(name); @@ -38,7 +38,7 @@ public class OfflinePlayer { this.name = bukkitOfflinePlayer.getName(); FileConfiguration configLoad = YamlConfiguration.loadConfiguration( - new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); + new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); texture = new String[]{configLoad.getString("Texture.Signature"), configLoad.getString("Texture.Value")}; playtime = configLoad.getInt("Statistics.Island.Playtime"); memberSince = configLoad.getString("Statistics.Island.Join"); @@ -50,8 +50,8 @@ public class OfflinePlayer { } public OfflinePlayer(UUID uuid) { - SkyBlock skyblock = SkyBlock.getInstance(); - UserCacheManager userCacheManager = skyblock.getUserCacheManager(); + SkyBlock plugin = SkyBlock.getInstance(); + UserCacheManager userCacheManager = plugin.getUserCacheManager(); bukkitOfflinePlayer = Bukkit.getServer().getOfflinePlayer(uuid); @@ -63,7 +63,7 @@ public class OfflinePlayer { } FileConfiguration configLoad = YamlConfiguration.loadConfiguration( - new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); + new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); texture = new String[]{configLoad.getString("Texture.Signature"), configLoad.getString("Texture.Value")}; playtime = configLoad.getInt("Statistics.Island.Playtime"); memberSince = configLoad.getString("Statistics.Island.Join"); diff --git a/src/main/java/com/songoda/skyblock/utils/player/PlayerUtil.java b/src/main/java/com/songoda/skyblock/utils/player/PlayerUtil.java index b52a8cc8..d4a471df 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/PlayerUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/player/PlayerUtil.java @@ -1,10 +1,10 @@ package com.songoda.skyblock.utils.player; -import java.util.Set; - import org.bukkit.entity.Player; import org.bukkit.permissions.PermissionAttachmentInfo; +import java.util.Set; + public final class PlayerUtil { private PlayerUtil() { diff --git a/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java b/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java index 8813d0ac..dbc16a54 100644 --- a/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java @@ -15,10 +15,6 @@ import com.songoda.skyblock.utils.world.block.BlockDegreesType; import com.songoda.skyblock.utils.world.block.BlockUtil; import com.songoda.skyblock.utils.world.entity.EntityData; import com.songoda.skyblock.utils.world.entity.EntityUtil; - -import java.io.FileInputStream; -import java.util.Base64; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -30,10 +26,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Base64; import java.util.LinkedHashMap; import java.util.List; import java.util.logging.Level; @@ -203,14 +201,14 @@ public final class StructureUtil { } public static ItemStack getTool() throws Exception { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - ItemStack is = new ItemStack(Material.valueOf(fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Admin.Structure.Selector"))); + ItemStack is = new ItemStack(Material.valueOf(fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Admin.Structure.Selector"))); ItemMeta im = is.getItemMeta(); im.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Structure.Tool.Item.Displayname"))); 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 04bfb6b2..5b11fc45 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -14,7 +14,10 @@ import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.block.BlockDegreesType; import com.songoda.skyblock.world.WorldManager; import io.papermc.lib.PaperLib; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -26,7 +29,6 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Random; -import java.util.concurrent.CompletableFuture; import java.util.logging.Level; public final class LocationUtil { @@ -276,13 +278,13 @@ public final class LocationUtil { } public static void teleportPlayerToSpawn(Player player) { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")); if (config.getFileConfiguration().getString("Location.Spawn") == null) { Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set."); @@ -303,7 +305,7 @@ public final class LocationUtil { } } - Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + Bukkit.getServer().getScheduler().runTask(plugin, () -> { PaperLib.teleportAsync(player, spawnLocation); player.setFallDistance(0.0F); }); @@ -311,11 +313,11 @@ public final class LocationUtil { } public static Location getSpawnLocation() { - SkyBlock skyblock = SkyBlock.getInstance(); + SkyBlock plugin = SkyBlock.getInstance(); - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")); if (config.getFileConfiguration().getString("Location.Spawn") != null) { Location location = fileManager.getLocation(config, "Location.Spawn", true); diff --git a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java b/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java index 11be9ac7..12f9c9a1 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java +++ b/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java @@ -1,16 +1,14 @@ package com.songoda.skyblock.utils.world; +import com.songoda.core.compatibility.ServerVersion; +import com.songoda.skyblock.utils.version.NMSUtil; +import org.bukkit.Location; +import org.bukkit.entity.Player; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import com.songoda.core.compatibility.ServerVersion; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import com.songoda.skyblock.utils.version.NMSUtil; - public final class WorldBorder { private static Class packetPlayOutWorldBorder, packetPlayOutWorldBorderEnumClass, worldBorderClass, diff --git a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java index eb555348..14d093a0 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java @@ -1,7 +1,6 @@ package com.songoda.skyblock.utils.world.entity; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.utils.item.ItemStackUtil; import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.world.block.BlockDegreesType; diff --git a/src/main/java/com/songoda/skyblock/visit/Visit.java b/src/main/java/com/songoda/skyblock/visit/Visit.java index 958f17f0..a360b87d 100644 --- a/src/main/java/com/songoda/skyblock/visit/Visit.java +++ b/src/main/java/com/songoda/skyblock/visit/Visit.java @@ -15,7 +15,7 @@ import java.util.*; public class Visit { - private final SkyBlock skyblock; + private final SkyBlock plugin; private final IslandLevel islandLevel; private UUID islandOwnerUUID; private String islandOwnerName; @@ -28,9 +28,9 @@ public class Visit { private IslandStatus status; - protected Visit(SkyBlock skyblock, UUID islandOwnerUUID, IslandLocation[] islandLocations, int islandSize, + protected Visit(SkyBlock plugin, UUID islandOwnerUUID, IslandLocation[] islandLocations, int islandSize, int islandMembers, double islandBankBalance, int safeLevel, IslandLevel islandLevel, List islandSignature, IslandStatus status) { - this.skyblock = skyblock; + this.plugin = plugin; this.islandOwnerUUID = islandOwnerUUID; this.islandLocations = islandLocations; this.islandSize = islandSize; @@ -110,8 +110,8 @@ public class Visit { public Set getVisitors() { Set islandVisitors = new HashSet<>(); - for (String islandVisitorList : skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + for (String islandVisitorList : plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration().getStringList("Visitors")) { islandVisitors.add(UUID.fromString(islandVisitorList)); @@ -122,8 +122,8 @@ public class Visit { public void addVisitor(UUID uuid) { List islandVisitors = new ArrayList<>(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration(); @@ -137,8 +137,8 @@ public class Visit { public void removeVisitor(UUID uuid) { List islandVisitors = new ArrayList<>(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration(); @@ -157,8 +157,8 @@ public class Visit { public Set getVoters() { Set islandVoters = new HashSet<>(); - for (String islandVisitorList : skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + for (String islandVisitorList : plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration().getStringList("Voters")) { islandVoters.add(UUID.fromString(islandVisitorList)); @@ -169,8 +169,8 @@ public class Visit { public void addVoter(UUID uuid) { List islandVoters = new ArrayList<>(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration(); @@ -182,8 +182,8 @@ public class Visit { public void removeVoter(UUID uuid) { List islandVoters = new ArrayList<>(); - FileConfiguration configLoad = skyblock.getFileManager() - .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration(); @@ -205,12 +205,12 @@ public class Visit { } public Ban getBan() { - return skyblock.getBanManager().getIsland(getOwnerUUID()); + return plugin.getBanManager().getIsland(getOwnerUUID()); } public void save() { - FileManager.Config config = skyblock.getFileManager().getConfig(new File( - new File(skyblock.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File( + new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")); try { config.getFileConfiguration().save(config.getFile()); diff --git a/src/main/java/com/songoda/skyblock/visit/VisitManager.java b/src/main/java/com/songoda/skyblock/visit/VisitManager.java index 11d7fffe..35aacd2a 100644 --- a/src/main/java/com/songoda/skyblock/visit/VisitManager.java +++ b/src/main/java/com/songoda/skyblock/visit/VisitManager.java @@ -18,11 +18,11 @@ import java.util.concurrent.ConcurrentHashMap; public class VisitManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private HashMap visitStorage = new HashMap<>(); - public VisitManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public VisitManager(SkyBlock plugin) { + this.plugin = plugin; loadIslands(); } @@ -36,12 +36,12 @@ public class VisitManager { } public void loadIslands() { - WorldManager worldManager = skyblock.getWorldManager(); - FileManager fileManager = skyblock.getFileManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager fileManager = plugin.getFileManager(); - if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Visitor.Unload")) { - File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); + File configFile = new File(plugin.getDataFolder().toString() + "/island-data"); if (!configFile.exists()) return; @@ -106,7 +106,7 @@ public class VisitManager { configLoad.getStringList("Members").size() + configLoad.getStringList("Operators").size() + 1, configLoad.getDouble("Bank.Balance", 0), - getIslandSafeLevel(islandOwnerUUID), new IslandLevel(islandOwnerUUID, skyblock), + getIslandSafeLevel(islandOwnerUUID), new IslandLevel(islandOwnerUUID, plugin), islandSignature, status); } catch (Exception e) { @@ -123,13 +123,13 @@ public class VisitManager { visit.getLevel().setOwnerUUID(uuid2); visit.save(); - File oldVisitDataFile = new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + File oldVisitDataFile = new File(new File(plugin.getDataFolder().toString() + "/visit-data"), uuid1.toString() + ".yml"); - File newVisitDataFile = new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + File newVisitDataFile = new File(new File(plugin.getDataFolder().toString() + "/visit-data"), uuid2.toString() + ".yml"); - skyblock.getFileManager().unloadConfig(oldVisitDataFile); - skyblock.getFileManager().unloadConfig(newVisitDataFile); + plugin.getFileManager().unloadConfig(oldVisitDataFile); + plugin.getFileManager().unloadConfig(newVisitDataFile); oldVisitDataFile.renameTo(newVisitDataFile); @@ -138,14 +138,14 @@ public class VisitManager { } public void removeVisitors(Island island, VisitManager.Removal removal) { - MessageManager messageManager = skyblock.getMessageManager(); - SoundManager soundManager = skyblock.getSoundManager(); - FileManager fileManager = skyblock.getFileManager(); + MessageManager messageManager = plugin.getMessageManager(); + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - for (UUID visitorList : skyblock.getIslandManager().getVisitorsAtIsland(island)) { + for (UUID visitorList : plugin.getIslandManager().getVisitorsAtIsland(island)) { Player targetPlayer = Bukkit.getServer().getPlayer(visitorList); LocationUtil.teleportPlayerToSpawn(targetPlayer); @@ -157,13 +157,13 @@ public class VisitManager { } public int getIslandSafeLevel(UUID islandOwnerUUID) { - FileManager fileManager = skyblock.getFileManager(); + FileManager fileManager = plugin.getFileManager(); FileManager.Config settingDataConfig = new FileManager.Config(fileManager, - new File(skyblock.getDataFolder().toString() + "/setting-data", islandOwnerUUID.toString() + ".yml")); + new File(plugin.getDataFolder().toString() + "/setting-data", islandOwnerUUID.toString() + ".yml")); FileConfiguration settingDataConfigLoad = settingDataConfig.getFileConfiguration(); - FileManager.Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration(); int safeLevel = 0; @@ -216,7 +216,7 @@ public class VisitManager { public void createIsland(UUID islandOwnerUUID, IslandLocation[] islandLocations, int islandSize, int islandMembers, double islandBankBalance, int safeLevel, IslandLevel islandLevel, List islandSignature, IslandStatus status) { - visitStorage.put(islandOwnerUUID, new Visit(skyblock, islandOwnerUUID, islandLocations, islandSize, + visitStorage.put(islandOwnerUUID, new Visit(plugin, islandOwnerUUID, islandLocations, islandSize, islandMembers, islandBankBalance, safeLevel, islandLevel, islandSignature, status)); } @@ -232,8 +232,8 @@ public class VisitManager { public void unloadIsland(UUID islandOwnerUUID) { if (hasIsland(islandOwnerUUID)) { - skyblock.getFileManager() - .unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + plugin.getFileManager() + .unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")); visitStorage.remove(islandOwnerUUID); } @@ -241,8 +241,8 @@ public class VisitManager { public void deleteIsland(UUID islandOwnerUUID) { if (hasIsland(islandOwnerUUID)) { - skyblock.getFileManager() - .deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/visit-data"), + plugin.getFileManager() + .deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")); visitStorage.remove(islandOwnerUUID); } diff --git a/src/main/java/com/songoda/skyblock/visit/VisitTask.java b/src/main/java/com/songoda/skyblock/visit/VisitTask.java index e79d4560..97638198 100644 --- a/src/main/java/com/songoda/skyblock/visit/VisitTask.java +++ b/src/main/java/com/songoda/skyblock/visit/VisitTask.java @@ -1,9 +1,8 @@ package com.songoda.skyblock.visit; -import org.bukkit.scheduler.BukkitRunnable; - import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; +import org.bukkit.scheduler.BukkitRunnable; public class VisitTask extends BukkitRunnable { diff --git a/src/main/java/com/songoda/skyblock/world/WorldManager.java b/src/main/java/com/songoda/skyblock/world/WorldManager.java index ec140252..c2067ef3 100644 --- a/src/main/java/com/songoda/skyblock/world/WorldManager.java +++ b/src/main/java/com/songoda/skyblock/world/WorldManager.java @@ -12,20 +12,20 @@ import java.util.logging.Level; public class WorldManager { - private final SkyBlock skyblock; + private final SkyBlock plugin; private org.bukkit.World normalWorld; private org.bukkit.World netherWorld; private org.bukkit.World endWorld; - public WorldManager(SkyBlock skyblock) { - this.skyblock = skyblock; + public WorldManager(SkyBlock plugin) { + this.plugin = plugin; loadWorlds(); } public void loadWorlds() { - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); String normalWorldName = configLoad.getString("Island.World.Normal.Name"); @@ -47,21 +47,21 @@ public class WorldManager { Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'."); normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(normalWorldEnvironment).generator(new VoidGenerator()).createWorld(); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(normalWorldName, normalWorldEnvironment)); + Bukkit.getServer().getScheduler().runTask(plugin, () -> registerMultiverse(normalWorldName, normalWorldEnvironment)); } if (netherWorld == null && netherWorldEnabled) { Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'."); netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(netherWorldEnvironment).generator(new VoidGenerator()).createWorld(); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(netherWorldName, netherWorldEnvironment)); + Bukkit.getServer().getScheduler().runTask(plugin, () -> registerMultiverse(netherWorldName, netherWorldEnvironment)); } if (endWorld == null && endWorldEnabled) { Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + endWorldName + "'."); endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(endWorldEnvironment).generator(new VoidGenerator()).createWorld(); - Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(endWorldName, endWorldEnvironment)); + Bukkit.getServer().getScheduler().runTask(plugin, () -> registerMultiverse(endWorldName, endWorldEnvironment)); } if (normalWorld != null) @@ -76,8 +76,8 @@ public class WorldManager { public void registerMultiverse(String worldName, World.Environment environment) { if (Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core") != null) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldName + " " + environment.name().toLowerCase() + " -g " + skyblock.getName()); - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv modify set generator " + skyblock.getName() + " " + worldName); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldName + " " + environment.name().toLowerCase() + " -g " + plugin.getName()); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv modify set generator " + plugin.getName() + " " + worldName); } } diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index ccfb8400..fb7b3ea7 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -4,11 +4,7 @@ import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandWorld; -import io.papermc.lib.PaperLib; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Biome; @@ -29,12 +25,11 @@ public class VoidGenerator extends ChunkGenerator { public @Nonnull ChunkData generateChunkData(@Nonnull World world, @Nonnull Random random, int chunkX, int chunkZ, @Nonnull BiomeGrid biomeGrid) { final ChunkData chunkData = createChunkData(world); - final SkyBlock skyblock = SkyBlock.getInstance(); - final Configuration configLoad = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration(); + final SkyBlock plugin = SkyBlock.getInstance(); + final Configuration configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); - Biome biome = CompatibleBiome.valueOf(configLoad // 2D for the moment - .getString("Island.Biome.Default.Type").toUpperCase()).getBiome(); + Biome biome = CompatibleBiome.valueOf(configLoad.getString("Island.Biome.Default.Type").toUpperCase()).getBiome(); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there setChunkBiome3D(biome, biomeGrid, world); From 93974a4291ba8d01348801881aad34a25f89a25c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 09:17:09 +0200 Subject: [PATCH 181/366] Finishing renaming variables --- .../com/songoda/skyblock/menus/admin/Upgrade.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java index 6a255052..d541b949 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java @@ -921,7 +921,7 @@ public class Upgrade { size); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); } @@ -963,7 +963,7 @@ public class Upgrade { if (event.getClick() == ClickType.LEFT) { soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - Bukkit.getServer().getScheduler().runTaskLater(skyblock, + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { @@ -1049,14 +1049,14 @@ public class Upgrade { .get(tier).setValue(size); fileManager .getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "upgrades.yml")) .getFileConfiguration() .set("Upgrades.Members." + tier + ".Value", size); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); } @@ -1131,7 +1131,7 @@ public class Upgrade { 1.0F); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); return; @@ -1146,14 +1146,14 @@ public class Upgrade { .get(tier).setCost(cost); fileManager .getConfig( - new File(skyblock.getDataFolder(), + new File(plugin.getDataFolder(), "upgrades.yml")) .getFileConfiguration() .set("Upgrades.Members." + tier + ".Cost", cost); Bukkit.getServer().getScheduler() - .runTaskLater(skyblock, + .runTaskLater(plugin, () -> open(player), 1L); } From d078b5e2d42a960a5049943c654b4d103fbbd044 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 13:31:42 +0200 Subject: [PATCH 182/366] Make Manager constructor public --- src/main/java/com/songoda/skyblock/manager/Manager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/manager/Manager.java b/src/main/java/com/songoda/skyblock/manager/Manager.java index 34c8e621..90ac07d7 100644 --- a/src/main/java/com/songoda/skyblock/manager/Manager.java +++ b/src/main/java/com/songoda/skyblock/manager/Manager.java @@ -6,7 +6,7 @@ public abstract class Manager { protected SkyBlock plugin; - Manager(SkyBlock plugin) { + public Manager(SkyBlock plugin) { this.plugin = plugin; } From f4a640bcf947f0fc37eb5d2f21d746be4e5cada3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 14:38:05 +0200 Subject: [PATCH 183/366] Optimize FallBreak listener --- .../songoda/skyblock/listeners/FallBreak.java | 126 +++++++++++------- 1 file changed, 75 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java index 8f157433..47a1af87 100644 --- a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java +++ b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java @@ -1,79 +1,103 @@ package com.songoda.skyblock.listeners; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.world.WorldManager; +import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; import java.io.File; -import java.util.List; +import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; public class FallBreak implements Listener { private final SkyBlock plugin; + + private final Set fallingBlocks; public FallBreak(SkyBlock plugin) { this.plugin = plugin; + this.fallingBlocks = new HashSet<>(); + + Bukkit.getScheduler().runTaskTimer(plugin, () -> { + if(!fallingBlocks.isEmpty()) { + int counter = 0; + IslandManager islandManager = plugin.getIslandManager(); + WorldManager worldManager = plugin.getWorldManager(); + FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + Iterator iterator = fallingBlocks.iterator(); + while(iterator.hasNext()) { + FallingBlock ent = iterator.next(); + if(ent.isDead()) { + if (worldManager.isIslandWorld(ent.getLocation().getWorld()) && configLoad.getBoolean("Island.Block.Level.Enable")) { + Island island = islandManager.getIslandAtLocation(ent.getLocation()); + + if (island != null) { + CompatibleMaterial material = null; + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { + material = CompatibleMaterial.getMaterial(ent.getBlockData().getMaterial()); + } else { + try { + material = CompatibleMaterial.getMaterial((Material) ent.getClass().getMethod("getMaterial").invoke(ent)); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + if (material != null) { + IslandLevel level = island.getLevel(); + + if (level.hasMaterial(material.name())) { + long materialAmount = level.getMaterialAmount(material.name()); + + if (materialAmount <= 1) + level.removeMaterial(material.name()); + else + level.setMaterialAmount(material.name(), materialAmount - 1); + } + } + } + } + iterator.remove(); + } + if(++counter > 50) { // Limit 50 checks per tick + break; + } + } + } + }, 2L, 1L); } - /* - * Removes island points when a block is broken by falling. - * Checks for items spawning (because there's no other event called) - * Then looks for the falling block (in a radius of 1), which should still be present on the event call. - * - * Couldn't find any other way to do this. - * */ + @EventHandler(ignoreCancelled = true) + public void onSpawnFallingBlock(EntitySpawnEvent event) { + if(event.getEntity() instanceof FallingBlock) { + WorldManager worldManager = plugin.getWorldManager(); + if (worldManager.isIslandWorld(event.getEntity().getLocation().getWorld())) { + fallingBlocks.add((FallingBlock) event.getEntity()); + } + } + } + @EventHandler - public void onItemSpawn(ItemSpawnEvent event) { - - // Basic world and island checks - IslandManager islandManager = plugin.getIslandManager(); - WorldManager worldManager = plugin.getWorldManager(); - - if (!worldManager.isIslandWorld(event.getEntity().getWorld())) return; - - FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (!configLoad.getBoolean("Island.Block.Level.Enable")) return; - - Island island = islandManager.getIslandAtLocation(event.getLocation()); - - if (island == null) return; - - // Get entities in radius and look for our block - List entities = event.getEntity().getNearbyEntities(1, 1, 1); - - for (Entity e : entities) { - if (!(e instanceof FallingBlock)) continue; - - FallingBlock fallingBlock = (FallingBlock) e; - - // Get the block material - CompatibleMaterial material = CompatibleMaterial.getMaterial(fallingBlock.getMaterial()); - - if (material == null) continue; - - // Update count in the level - IslandLevel level = island.getLevel(); - - if (!level.hasMaterial(material.name())) continue; - - long materialAmount = level.getMaterialAmount(material.name()); - - if (materialAmount <= 1) - level.removeMaterial(material.name()); - else - level.setMaterialAmount(material.name(), materialAmount - 1); + public void onDespawnFallingBlock(EntityChangeBlockEvent event) { + if(event.getEntity() instanceof FallingBlock && !event.getTo().equals(CompatibleMaterial.AIR.getMaterial())) { + fallingBlocks.remove((FallingBlock) event.getEntity()); } } } \ No newline at end of file From 796d3ce6b04d863c5deb8d1f4ce855a3ee923a61 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 17:07:17 +0200 Subject: [PATCH 184/366] Fix for biome update in 1.8.8 --- .../songoda/skyblock/biome/BiomeManager.java | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 3c3d407c..f550450e 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -9,6 +9,7 @@ import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.Chunk; +import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -21,6 +22,8 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; public class BiomeManager { + + final ServerVersion ASYNC_OBFUSCATOR_VERSION = ServerVersion.V1_9; private final SkyBlock plugin; private final List updatingIslands; @@ -59,10 +62,15 @@ public class BiomeManager { ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunk, syncChunk) -> { Chunk chunk = asyncChunk.join(); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(island, biome, chunk); // 2D for the moment + setChunkBiome3D(biome, chunk); // 2D for the moment } else { - setChunkBiome2D(island, biome, chunk); + try { + setChunkBiome2D(biome, chunk); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } } + updateBiomePacket(island, chunk); progress.getAndIncrement(); @@ -92,9 +100,16 @@ public class BiomeManager { int progress = 0; for(Chunk chunk : syncChunks){ if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(island, biome, chunk); // 2D for the moment + setChunkBiome3D(biome, chunk); // 2D for the moment } else { - setChunkBiome2D(island, biome, chunk); + try { + setChunkBiome2D(biome, chunk); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } + } + if(ServerVersion.isServerVersionAtLeast(ASYNC_OBFUSCATOR_VERSION)) { + updateBiomePacket(island, chunk); } progress++; @@ -113,6 +128,11 @@ public class BiomeManager { } } } + if(ServerVersion.isServerVersionBelow(ASYNC_OBFUSCATOR_VERSION)) { + for(Chunk chunk : syncChunks){ + updateBiomePacket(island, chunk); + } + } }); }, (island1 -> { removeUpdatingIsland(island1); @@ -123,17 +143,16 @@ public class BiomeManager { } } - private void setChunkBiome2D(Island island, Biome biome, Chunk chunk) { + private void setChunkBiome2D(Biome biome, Chunk chunk) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){ for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){ - chunk.getWorld().setBiome(x, z, biome); + World.class.getMethod("setBiome", int.class, int.class, Biome.class).invoke(chunk.getWorld(), x, z, biome); } } - updateBiomePacket(island, chunk); } // Do not use - Too laggy - private void setChunkBiome3D(Island island, Biome biome, Chunk chunk) { + private void setChunkBiome3D(Biome biome, Chunk chunk) { for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){ for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){ for(int y = 0; y < chunk.getWorld().getMaxHeight(); ++y) { @@ -141,7 +160,6 @@ public class BiomeManager { } } } - updateBiomePacket(island, chunk); } From f98719d457bc35805c4d94f7c81e2e35d0de2ee7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 18:05:30 +0200 Subject: [PATCH 185/366] Fix error with anti xray in 1.8 --- .../java/com/songoda/skyblock/biome/BiomeManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index f550450e..98e9018b 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -129,9 +129,11 @@ public class BiomeManager { } } if(ServerVersion.isServerVersionBelow(ASYNC_OBFUSCATOR_VERSION)) { - for(Chunk chunk : syncChunks){ - updateBiomePacket(island, chunk); - } + Bukkit.getScheduler().runTask(plugin, () -> { + for(Chunk chunk : syncChunks){ + updateBiomePacket(island, chunk); + } + }); } }); }, (island1 -> { From 0adf61973780bc247e41220889a047ff73b9d28e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 18:07:58 +0200 Subject: [PATCH 186/366] Smal changes to gui biome --- .../songoda/skyblock/gui/biome/GuiBiome.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java index 1e8abf8d..a97efe22 100644 --- a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java @@ -20,6 +20,7 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.Bukkit; +import org.bukkit.block.Biome; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -94,21 +95,28 @@ public class GuiBiome extends Gui { List biomes = new ArrayList<>(); for(CompatibleBiome biome : CompatibleBiome.getCompatibleBiomes()) { if(biome.isCompatible()){ + try { // Hotfix for core misconfiguration + biome.getBiome(); + } catch (IllegalArgumentException ex) { + continue; + } BiomeIcon icon = new BiomeIcon(plugin, biome); - if(!icon.permission || player.hasPermission("fabledskyblock.biome." + biome.name().toLowerCase())){ - switch(world){ + if (icon.biome != null && + (!icon.permission || + player.hasPermission("fabledskyblock.biome." + biome.name().toLowerCase()))) { + switch (world) { case Normal: - if(icon.normal){ + if (icon.normal) { biomes.add(icon); } break; case Nether: - if(icon.nether){ + if (icon.nether) { biomes.add(icon); } break; case End: - if(icon.end){ + if (icon.end) { biomes.add(icon); } break; @@ -118,10 +126,10 @@ public class GuiBiome extends Gui { } if(biomes.size() > 0){ - biomes.sort(Comparator.comparing(m -> m.biome)); - + biomes.sort(Comparator.comparing(m -> m.biome.name())); + this.pages = (int) Math.max(1, Math.ceil((double) biomes.size() / 27d)); - + if (page != 1) setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Last.Displayname"))), @@ -129,7 +137,7 @@ public class GuiBiome extends Gui { page--; paint(); }); - + if (page != pages) setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, TextUtils.formatText(languageLoad.getString("Menu.Biome.Item.Next.Displayname"))), @@ -145,7 +153,11 @@ public class GuiBiome extends Gui { continue; } BiomeIcon icon = biomes.get(current + i); - if (icon == null) continue; + if (icon == null || + icon.biome == null || + icon.biome.getBiome() == null) { + continue; + } if(icon.biome.getBiome().equals(island.getBiome())){ icon.enchant(); From 2812c6d07d60916a5df56d18bdeb86f988e42e42 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 18:37:52 +0200 Subject: [PATCH 187/366] Fix for FallBreak not working on old versions --- .../songoda/skyblock/listeners/FallBreak.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java index 47a1af87..b3b9ba1a 100644 --- a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java +++ b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java @@ -83,21 +83,18 @@ public class FallBreak implements Listener { } }, 2L, 1L); } - - @EventHandler(ignoreCancelled = true) - public void onSpawnFallingBlock(EntitySpawnEvent event) { + + @EventHandler + public void onFallingBlockModify(EntityChangeBlockEvent event) { if(event.getEntity() instanceof FallingBlock) { WorldManager worldManager = plugin.getWorldManager(); if (worldManager.isIslandWorld(event.getEntity().getLocation().getWorld())) { - fallingBlocks.add((FallingBlock) event.getEntity()); + if (!event.getTo().equals(CompatibleMaterial.AIR.getMaterial())){ + fallingBlocks.remove((FallingBlock) event.getEntity()); + } else if(!event.isCancelled()) { + fallingBlocks.add((FallingBlock) event.getEntity()); + } } } } - - @EventHandler - public void onDespawnFallingBlock(EntityChangeBlockEvent event) { - if(event.getEntity() instanceof FallingBlock && !event.getTo().equals(CompatibleMaterial.AIR.getMaterial())) { - fallingBlocks.remove((FallingBlock) event.getEntity()); - } - } } \ No newline at end of file From 2a0dc9396f15e97045c62c59dec61718865cc18f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 18:56:31 +0200 Subject: [PATCH 188/366] Fix for challenges with per-island true --- .../challenge/player/PlayerManager.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) 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 fff46221..7ee489b2 100644 --- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java +++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java @@ -9,6 +9,7 @@ import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.Island; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -41,8 +42,12 @@ public class PlayerManager { public HashMap getPlayer(UUID uuid) { if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + .getBoolean("Island.Challenge.PerIsland", false)) { + OfflinePlayer player = Bukkit.getPlayer(uuid); + if(player == null) { + player = Bukkit.getOfflinePlayer(uuid); + } + Island is = plugin.getIslandManager().getIsland(player); if(is != null){ uuid = is.getOwnerUUID(); } @@ -99,10 +104,18 @@ public class PlayerManager { */ public void unloadPlayer(UUID uuid) { if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Challenge.PerIsland", true)) { - Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid)); + .getBoolean("Island.Challenge.PerIsland", false)) { + OfflinePlayer player = Bukkit.getPlayer(uuid); + if(player == null) { + player = Bukkit.getOfflinePlayer(uuid); + } + Island is = plugin.getIslandManager().getIsland(player); if(is != null){ - uuid = is.getOwnerUUID(); + if (!plugin.getIslandManager().getMembersOnline(is).isEmpty()) { + return; + } else { + uuid = is.getOwnerUUID(); + } } } islands.remove(uuid); From c47cda47680412a89c2f3dbb0168e9a64d24bd54 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 9 Jul 2020 19:21:10 +0200 Subject: [PATCH 189/366] 2.3.5-RC3 --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 966ef25e..ead5f538 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC2 + 2.3.5-RC3 jar UTF-8 @@ -51,7 +51,6 @@ 1.8 - org.apache.maven.plugins maven-shade-plugin From f3ad27c9e7e1605834ef26a152f8bcb33a668fa5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 07:34:17 +0200 Subject: [PATCH 190/366] Added Nonnull notations on BasicPermission --- .../java/com/songoda/skyblock/permission/BasicPermission.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java index 81194392..cbc80da6 100644 --- a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import javax.annotation.Nonnull; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -21,7 +22,7 @@ public abstract class BasicPermission { private final CompatibleMaterial icon; private final PermissionType type; - protected BasicPermission(String name, CompatibleMaterial icon, PermissionType type) { + protected BasicPermission(@Nonnull String name, @Nonnull CompatibleMaterial icon, @Nonnull PermissionType type) { this.name = name; this.icon = icon; this.type = type; From 9dcfe25d061b90249ad77d585911206c36ca27b6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 07:34:32 +0200 Subject: [PATCH 191/366] Fixed MaxMembers upgrade --- .../skyblock/command/commands/island/AcceptCommand.java | 3 +-- .../skyblock/command/commands/island/InviteCommand.java | 2 +- src/main/java/com/songoda/skyblock/menus/Members.java | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java index a5e688fc..f8f26401 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java @@ -99,8 +99,7 @@ public class AcceptCommand extends SubCommand { island.save(); if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() - + 1) >= fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) - .getFileConfiguration().getInt("Island.Member.Capacity")) { + + 1) >= island.getMaxMembers()) { Map invites = inviteManager.getInvites(); for (UUID inviteList : invites.keySet()) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java index 0ce58614..361e743a 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java @@ -50,7 +50,7 @@ public class InviteCommand extends SubCommand { Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() - + 1) >= mainConfig.getFileConfiguration().getInt("Island.Member.Capacity")) { + + 1) >= island.getMaxMembers()) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Capacity.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { diff --git a/src/main/java/com/songoda/skyblock/menus/Members.java b/src/main/java/com/songoda/skyblock/menus/Members.java index 7d33171a..50b83df4 100644 --- a/src/main/java/com/songoda/skyblock/menus/Members.java +++ b/src/main/java/com/songoda/skyblock/menus/Members.java @@ -333,8 +333,7 @@ public class Members { new Placeholder("%island_members", "" + (islandMembers.size() + islandOperators.size() + 1)), new Placeholder("%island_capacity", - "" + fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) - .getFileConfiguration().getInt("Island.Member.Capacity")), + "" + island.getMaxMembers()), new Placeholder("%members", "" + islandMembers.size()), new Placeholder("%operators", "" + islandOperators.size())}, null, null), 4); From 01e0b13e0768fbdc8a77436037181fed3e1cbd0d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 07:43:37 +0200 Subject: [PATCH 192/366] Edited default placeholder --- src/main/resources/language.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 0c64453b..77b3ac5c 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -2246,7 +2246,7 @@ Menu: Statistics: Lore: - '&bIsland Members:' - - '&e%island_members/%island_maxMembers' + - '&e%island_members/%island_capacity' - '' - '&bMembers:' - '&e%members' From d0b3f5f93762169173ea42125443ae6e7218f517 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 07:43:57 +0200 Subject: [PATCH 193/366] 2.3.5-RC4-DEV1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ead5f538..912e586e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC3 + 2.3.5-RC4-DEV1 jar UTF-8 From 41fd23122b0522ad483e3640a697d8055278e5d3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 10:48:53 +0200 Subject: [PATCH 194/366] Hotfix for repeaters not being recognized in 1.8.8 --- .../songoda/skyblock/island/IslandLevel.java | 37 +++++++++++++++ .../levelling/IslandLevelManager.java | 13 +++++- .../skyblock/limit/impl/BlockLimitation.java | 33 +++++++++++-- .../com/songoda/skyblock/listeners/Block.java | 46 ++++++++++++++++--- 4 files changed, 116 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java index 2d73d9f3..a054f6af 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java @@ -1,6 +1,8 @@ package com.songoda.skyblock.island; import com.google.common.base.Strings; +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.reward.LevelReward; @@ -94,6 +96,15 @@ public class IslandLevel { } public long getMaterialPoints(String material) { + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (material.toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER.name(); + break; + } + } + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -186,6 +197,15 @@ public class IslandLevel { } public void setMaterialAmount(String material, long amount) { + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (material.toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER.name(); + break; + } + } + plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration() .set("Levelling.Materials." + material + ".Amount", amount); @@ -193,10 +213,27 @@ public class IslandLevel { } public long getMaterialAmount(String material) { + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (material.toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER.name(); + break; + } + } return this.materials.getOrDefault(material, 0l); } public void removeMaterial(String material) { + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (material.toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER.name(); + break; + } + } + plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration() .set("Levelling.Materials." + material, null); diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java index d0faa300..ba5b2d42 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java @@ -231,7 +231,18 @@ public final class IslandLevelManager { private void updateLevelLocation(Island island, Location location) { Block block = location.getBlock(); - CompatibleMaterial material = CompatibleMaterial.getMaterial(block); + CompatibleMaterial material = null; + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (block.getType().toString().toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER; + break; + } + } + if(material == null) { + material = CompatibleMaterial.getMaterial(block); + } if (material == null || material == CompatibleMaterial.AIR) return; 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 6ec563a6..58d63665 100644 --- a/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java +++ b/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.limit.impl; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; @@ -45,11 +46,11 @@ public final class BlockLimitation extends EnumLimitation { for (String key : keys) { final String enumName = key.toUpperCase(Locale.ENGLISH); - final CompatibleMaterial type = CompatibleMaterial.getMaterial(enumName); + CompatibleMaterial type = CompatibleMaterial.getMaterial(enumName); if (type == null) throw new IllegalArgumentException("Unable to parse Materials from '" + enumName + "' in the Section '" + loadFrom.getCurrentPath() + "'"); - + getMap().put(type, loadFrom.getLong(key)); } @@ -64,7 +65,18 @@ public final class BlockLimitation extends EnumLimitation { if (player.hasPermission("fabledskyblock.limit.block.*")) return -1; - final CompatibleMaterial material = CompatibleMaterial.getMaterial(type); + CompatibleMaterial material = null; + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (type.toString().toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER; + break; + } + } + if(material == null) { + material = CompatibleMaterial.getMaterial(type); + } if (material == null) return -1; @@ -78,7 +90,6 @@ public final class BlockLimitation extends EnumLimitation { } public boolean isBlockLimitExceeded(Material type, Location loc, long limit) { - if (limit == -1) return false; final IslandManager islandManager = SkyBlock.getInstance().getIslandManager(); @@ -88,7 +99,19 @@ public final class BlockLimitation extends EnumLimitation { 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(type).name()); + CompatibleMaterial material = null; + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (type.toString().toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER; + break; + } + } + if(material == null) { + material = CompatibleMaterial.getMaterial(type); + } + totalPlaced = island.getLevel().getMaterialAmount(material.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 9ac94cb5..bf9eb1b9 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -44,8 +44,7 @@ public class Block implements Listener { public Block(SkyBlock plugin) { this.plugin = plugin; } - - @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.LOW) public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); @@ -74,7 +73,18 @@ public class Block implements Listener { if (stackableManager != null && stackableManager.isStacked(blockLocation)) { Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block)); if (stackable != null) { - CompatibleMaterial material = CompatibleMaterial.getMaterial(block); + CompatibleMaterial material = null; + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (block.getType().toString().toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER; + break; + } + } + if(material == null) { + material = CompatibleMaterial.getMaterial(block); + } byte data = block.getData(); int droppedAmount; @@ -141,8 +151,19 @@ public class Block implements Listener { } if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return; - - CompatibleMaterial material = CompatibleMaterial.getMaterial(block); + + CompatibleMaterial material = null; + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (block.getType().toString().toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER; + break; + } + } + if(material == null) { + material = CompatibleMaterial.getMaterial(block); + } if (material == null) return; @@ -273,7 +294,18 @@ public class Block implements Listener { long limit = limits.getBlockLimit(player, block); if (limits.isBlockLimitExceeded(block, limit)) { - CompatibleMaterial material = CompatibleMaterial.getMaterial(block.getType()); + CompatibleMaterial material = null; + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + switch (block.getType().toString().toUpperCase()) { + case "DIODE_BLOCK_OFF": + case "DIODE_BLOCK_ON": + material = CompatibleMaterial.REPEATER; + break; + } + } + if(material == null) { + material = CompatibleMaterial.getMaterial(block); + } plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message") .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit))); @@ -287,7 +319,7 @@ public class Block implements Listener { if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial() && event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return; - + islandLevelManager.updateLevel(island, blockLoc); } From 9844f32eb2834b3327ea7695303ab9834c796300 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 10:48:59 +0200 Subject: [PATCH 195/366] Removed unused imports --- src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java | 1 - src/main/java/com/songoda/skyblock/listeners/FallBreak.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java index a97efe22..de566538 100644 --- a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java @@ -20,7 +20,6 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.NumberUtil; import org.bukkit.Bukkit; -import org.bukkit.block.Biome; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java index b3b9ba1a..8b8cc1f3 100644 --- a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java +++ b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java @@ -15,8 +15,6 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntitySpawnEvent; import java.io.File; import java.lang.reflect.InvocationTargetException; From c8590a74fe7267aeeaa1d2017588ac966b4d8e16 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 10:57:02 +0200 Subject: [PATCH 196/366] Removed french challenges --- src/main/resources/challenges.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index 4a8f052d..95c0b5fb 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -529,7 +529,7 @@ challenges: - '&e- 24 pumpkin seeds' - '&e- 24 melon seeds' - '&e- 24 wheat seeds' - - '&c&lEt tu gagneras :' + - '&c&lRewards:' - '&e- 1 sponge' - '&e- 150 $' '9': @@ -617,7 +617,7 @@ challenges: - '&e- 1 stack of gunpowder' - '&e- 1 stack of arrows' - '&e- 1 stack of bones' - - '&c&lEt tu gagneras :' + - '&c&lRewards:' - '&e- 16 iron ingots' - '&e- 8 redstone blocks' - '&e- 250 $' @@ -911,7 +911,7 @@ challenges: - '&e- 10 ghast tears' - '&e- 24 magma cream' - '&e- 1 stack of magma blocks' - - '&c&lEt tu gagneras :' + - '&c&lRewards:' - '&e- 1 spawner' - '&e- 500 $' '4': From ba6033c5fddcdd78c0998b1b77bec316de63b5e6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 14:05:31 +0200 Subject: [PATCH 197/366] 2.3.5-RC4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 912e586e..6e5a893d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC4-DEV1 + 2.3.5-RC4 jar UTF-8 From e599b735a8c3d8ff629e867d6b066baf80d6b141 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 14:15:01 +0200 Subject: [PATCH 198/366] Fix for API implementation --- src/main/java/com/songoda/skyblock/api/SkyBlockAPI.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/api/SkyBlockAPI.java b/src/main/java/com/songoda/skyblock/api/SkyBlockAPI.java index 8000a0ef..55a619bc 100644 --- a/src/main/java/com/songoda/skyblock/api/SkyBlockAPI.java +++ b/src/main/java/com/songoda/skyblock/api/SkyBlockAPI.java @@ -25,9 +25,9 @@ public class SkyBlockAPI { /** * @param implementation the implementation to set */ - public static void setImplementation(SkyBlock implementation) { - if (SkyBlockAPI.implementation != null) { - throw new IllegalArgumentException("Cannot set API implementation twice"); + public static void setImplementation(SkyBlock implementation) throws IllegalStateException { + if (SkyBlockAPI.implementation != null && SkyBlockAPI.implementation != implementation) { + throw new IllegalStateException("Cannot set API implementation twice"); } SkyBlockAPI.implementation = implementation; From ef34164d5027af5fc77bad666fccceb2c02f5c63 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 14:41:36 +0200 Subject: [PATCH 199/366] Removed default colors from placeholders --- src/main/resources/language.yml | 132 ++++++++++++++++---------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 77b3ac5c..7e0ae24f 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -3437,168 +3437,168 @@ Menu: Placeholder: fabledskyblock_leaderboard_votes: Empty: - Message: '&f&oUnclaimed' + Message: 'Unclaimed' Non-empty: - Message: '&f[%position] %player [%votes]' + Message: '[%position] %player [%votes]' fabledskyblock_leaderboard_bank: Empty: - Message: '&f&oUnclaimed' + Message: 'Unclaimed' Non-empty: - Message: '&f[%position] %player [$%balance]' + Message: '[%position] %player [$%balance]' fabledskyblock_island_exists: Exists: - Message: '&atrue' + Message: 'true' Not-exists: - Message: '&cfalse' + Message: 'false' fabledskyblock_island_members: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_coops: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_leaderboard_level: Empty: - Message: '&f&oUnclaimed' + Message: 'Unclaimed' Non-empty: - Message: '&f[%position] %player [%level]' + Message: '[%position] %player [%level]' fabledskyblock_island_visitors: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_size: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_maxmembers: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_time: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_bank_balance_formatted: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_owner: Non-empty: Yourself: - Message: '&fYou' + Message: 'You' Other: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&f&oNone' + Message: '&oNone' fabledskyblock_island_leaderboard_bank_rank: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_bans: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_coops_total: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_invites: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_level_block_count: Invalid: - Message: '&cInvalid Type' + Message: 'Invalid Type' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_weather: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_role: Empty: - Message: '&f&oNone' + Message: '&oNone' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_operators: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_bank_balance: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_biome: Empty: - Message: '&f&oNone' + Message: '&oNone' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_level_formatted: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_members_total: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_island_level_block_points: Empty: - Message: '&c0' + Message: '0' Invalid: - Message: '&cInvalid Type' + Message: 'Invalid Type' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_isopen: Closed: - Message: '&cfalse' + Message: 'false' Open: - Message: '&atrue' + Message: 'true' Empty: - Message: '&cfalse' + Message: 'false' fabledskyblock_island_votes: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_radius: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_leaderboard_votes_rank: Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Empty: - Message: '&c0' + Message: '0' fabledskyblock_level_block_value: Invalid: - Message: '&cInvalid Type' + Message: 'Invalid Type' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' fabledskyblock_island_leaderboard_level_rank: Empty: - Message: '&c0' + Message: '0' Non-empty: - Message: '&f%placeholder' + Message: '%placeholder' Island: Limit: Block: From 842243a9c7133a1934684fd969f4615b0fde2572 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 15:58:07 +0200 Subject: [PATCH 200/366] Settings permissions --- .../commands/admin/SettingsCommand.java | 2 +- .../commands/island/SettingsCommand.java | 2 +- .../gui/permissions/GuiPermissions.java | 87 +++++++++++-------- .../permissions/GuiPermissionsSelector.java | 13 +-- src/main/resources/config.yml | 3 + 5 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java index daa7c249..e8aab837 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SettingsCommand.java @@ -13,7 +13,7 @@ public class SettingsCommand extends SubCommand { public void onCommandByPlayer(Player player, String[] args) { SoundManager soundManager = plugin.getSoundManager(); - plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, null, null)); + plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, player, null, null)); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java index c8bb0393..a94f5ceb 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/SettingsCommand.java @@ -39,7 +39,7 @@ public class SettingsCommand extends SubCommand { && (permissionManager.hasPermission(island, "Visitor", IslandRole.Operator) || permissionManager.hasPermission(island, "Member", IslandRole.Operator))) || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, island, null)); + plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, player, island, null)); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } else{ messageManager.sendMessage(player, diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java index 3a5825dd..7de71d08 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java @@ -23,6 +23,7 @@ import org.bukkit.entity.Player; import java.io.File; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -33,22 +34,24 @@ public class GuiPermissions extends Gui { private final SoundManager soundManager; private final IslandRole role; private final Island island; + private final Player player; + private final FileConfiguration languageLoad; private final FileConfiguration configLoad; - private final FileManager.Config config; private final Gui returnGui; - public GuiPermissions(SkyBlock plugin, Island island, IslandRole role, Gui returnGui) { + public GuiPermissions(SkyBlock plugin, Player player, Island island, IslandRole role, Gui returnGui) { super(6, returnGui); this.plugin = plugin; + this.player = player; this.permissionManager = plugin.getPermissionManager(); this.soundManager = plugin.getSoundManager(); this.role = role; this.island = island; this.returnGui = returnGui; - this.configLoad = plugin.getFileManager() + this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); - this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); - setTitle(TextUtils.formatText(configLoad.getString("Menu.Settings." + role.name() + ".Title"))); + this.configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Settings." + role.name() + ".Title"))); setDefaultItem(null); paint(); } @@ -59,22 +62,22 @@ public class GuiPermissions extends Gui { setActionForRange(0, 0, 5, 9, null); setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); if (role == IslandRole.Visitor) { - if (config.getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable")) + if (configLoad.getBoolean("Island.Visitor.Welcome.Enable")) setButton(5, GuiUtils.createButtonItem(CompatibleMaterial.MAP, - TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Welcome.Displayname")), - TextUtils.formatText(configLoad.getStringList("Menu.Settings.Visitor.Item.Welcome.Lore"))), + TextUtils.formatText(languageLoad.getString("Menu.Settings.Visitor.Item.Welcome.Displayname")), + TextUtils.formatText(languageLoad.getStringList("Menu.Settings.Visitor.Item.Welcome.Lore"))), (event) -> guiManager.showGUI(event.player, new GuiWelcomeEditor(plugin, this, island))); - if (config.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) { + if (configLoad.getBoolean("Island.Visitor.Signature.Enable")) { setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, - TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Signature.Displayname")), - TextUtils.formatText(configLoad.getStringList("Menu.Settings.Visitor.Item.Signature.Lore"))), + TextUtils.formatText(languageLoad.getString("Menu.Settings.Visitor.Item.Signature.Displayname")), + TextUtils.formatText(languageLoad.getStringList("Menu.Settings.Visitor.Item.Signature.Lore"))), (event) -> guiManager.showGUI(event.player, new GuiSignatureEditor(plugin, this, island))); } @@ -91,7 +94,7 @@ public class GuiPermissions extends Gui { configAddress = "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Whitelisted.Lore"; break; } - List welcomeLore = TextUtils.formatText(configLoad.getStringList(configAddress)); + List welcomeLore = TextUtils.formatText(languageLoad.getStringList(configAddress)); List welcomeFinal = new ArrayList<>(); @@ -102,7 +105,7 @@ public class GuiPermissions extends Gui { } setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, - TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname")), + TextUtils.formatText(languageLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname")), welcomeFinal), (event -> { switch (island.getStatus()) { @@ -124,7 +127,7 @@ public class GuiPermissions extends Gui { } setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> { soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); @@ -132,12 +135,18 @@ public class GuiPermissions extends Gui { List permissions = permissionManager.getPermissions().stream() .filter(p -> p.getType() == getType(role)) .collect(Collectors.toList()); + + if(configLoad.getBoolean("Island.Settings.Permission")) { + permissions.removeIf(permission -> !player.hasPermission("fabledskyblock.settings." + + role.name().toLowerCase() + "." + permission.getName().toLowerCase())); + } + double itemCount = permissions.size(); this.pages = (int) Math.max(1, Math.ceil(itemCount / 36)); if (page != 1) setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Last.Displayname"))), + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Last.Displayname"))), (event) -> { page--; paint(); @@ -145,33 +154,37 @@ public class GuiPermissions extends Gui { if (page != pages) setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Next.Displayname"))), + TextUtils.formatText(languageLoad.getString("Menu.Settings.Categories.Item.Next.Displayname"))), (event) -> { page++; paint(); }); - for (int i = 9; i < 45; i++) { - int current = ((page - 1) * 36) - 9; - if (current + i >= permissions.size()) { - setItem(i, null); - continue; - } - BasicPermission permission = permissions.get(current + i); - if (permission == null) continue; - - setButton(i, permission.getItem(island, role), (event) -> { - if (!hasPermission(island, event.player, role)) { - plugin.getMessageManager().sendMessage(event.player, configLoad - .getString("Command.Island.Settings.Permission.Change.Message")); - soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); - - return; + if(!permissions.isEmpty()) { + for (int i = 9; i < 45; i++) { + int current = ((page - 1) * 36) - 9; + if (current + i >= permissions.size()) { + setItem(i, null); + continue; } - IslandPermission islandPermission = island.getPermission(role, permission); - islandPermission.setStatus(!islandPermission.getStatus()); - paint(); - }); + BasicPermission permission = permissions.get(current + i); + if (permission == null) continue; + + setButton(i, permission.getItem(island, role), (event) -> { + if (!hasPermission(island, event.player, role)) { + plugin.getMessageManager().sendMessage(event.player, languageLoad + .getString("Command.Island.Settings.Permission.Change.Message")); + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + + return; + } + IslandPermission islandPermission = island.getPermission(role, permission); + islandPermission.setStatus(!islandPermission.getStatus()); + paint(); + }); + } + } else { + setItem(31, CompatibleMaterial.BARRIER.getItem()); // TODO } } diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java index c27b8d04..a8e75ff6 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java @@ -10,6 +10,7 @@ import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandRole; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -17,7 +18,7 @@ import java.io.File; public class GuiPermissionsSelector extends Gui { - public GuiPermissionsSelector(@Nonnull SkyBlock plugin, @Nullable Island island, @Nullable Gui returnGui) { + public GuiPermissionsSelector(@Nonnull SkyBlock plugin, @Nullable Player player, @Nullable Island island, @Nullable Gui returnGui) { super(1, returnGui); setDefaultItem(null); @@ -34,21 +35,21 @@ public class GuiPermissionsSelector extends Gui { TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Visitor.Lore"))), (event) -> guiManager.showGUI(event.player, island == null ? new GuiAdminPermissions(plugin, IslandRole.Visitor, this) : - new GuiPermissions(plugin, island, IslandRole.Visitor, this))); + new GuiPermissions(plugin, player, island, IslandRole.Visitor, this))); setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Member.Displayname")), TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Member.Lore"))), (event) -> guiManager.showGUI(event.player, island == null ? new GuiAdminPermissions(plugin, IslandRole.Member, this) : - new GuiPermissions(plugin, island, IslandRole.Member, this))); + new GuiPermissions(plugin, player, island, IslandRole.Member, this))); setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME, TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Operator.Displayname")), TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Operator.Lore"))), (event) -> guiManager.showGUI(event.player, island == null ? new GuiAdminPermissions(plugin, IslandRole.Operator, this) : - new GuiPermissions(plugin, island, IslandRole.Operator, this))); + new GuiPermissions(plugin, player, island, IslandRole.Operator, this))); boolean isCoop = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Coop.Enable"); @@ -65,14 +66,14 @@ public class GuiPermissionsSelector extends Gui { TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Coop.Lore"))), (event) -> guiManager.showGUI(event.player, island == null ? new GuiAdminPermissions(plugin, IslandRole.Coop, this) : - new GuiPermissions(plugin, island, IslandRole.Coop, this))); + new GuiPermissions(plugin, player, island, IslandRole.Coop, this))); setButton(isCoop ? 7 : 8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_SAPLING.getItem(), TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Owner.Displayname")), TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Owner.Lore"))), (event) -> guiManager.showGUI(event.player, island == null ? new GuiAdminPermissions(plugin, IslandRole.Owner, this) : - new GuiPermissions(plugin, island, IslandRole.Owner, this))); + new GuiPermissions(plugin, player, island, IslandRole.Owner, this))); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index af42336d..9e9138d3 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -291,6 +291,9 @@ Island: # items in their inventory if they die at an island. Enable: true Settings: + # With this option true the players will need fabledskyblock.settings.. permission + # Roles and settings name can be found in the settings.yml file + Permission: false # When any of these options are disabled, the setting will be removed from the settings menu # menu. KeepItemsOnDeath: From af16aff942cc167b08a856337e783e5c19529ad7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 10 Jul 2020 16:01:53 +0200 Subject: [PATCH 201/366] 2.3.5-RC5-DEV1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6e5a893d..9e350254 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC4 + 2.3.5-RC5-DEV1 jar UTF-8 From 00085c923d158f8e4e24c23a8968e4765f52b740 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 06:56:14 +0200 Subject: [PATCH 202/366] Fixed double chat --- .../com/songoda/skyblock/listeners/Chat.java | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index 46891371..6a007947 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -63,53 +63,15 @@ public class Chat implements Listener { event.setFormat(messageFormat); - if (playerData.isChat()) { + if (playerData.isChat() && island != null) { event.setCancelled(true); Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration languageLoad = language.getFileConfiguration(); - String islandRole = ""; - - if (island.hasRole(IslandRole.Member, player.getUniqueId())) { - islandRole = languageLoad.getString("Island.Chat.Format.Role.Member"); - } else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) { - islandRole = languageLoad.getString("Island.Chat.Format.Role.Operator"); - } else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { - islandRole = languageLoad.getString("Island.Chat.Format.Role.Owner"); - } - PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, island.getAPIWrapper(), event.getMessage(), languageLoad.getString("Island.Chat.Format.Message")); Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); - - if (!islandChatEvent.isCancelled()) { - for (UUID islandMembersOnlineList : islandManager.getMembersOnline(island)) { - Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); - String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, - islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName()))) - .replace("%message", islandChatEvent.getMessage()); - messageManager.sendMessage(targetPlayer, message); - } - - for(Player targetPlayer : Bukkit.getServer().getOnlinePlayers()){ - if(targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) { - PlayerData pd = playerDataManager.getPlayerData(targetPlayer); - if(pd != null && pd.isChatSpy() && (pd.isGlobalChatSpy() || pd.isChatSpyIsland(island))) { - String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, - islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName()))) - .replace("%islandOwner", new OfflinePlayer(island.getOwnerUUID()).getName()) - .replace("%message", islandChatEvent.getMessage()); - messageManager.sendMessage(targetPlayer, message); - } - } - } - - if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { - messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName()) - .replace("%message", islandChatEvent.getMessage())); - } - } } } } From 71e7d5aba49ee281ca67c6bad361a8f5f0707fc9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 09:15:48 +0200 Subject: [PATCH 203/366] FallBreak check every 2 ticks --- src/main/java/com/songoda/skyblock/listeners/FallBreak.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java index 8b8cc1f3..a46d2391 100644 --- a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java +++ b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java @@ -79,7 +79,7 @@ public class FallBreak implements Listener { } } } - }, 2L, 1L); + }, 2L, 2L); } @EventHandler From d9e1ffeaef50765927a81ae3c637dcfe8ee15dd8 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 09:16:25 +0200 Subject: [PATCH 204/366] Small edits to Scoreboard manager --- .../command/commands/admin/ReloadCommand.java | 2 +- .../scoreboard/ScoreboardManager.java | 168 +++++++++--------- 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java index bb191456..b04042a2 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java @@ -68,7 +68,7 @@ public class ReloadCommand extends SubCommand { plugin.setScoreboardManager(new ScoreboardManager(plugin)); } } else { - plugin.getScoreboardManager().updateScoreboards(false); + plugin.getScoreboardManager().reloadScoreboards(false); } if (plugin.getGeneratorManager() == null) { diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 194d39c3..098bbfe3 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.scoreboard; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -23,9 +24,8 @@ import org.bukkit.scoreboard.Team.Option; import java.io.File; import java.util.*; -public class ScoreboardManager extends BukkitRunnable { - - private final static int VERSION = NMSUtil.getVersionNumber(); +public class ScoreboardManager { + private final SkyBlock plugin; private final Map scoreboardStorage = new HashMap<>(); @@ -39,48 +39,41 @@ public class ScoreboardManager extends BukkitRunnable { public ScoreboardManager(SkyBlock plugin) { this.plugin = plugin; this.playerDataManager = plugin.getPlayerDataManager(); - this.runTaskTimer(plugin, 20, 40); + Bukkit.getScheduler().runTask(plugin, () -> reloadScoreboards(true)); + Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::updateScoreboards, 20L, 40L); } - @SuppressWarnings("deprecation") - @Override - public void run() { - - if (runTicks++ == 0) { - updateScoreboards(true); - return; - } - + private void updateScoreboards() { final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); - final Collection players = Bukkit.getOnlinePlayers(); final Set objectives = primary.getObjectives(); final Set teams = primary.getTeams(); - - for (Player player : players) { - - /* - * Unregister all teams or objectives that are no longer present in the main - * scoreboard. - */ - - final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); - - for (String name : objectiveNames) { - - if (primary.getObjective(name) != null) continue; - - final Objective objective = board.getObjective(name); - - if (objective != null) objective.unregister(); - } - - for (String name : teamNames) { - - if (primary.getTeam(name) != null) continue; - - final Team team = board.getTeam(name); - - if (team != null) team.unregister(); + + /* + * Unregister all teams or objectives that are no longer present in the main + * scoreboard. + */ + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); + + for (String name : objectiveNames) { + + if (primary.getObjective(name) != null) continue; + + final Objective objective = board.getObjective(name); + + if (objective != null) objective.unregister(); + } + + for (String name : teamNames) { + + if (primary.getTeam(name) != null) continue; + + final Team team = board.getTeam(name); + + if (team != null) team.unregister(); + } } } @@ -90,57 +83,64 @@ public class ScoreboardManager extends BukkitRunnable { objectiveNames.clear(); teamNames.clear(); + + for(Objective objective : objectives) { + if (primary.getObjective(objective.getName()) != null) { + objectiveNames.add(objective.getName()); + } + } - objectives.forEach(objective -> { - if (primary.getObjective(objective.getName()) != null) objectiveNames.add(objective.getName()); - }); - teams.forEach(team -> { - if (primary.getTeam(team.getName()) != null) teamNames.add(team.getName()); - }); - + for(Team team : teams) { + if (primary.getTeam(team.getName()) != null) { + teamNames.add(team.getName()); + } + } + /* * Update or add any missing information to the player's scoreboard. */ - - for (Player player : players) { - PlayerData pd = playerDataManager.getPlayerData(player); - if(pd != null && pd.isScoreboard()){ - final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - - for (Objective primaryObjective : objectives) { + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + PlayerData pd = playerDataManager.getPlayerData(player); + if(pd != null && pd.isScoreboard()){ + final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - Objective obj = playerBoard.getObjective(primaryObjective.getName()); - - if (obj == null) - obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); - - obj.setDisplayName(primaryObjective.getDisplayName()); - obj.setDisplaySlot(primaryObjective.getDisplaySlot()); - if (VERSION > 12) obj.setRenderType(primaryObjective.getRenderType()); - } - - for (Team primaryTeam : teams) { - - Team obj = playerBoard.getTeam(primaryTeam.getName()); - - if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); - - obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); - obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); - if (VERSION > 11) obj.setColor(primaryTeam.getColor()); - obj.setDisplayName(primaryTeam.getDisplayName()); - obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); - obj.setPrefix(primaryTeam.getPrefix()); - obj.setSuffix(primaryTeam.getSuffix()); - - for (String primaryEntry : primaryTeam.getEntries()) { - obj.addEntry(primaryEntry); + for (Objective primaryObjective : objectives) { + + Objective obj = playerBoard.getObjective(primaryObjective.getName()); + + if (obj == null) + obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); + + obj.setDisplayName(primaryObjective.getDisplayName()); + obj.setDisplaySlot(primaryObjective.getDisplaySlot()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); } - if (VERSION > 8) { - for (Option option : Option.values()) { - obj.setOption(option, primaryTeam.getOption(option)); + for (Team primaryTeam : teams) { + + Team obj = playerBoard.getTeam(primaryTeam.getName()); + + if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); + + obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); + obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); + obj.setDisplayName(primaryTeam.getDisplayName()); + obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); + obj.setPrefix(primaryTeam.getPrefix()); + obj.setSuffix(primaryTeam.getSuffix()); + + for (String primaryEntry : primaryTeam.getEntries()) { + obj.addEntry(primaryEntry); + } + + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { + for (Option option : Option.values()) { + obj.setOption(option, primaryTeam.getOption(option)); + } } } } @@ -148,7 +148,7 @@ public class ScoreboardManager extends BukkitRunnable { } } - public void updateScoreboards(boolean createNew) { + public void reloadScoreboards(boolean createNew) { FileManager fileManager = plugin.getFileManager(); From ba802f09c1815e2a595e731e479910ec116351fd Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 09:17:30 +0200 Subject: [PATCH 205/366] Fix for challenges taking all the items --- .../com/songoda/skyblock/challenge/challenge/Challenge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e8a832f4..f1f8e8eb 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -186,7 +186,7 @@ public class Challenge { if(isItem) { if(jis.getAmount() <= toRemove) { toRemove -= jis.getAmount(); - p.getInventory().remove(jis); + p.getInventory().removeItem(jis); } else { jis.setAmount(jis.getAmount() - toRemove); toRemove = 0; From 0564310dc3a239959b515228486a9da7dd390390 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 09:17:43 +0200 Subject: [PATCH 206/366] 2.3.5-RC5-DEV2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9e350254..f641d0f7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC5-DEV1 + 2.3.5-RC5-DEV2 jar UTF-8 From ba088b940a943e18650e7c16ab36059d452ff3a8 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 11:30:48 +0200 Subject: [PATCH 207/366] Async scoreboard --- .../scoreboard/ScoreboardManager.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 098bbfe3..dbf35928 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -23,16 +23,15 @@ import org.bukkit.scoreboard.Team.Option; import java.io.File; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; public class ScoreboardManager { private final SkyBlock plugin; - private final Map scoreboardStorage = new HashMap<>(); + private final Map scoreboardStorage = new ConcurrentHashMap<>(); private final PlayerDataManager playerDataManager; - private int runTicks = 0; - private final List teamNames = new ArrayList<>(); private final List objectiveNames = new ArrayList<>(); @@ -43,7 +42,7 @@ public class ScoreboardManager { Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::updateScoreboards, 20L, 40L); } - private void updateScoreboards() { + private synchronized void updateScoreboards() { final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); final Set objectives = primary.getObjectives(); final Set teams = primary.getTeams(); @@ -148,7 +147,7 @@ public class ScoreboardManager { } } - public void reloadScoreboards(boolean createNew) { + public synchronized void reloadScoreboards(boolean createNew) { FileManager fileManager = plugin.getFileManager(); @@ -207,11 +206,11 @@ public class ScoreboardManager { return str != null ? ChatColor.translateAlternateColorCodes('&', str) : null; } - public void storeScoreboard(Player player, Scoreboard scoreboard) { + public synchronized void storeScoreboard(Player player, Scoreboard scoreboard) { scoreboardStorage.put(player.getUniqueId(), scoreboard); } - public Scoreboard getScoreboard(Player player) { + public synchronized Scoreboard getScoreboard(Player player) { if (scoreboardStorage.containsKey(player.getUniqueId())) { return scoreboardStorage.get(player.getUniqueId()); } @@ -219,15 +218,15 @@ public class ScoreboardManager { return null; } - public boolean hasScoreboard(Player player) { + public synchronized boolean hasScoreboard(Player player) { return scoreboardStorage.containsKey(player.getUniqueId()); } - public Map getScoreboardStorage() { + public synchronized Map getScoreboardStorage() { return this.scoreboardStorage; } - public void addPlayer(Player player){ + public synchronized void addPlayer(Player player){ CooldownManager cooldownManager = plugin.getCooldownManager(); FileManager fileManager = plugin.getFileManager(); IslandManager islandManager = plugin.getIslandManager(); @@ -269,7 +268,7 @@ public class ScoreboardManager { this.storeScoreboard(player, scoreboard); } - public void removePlayer(Player player){ + public synchronized void removePlayer(Player player){ player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); this.scoreboardStorage.remove(player.getUniqueId()); } From 742cd86f9604146737970ba5d85918f0b098cea9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 12:03:01 +0200 Subject: [PATCH 208/366] Default KeepItemsOnDeath to false --- src/main/resources/settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 154bfd74..0e50ae85 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -170,4 +170,4 @@ Settings: Explosions: true FireSpread: true LeafDecay: true - KeepItemsOnDeath: true \ No newline at end of file + KeepItemsOnDeath: false \ No newline at end of file From 4cd92121593c7cad3b95f90cad724f69cc9de16a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 14:18:53 +0200 Subject: [PATCH 209/366] Fixed mob griefing (sheep and enderman) --- .../listening/MobGriefingPermission.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java index f5a5e1bf..55e88cf0 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java @@ -5,9 +5,11 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; @@ -73,22 +75,12 @@ public class MobGriefingPermission extends ListeningPermission { event.setCancelled(true); } } - - /*@PermissionHandler // TODO ? - Fabrimat - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - Entity entity = event.getEntity(); - EntityType type = event.getEntityType(); - - if (type == EntityType.ARMOR_STAND || type == EntityType.PLAYER || entity instanceof Monster) return; - - Player player; - if (event.getDamager() instanceof Player) - player = (Player)event.getDamager(); - else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) - player = (Player) ((Projectile) event.getDamager()).getShooter(); - else return; - - cancelAndMessage(event, player, plugin, messageManager); - }*/ + + @PermissionHandler + public void onMobChangeBlock(EntityChangeBlockEvent event) { + if(event.getEntity() instanceof LivingEntity && !(event.getEntity() instanceof Player)) { + event.setCancelled(true); + } + } } From a0edb29bc480215d01b1cfd56ae4c31cf22d681d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 16:30:46 +0200 Subject: [PATCH 210/366] 2.3.5-RC5-DEV3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f641d0f7..7a630588 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC5-DEV2 + 2.3.5-RC5-DEV3 jar UTF-8 From 493cb70987b84f2ec7f121eb0b040ac1c409ff50 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 18:45:01 +0200 Subject: [PATCH 211/366] Added some missing blocks to levelling.yml --- src/main/resources/levelling.yml | 246 +++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) diff --git a/src/main/resources/levelling.yml b/src/main/resources/levelling.yml index b98ee706..bf96aa28 100644 --- a/src/main/resources/levelling.yml +++ b/src/main/resources/levelling.yml @@ -47,6 +47,9 @@ Materials: ALLIUM: Limit: -1 Points: 1 + ANCIENT_DEBRIES: + Limit: -1 + Points: 2 ANDESITE: Limit: -1 Points: 1 @@ -83,6 +86,9 @@ Materials: BARREL: Limit: -1 Points: 1 + BASALT: + Limit: -1 + Points: 2 BEACON: Limit: -1 Points: 500 @@ -92,6 +98,12 @@ Materials: BEETROOTS: Limit: -1 Points: 1 + BEE_NEST: + Limit: -1 + Points: 1 + BEEHIVE: + Limit: -1 + Points: 1 BELL: Limit: -1 Points: 7 @@ -176,6 +188,18 @@ Materials: BLACK_WOOL: Limit: -1 Points: 2 + BLACKSTONE: + Limit: -1 + Points: 2 + BLACKSTONE_STAIRS: + Limit: -1 + Points: 5 + BLACKSTONE_WALL: + Limit: -1 + Points: 5 + BLASTSTONE_SLAB: + Limit: -1 + Points: 1 BLAST_FURNACE: Limit: -1 Points: 6 @@ -335,6 +359,9 @@ Materials: CAVE_AIR: Limit: -1 Points: 0 + CHAIN: + Limit: -1 + Points: 1 CHAIN_COMMAND_BLOCK: Limit: -1 Points: 0 @@ -344,6 +371,12 @@ Materials: CHIPPED_ANVIL: Limit: -1 Points: 9 + CHISELED_NETHER_BRICKS: + Limit: -1 + Points: 2 + CHISELED_POLISHED_BLACKSTONE: + Limit: -1 + Points: 2 CHISELED_QUARTZ_BLOCK: Limit: -1 Points: 2 @@ -407,6 +440,12 @@ Materials: CORNFLOWER: Limit: -1 Points: 1 + CRACKED_NETHER_BRICKS: + Limit: -1 + Points: 2 + CRACKED_POLISHED_BLACKSTONE_BRICKS: + Limit: -1 + Points: 2 CRACKED_STONE_BRICKS: Limit: -1 Points: 2 @@ -419,6 +458,54 @@ Materials: CREEPER_WALL_HEAD: Limit: -1 Points: 1 + CRIMSON_BUTTON: + Limit: -1 + Points: 1 + CRIMSON_DOOR: + Limit: -1 + Points: 1 + CRIMSON_FENCE: + Limit: -1 + Points: 1 + CRIMSON_FENCE_GATE: + Limit: -1 + Points: 1 + CRIMSON_FUNGUS: + Limit: -1 + Points: 1 + CRIMSON_HYPHAE: + Limit: -1 + Points: 1 + CRIMSON_NYLIUM: + Limit: -1 + Points: 1 + CRIMSON_PLANKS: + Limit: -1 + Points: 1 + CRIMSON_PRESSURE_PLATE: + Limit: -1 + Points: 1 + CRIMSON_ROOTS: + Limit: -1 + Points: 1 + CRIMSON_SIGN: + Limit: -1 + Points: 1 + CRIMSON_SLAB: + Limit: -1 + Points: 1 + CRIMSON_STAIRS: + Limit: -1 + Points: 1 + CRIMSON_STEM: + Limit: -1 + Points: 1 + CRIMSON_TRAPDOOR: + Limit: -1 + Points: 1 + CRIMSON_WALL_SIGN: + Limit: -1 + Points: 1 CUT_RED_SANDSTONE: Limit: -1 Points: 1 @@ -431,6 +518,9 @@ Materials: CUT_SANDSTONE_SLAB: Limit: -1 Points: 1 + CRYING_OBSIDIAN: + Limit: -1 + Points: 20 CYAN_BANNER: Limit: -1 Points: 2 @@ -698,6 +788,9 @@ Materials: GLASS_PANE: Limit: -1 Points: 1 + GILDED_BLACKSTONE: + Limit: -1 + Points: 2 GLOWSTONE: Limit: -1 Points: 1 @@ -812,6 +905,12 @@ Materials: HEAVY_WEIGHTED_PRESSURE_PLATE: Limit: -1 Points: 3 + HONEY_BLOCK: + Limit: -1 + Points: 2 + HONEYCOMB_BLOCK: + Limit: -1 + Points: 3 HOPPER: Limit: -1 Points: 5 @@ -1064,6 +1163,9 @@ Materials: LIME_WOOL: Limit: -1 Points: 2 + LODESTONE: + Limit: -1 + Points: 15 LOOM: Limit: -1 Points: 4 @@ -1163,18 +1265,27 @@ Materials: NETHER_BRICK_STAIRS: Limit: -1 Points: 2 + NETHER_GOLD_ORE: + Limit: -1 + Points: 2 NETHER_PORTAL: Limit: -1 Points: 1 NETHER_QUARTZ_ORE: Limit: -1 Points: 1 + NETHER_SPROUTS: + Limit: -1 + Points: 1 NETHER_WART: Limit: -1 Points: 1 NETHER_WART_BLOCK: Limit: -1 Points: 2 + NETHERITE_BLOCK: + Limit: -1 + Points: 1 NOTE_BLOCK: Limit: -1 Points: 10 @@ -1343,6 +1454,39 @@ Materials: POLISHED_ANDESITE_STAIRS: Limit: -1 Points: 1 + POLISHED_BASALT: + Limit: -1 + Points: 3 + POLISHED_BLACKSTONE: + Limit: -1 + Points: 3 + POLISHED_BLACKSTONE_BRICKS: + Limit: -1 + Points: 5 + POLISHED_BLACKSTONE_BRICK_SLAB: + Limit: -1 + Points: 2 + POLISHED_BLACKSTONE_BRICK_STAIRS: + Limit: -1 + Points: 3 + POLISHED_BLACKSTONE_BRICK_WALL: + Limit: -1 + Points: 2 + POLISHED_BLACKSTONE_BUTTON: + Limit: -1 + Points: 1 + POLISHED_BLACKSTONE_PRESSURE_PLATE: + Limit: -1 + Points: 1 + POLISHED_BLACKSTONE_SLAB: + Limit: -1 + Points: 1 + POLISHED_BLACKSTONE_STAIRS: + Limit: -1 + Points: 2 + POLISHED_BLACKSTONE_WALL: + Limit: -1 + Points: 3 POLISHED_DIORITE: Limit: -1 Points: 1 @@ -1523,6 +1667,9 @@ Materials: QUARTZ_BLOCK: Limit: -1 Points: 1 + QUARTZ_BRICKS: + Limit: -1 + Points: 1 QUARTZ_PILLAR: Limit: -1 Points: 1 @@ -1628,6 +1775,9 @@ Materials: REPEATING_COMMAND_BLOCK: Limit: -1 Points: 0 + RESPAWN_ANCHOR: + Limit: -1 + Points: 20 ROSE_BUSH: Limit: -1 Points: 1 @@ -1658,6 +1808,9 @@ Materials: SEA_PICKLE: Limit: -1 Points: 1 + SHROOMLIGHT: + Limit: -1 + Points: 2 SHULKER_BOX: Limit: -1 Points: 10 @@ -1709,9 +1862,24 @@ Materials: SNOW_BLOCK: Limit: -1 Points: 1 + SOUL_CAMPFIRE: + Limit: -1 + Points: 1 + SOUL_LANTERN: + Limit: -1 + Points: 1 SOUL_SAND: Limit: -1 Points: 1 + SOUL_SOIL: + Limit: -1 + Points: 1 + SOUL_TORCH: + Limit: -1 + Points: 0 + SOUL_WALL_TORCH: + Limit: -1 + Points: 0 SPAWNER: Limit: -1 Points: 10 @@ -1979,6 +2147,12 @@ Materials: STRIPPED_BIRCH_WOOD: Limit: -1 Points: 1 + STRIPPED_CRIMSON_HYPHAE: + Limit: -1 + Points: 0 + STRIPPED_CRIMSON_STEM: + Limit: -1 + Points: 0 STRIPPED_DARK_OAK_LOG: Limit: -1 Points: 0 @@ -2003,6 +2177,12 @@ Materials: STRIPPED_SPRUCE_WOOD: Limit: -1 Points: 1 + STRIPPED_WARPED_HYPHAE: + Limit: -1 + Points: 0 + STRIPPED_WARPED_STEM: + Limit: -1 + Points: 0 SUGAR_CANE: Limit: -1 Points: 1 @@ -2018,6 +2198,9 @@ Materials: TALL_SEAGRASS: Limit: -1 Points: 1 + TARGET: + Limit: -1 + Points: 1 TERRACOTTA: Limit: -1 Points: 2 @@ -2051,6 +2234,12 @@ Materials: TURTLE_EGG: Limit: -1 Points: 1 + TWISTING_VINES: + Limit: -1 + Points: 1 + TWISTING_VINES_PLANT: + Limit: -1 + Points: 1 VINE: Limit: -1 Points: 1 @@ -2060,6 +2249,63 @@ Materials: WALL_TORCH: Limit: -1 Points: 1 + WARPED_BUTTON: + Limit: -1 + Points: 1 + WARPED_DOOR: + Limit: -1 + Points: 1 + WARPED_FENCE: + Limit: -1 + Points: 1 + WARPED_FENCE_GATE: + Limit: -1 + Points: 1 + WARPED_FUNGUS: + Limit: -1 + Points: 1 + WARPED_HYPHAE: + Limit: -1 + Points: 1 + WARPED_NYLIUM: + Limit: -1 + Points: 1 + WARPED_PLANKS: + Limit: -1 + Points: 1 + WARPED_PRESSURE_PLATE: + Limit: -1 + Points: 1 + WARPED_ROOTS: + Limit: -1 + Points: 1 + WARPED_SIGN: + Limit: -1 + Points: 1 + WARPED_SLAB: + Limit: -1 + Points: 1 + WARPED_STAIRS: + Limit: -1 + Points: 1 + WARPED_STEM: + Limit: -1 + Points: 1 + WARPED_TRAPDOOR: + Limit: -1 + Points: 1 + WARPED_WALL_SIGN: + Limit: -1 + Points: 1 + WARPED_WART_BLOCK: + Limit: -1 + Points: 1 + WEEPING_VINES: + Limit: -1 + Points: 1 + WEEPING_VINES_PLANT: + Limit: -1 + Points: 1 WET_SPONGE: Limit: -1 Points: 10 From dbae4df3084cd7569da3f508a22225ac54b07645 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 11 Jul 2020 20:27:44 +0200 Subject: [PATCH 212/366] Reworked Entity listeners --- .../songoda/skyblock/listeners/Entity.java | 159 ++++++++---------- 1 file changed, 74 insertions(+), 85 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 194ae9d3..f34bbd84 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.listeners; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -34,7 +35,6 @@ import org.bukkit.event.vehicle.VehicleDamageEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; import java.io.File; import java.lang.reflect.Method; @@ -44,20 +44,20 @@ public class Entity implements Listener { private final SkyBlock plugin; - private Set preventFireTicks = new HashSet<>(); + private final Set preventFireTicks = new HashSet<>(); public Entity(SkyBlock plugin) { this.plugin = plugin; } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onFireWorkBoom(EntityDamageByEntityEvent event) { if (event.getDamager().getType() == EntityType.FIREWORK && plugin.getWorldManager().isIslandWorld(event.getEntity().getWorld())) event.setCancelled(true); } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { IslandManager islandManager = plugin.getIslandManager(); if(event.getEntity() instanceof Blaze){ @@ -88,62 +88,52 @@ public class Entity implements Listener { } } } - - @EventHandler + + @EventHandler(ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { IslandManager islandManager = plugin.getIslandManager(); - - if (event.getDamager() instanceof Player) { - Player player = (Player) event.getDamager(); - org.bukkit.entity.Entity entity = event.getEntity(); - - if (plugin.getWorldManager().isIslandWorld(entity.getWorld())) { - - // Check permissions. - plugin.getPermissionManager() - .processPermission(event, player, islandManager.getIslandAtLocation(entity.getLocation())); + + org.bukkit.entity.Entity victim = event.getEntity(); + Island island = islandManager.getIslandAtLocation(victim.getLocation()); + + if(island != null) { + org.bukkit.entity.Entity attacker = event.getDamager(); + if(attacker instanceof Projectile && ((Projectile) attacker).getShooter() instanceof org.bukkit.entity.Entity) { + attacker = (org.bukkit.entity.Entity) ((Projectile) attacker).getShooter(); } - - return; - } - - if (event.getEntity() instanceof Player) { - Player player = (Player) event.getEntity(); - - // Check permissions. - plugin.getPermissionManager() - .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true); - - } else if((event.getDamager() instanceof org.bukkit.entity.Projectile - && ((Projectile) event.getDamager()).getShooter() instanceof Player)){ - Player player = (Player) ((Projectile) event.getDamager()).getShooter(); - plugin.getPermissionManager() - .processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation())); - } else { // Make it work with all the entities, not just TNT - org.bukkit.entity.Entity entity = event.getEntity(); - - // Check permissions. - plugin.getPermissionManager() - .processPermission(event, islandManager.getIslandAtLocation(entity.getLocation())); - } - - // Fix a bug in minecraft where arrows with flame still apply fire ticks even if - // the shot entity isn't damaged - if (event.isCancelled() && event.getDamager() instanceof Arrow - && ((Arrow) event.getDamager()).getShooter() instanceof Player) { - Arrow arrow = (Arrow) event.getDamager(); - if (arrow.getFireTicks() != 0) { - preventFireTicks.add(event.getEntity().getUniqueId()); - new BukkitRunnable() { - public void run() { - preventFireTicks.remove(event.getEntity().getUniqueId()); - } - }.runTaskLater(SkyBlock.getInstance(), 5L); + + if(victim instanceof Player && attacker instanceof Player) { // PVP + if(plugin.getPermissionManager() + .processPermission(event, (Player) attacker, island)) { + plugin.getPermissionManager() + .processPermission(event, (Player) victim, island); + } + } else if(victim instanceof Player) { // EVP + plugin.getPermissionManager() + .processPermission(event, (Player) victim, island, true); + } else if(attacker instanceof Player) { // PVE + plugin.getPermissionManager() + .processPermission(event, (Player) attacker, island); + } else { // EVE + plugin.getPermissionManager() + .processPermission(event, island); + } + + // Fix a bug in minecraft where arrows with flame still apply fire ticks even if + // the shot entity isn't damaged + if (event.isCancelled() && event.getDamager() instanceof Arrow) { + Arrow arrow = (Arrow) event.getDamager(); + if (arrow.getFireTicks() != 0) { + preventFireTicks.add(event.getEntity().getUniqueId()); + Bukkit.getScheduler().runTaskLater(plugin, + () -> preventFireTicks.remove(event.getEntity().getUniqueId()), + 5L); + } } } } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onPlayerShearEntity(PlayerShearEntityEvent event) { Player player = event.getPlayer(); @@ -161,7 +151,7 @@ public class Entity implements Listener { * * @author LimeGlass */ - @EventHandler + @EventHandler(ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event) { org.bukkit.entity.Entity entity = event.getEntity(); WorldManager worldManager = plugin.getWorldManager(); @@ -184,11 +174,10 @@ public class Entity implements Listener { // Both entities are on different islands. if (!entityIsland.getIslandUUID().equals(targetIsland.getIslandUUID())) { event.setCancelled(true); - return; } } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onStackableInteract(PlayerArmorStandManipulateEvent event) { Player player = event.getPlayer(); if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; @@ -213,18 +202,20 @@ public class Entity implements Listener { } } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onHangingPlace(HangingPlaceEvent event) { Player player = event.getPlayer(); - if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; - IslandManager islandManager = plugin.getIslandManager(); - - // Check permissions. - plugin.getPermissionManager().processPermission(event, player, - islandManager.getIslandAtLocation(event.getEntity().getLocation())); + if (player != null) { + if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) return; + IslandManager islandManager = plugin.getIslandManager(); + + // Check permissions. + plugin.getPermissionManager().processPermission(event, player, + islandManager.getIslandAtLocation(event.getEntity().getLocation())); + } } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onHangingBreak(HangingBreakEvent event) { Hanging hanging = event.getEntity(); @@ -236,7 +227,7 @@ public class Entity implements Listener { islandManager.getIslandAtLocation(hanging.getLocation())); } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onHangingBreak(HangingBreakByEntityEvent event) { Hanging hanging = event.getEntity(); @@ -252,7 +243,7 @@ public class Entity implements Listener { islandManager.getIslandAtLocation(hanging.getLocation())); } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onEntityTaming(EntityTameEvent event) { if (!(event.getOwner() instanceof Player)) return; @@ -267,8 +258,7 @@ public class Entity implements Listener { islandManager.getIslandAtLocation(entity.getLocation())); } - @EventHandler - @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled = true) public void onEntityChangeBlock(EntityChangeBlockEvent event) { org.bukkit.entity.Entity entity = event.getEntity(); @@ -315,7 +305,7 @@ public class Entity implements Listener { try { Method getBlockDataMethod = FallingBlock.class.getMethod("getBlockData"); byte data = (byte) getBlockDataMethod.invoke(fallingBlock); - if (fallingBlock.getMaterial().name().endsWith("ANVIL")) { + if (fallingBlock.getMaterial().name().endsWith("ANVIL")) { // TODO Reflection data = (byte) Math.ceil(data / 4.0); } fallingBlock.getWorld().dropItemNaturally(fallingBlock.getLocation(), new ItemStack(fallingBlock.getMaterial(), 1, data)); @@ -345,8 +335,8 @@ public class Entity implements Listener { removeBlockFromLevel(island, block); CompatibleMaterial materials; - - if (event.getTo() != null && event.getTo() != Material.AIR) { + + if (event.getTo() != Material.AIR) { materials = CompatibleMaterial.getBlockMaterial(event.getTo()); ; @@ -364,7 +354,7 @@ public class Entity implements Listener { } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) public void onEntityExplode(EntityExplodeEvent event) { org.bukkit.entity.Entity entity = event.getEntity(); @@ -463,7 +453,7 @@ public class Entity implements Listener { removeBlockFromLevel(island, CompatibleMaterial.getBlockMaterial(block.getType())); } - @EventHandler(priority = EventPriority.MONITOR) + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onEntityDeath(EntityDeathEvent event) { LivingEntity livingEntity = event.getEntity(); @@ -472,20 +462,20 @@ public class Entity implements Listener { return; } - if (NMSUtil.getVersionNumber() > 9) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) { if (livingEntity instanceof Donkey || livingEntity instanceof Mule || livingEntity instanceof ElderGuardian) return; } - if (NMSUtil.getVersionNumber() > 10) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { if (livingEntity instanceof Evoker) return; } - if (NMSUtil.getVersionNumber() > 11) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) { if (livingEntity instanceof Llama) return; } - if (NMSUtil.getVersionNumber() > 13) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) { if (livingEntity instanceof Ravager || livingEntity instanceof Illager) return; } @@ -528,7 +518,7 @@ public class Entity implements Listener { } } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) { if (!(event.getTarget() instanceof Player)) return; @@ -554,9 +544,8 @@ public class Entity implements Listener { if (raid != null) CHECKED_REASONS.add(raid); } - - @SuppressWarnings("deprecation") - @EventHandler + + @EventHandler(ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { LivingEntity entity = event.getEntity(); if (entity instanceof ArmorStand) return; @@ -601,10 +590,10 @@ public class Entity implements Listener { return; } Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { - if (NMSUtil.getVersionNumber() > 10) { // getPassengers() was added in 1.11 + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { // getPassengers() was added in 1.11 for (org.bukkit.entity.Entity passenger : entity.getPassengers()) passenger.remove(); - } else { + } else { // TODO Reflection if (entity.getPassenger() != null) entity.getPassenger().remove(); } entity.remove(); @@ -612,7 +601,7 @@ public class Entity implements Listener { event.setCancelled(true); // For other plugin API reasons. } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onDamageVehicle(VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player)) { IslandManager islandManager = plugin.getIslandManager(); @@ -620,7 +609,7 @@ public class Entity implements Listener { } } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onDestroyVehicle(VehicleDestroyEvent event) { if (!(event.getAttacker() instanceof Player)) { IslandManager islandManager = plugin.getIslandManager(); From 251a193195fb20fb968b557d006b00f715375c2e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 11:21:45 +0200 Subject: [PATCH 213/366] Small optimizations in Entity Listener --- .../songoda/skyblock/listeners/Entity.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index f34bbd84..0e0c2e7f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -37,6 +37,7 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import java.io.File; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; @@ -65,12 +66,11 @@ public class Entity implements Listener { Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - - if(configLoad.getBoolean("Island.Nether.BlazeImmuneToWaterInNether", false) && - worldManager.getIslandWorld(event.getEntity().getWorld()).equals(IslandWorld.Nether)){ - if(event.getCause().equals(DamageCause.DROWNING)){ - event.setCancelled(true); - } + + if (configLoad.getBoolean("Island.Nether.BlazeImmuneToWaterInNether", false) && + worldManager.getIslandWorld(event.getEntity().getWorld()).equals(IslandWorld.Nether) && + event.getCause().equals(DamageCause.DROWNING)) { + event.setCancelled(true); } } else if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); @@ -118,17 +118,14 @@ public class Entity implements Listener { plugin.getPermissionManager() .processPermission(event, island); } - + // Fix a bug in minecraft where arrows with flame still apply fire ticks even if // the shot entity isn't damaged - if (event.isCancelled() && event.getDamager() instanceof Arrow) { - Arrow arrow = (Arrow) event.getDamager(); - if (arrow.getFireTicks() != 0) { - preventFireTicks.add(event.getEntity().getUniqueId()); - Bukkit.getScheduler().runTaskLater(plugin, - () -> preventFireTicks.remove(event.getEntity().getUniqueId()), - 5L); - } + if (event.isCancelled() && event.getDamager() instanceof Arrow && event.getDamager().getFireTicks() != 0) { + preventFireTicks.add(event.getEntity().getUniqueId()); + Bukkit.getScheduler().runTaskLater(plugin, + () -> preventFireTicks.remove(victim.getUniqueId()), + 5L); } } } @@ -298,18 +295,19 @@ public class Entity implements Listener { && configLoad.getBoolean("Island.Spawn.Protection")) { FallingBlock fallingBlock = (FallingBlock) event.getEntity(); if (fallingBlock.getDropItem()) { - if (NMSUtil.getVersionNumber() > 12) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { fallingBlock.getWorld().dropItemNaturally(fallingBlock.getLocation(), new ItemStack(fallingBlock.getBlockData().getMaterial(), 1)); } else { try { Method getBlockDataMethod = FallingBlock.class.getMethod("getBlockData"); byte data = (byte) getBlockDataMethod.invoke(fallingBlock); - if (fallingBlock.getMaterial().name().endsWith("ANVIL")) { // TODO Reflection + if (fallingBlock.getMaterial().name().endsWith("ANVIL")) { data = (byte) Math.ceil(data / 4.0); } fallingBlock.getWorld().dropItemNaturally(fallingBlock.getLocation(), new ItemStack(fallingBlock.getMaterial(), 1, data)); - } catch (Exception ignored) { + } catch(NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); } } } From 51bb15a4f0ac577b8a09f545a2ed024638b9e52d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 12:45:50 +0200 Subject: [PATCH 214/366] floating point division --- src/main/java/com/songoda/skyblock/island/Island.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 9843540c..654fc906 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -339,7 +339,7 @@ public class Island { } public double getRadius() { - return (size / 2) + 0.5; + return (size / 2d) + 0.5d; } public boolean hasPassword() { From a6035254b3d50820c598b72ef6cc4bd98e5c02a6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 12:46:23 +0200 Subject: [PATCH 215/366] Check multiblock placement --- .../com/songoda/skyblock/listeners/Block.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index bf9eb1b9..a2939e58 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -199,7 +199,6 @@ public class Block implements Listener { } } - @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); @@ -215,13 +214,25 @@ public class Block implements Listener { Island island = islandManager.getIslandAtLocation(blockLoc); // Check permissions. - if (!plugin.getPermissionManager().processPermission(event, player, island)) + if (!plugin.getPermissionManager().processPermission(event, player, island)){ return; + } if (island == null) { event.setCancelled(true); return; } + + if(ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) { + if(event instanceof BlockMultiPlaceEvent) { + for(BlockState blockState : ((BlockMultiPlaceEvent) event).getReplacedBlockStates()) { + if(!island.equals(islandManager.getIslandAtLocation(blockState.getLocation()))) { + event.setCancelled(true); + return; + } + } + } + } if (islandLevelManager.isScanning(island)) { plugin.getMessageManager().sendMessage(player, From 86f24d306a2fe2d874d14393632f11dd5d1c291e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 12:47:09 +0200 Subject: [PATCH 216/366] Fixed for multi block placement bypass --- .../songoda/skyblock/permission/ListeningPermission.java | 3 +++ .../permission/permissions/listening/PlacePermission.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java index fcc639c1..656672d8 100644 --- a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockMultiPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.*; import org.bukkit.event.hanging.HangingBreakByEntityEvent; @@ -37,6 +38,8 @@ public abstract class ListeningPermission extends BasicPermission { public void onBreak(BlockBreakEvent event) {} public void onPlace(BlockPlaceEvent event) {} + + public void onMultiPlace(BlockMultiPlaceEvent event) {} public void onVehicleDamage(VehicleDamageEvent event) {} diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java index c09643e1..cfa494cd 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java @@ -8,6 +8,7 @@ import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockMultiPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -37,4 +38,9 @@ public class PlacePermission extends ListeningPermission { public void onPlace(BlockPlaceEvent event) { cancelAndMessage(event, event.getPlayer(), plugin, messageManager); } + + @PermissionHandler + public void onMultiPlace(BlockMultiPlaceEvent event) { + cancelAndMessage(event, event.getPlayer(), plugin, messageManager); + } } From 4afb226e37e7c1b7c4671a82149500c06d25af79 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 13:16:05 +0200 Subject: [PATCH 217/366] Fixed proxy command not working --- src/main/java/com/songoda/skyblock/island/Island.java | 8 +++----- .../java/com/songoda/skyblock/island/IslandManager.java | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 654fc906..a8664af9 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -692,11 +692,9 @@ public class Island { } public boolean hasRole(IslandRole role, UUID uuid) { - if (role == IslandRole.Owner) { - return getOwnerUUID().equals(uuid) || plugin.getIslandManager().isPlayerProxyingAnotherPlayer(uuid, getOwnerUUID()); - } - - return getRole(role).contains(uuid); + return getRole(role).contains(uuid) || + (plugin.getIslandManager().getPlayerProxyingAnotherPlayer(uuid) != null && + getRole(role).contains(plugin.getIslandManager().getPlayerProxyingAnotherPlayer(uuid))); } public void setUpgrade(Player player, Upgrade.Type type, boolean status) { diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index b84a251a..ba3e8e6f 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1606,6 +1606,10 @@ public class IslandManager { public boolean isPlayerProxyingAnotherPlayer(UUID proxying, UUID proxied) { return islandProxies.containsKey(proxying) && islandProxies.get(proxying) == proxied; } + + public UUID getPlayerProxyingAnotherPlayer(UUID proxying) { + return islandProxies.get(proxying); + } public void addProxiedPlayer(UUID toProxy, UUID proxied) { islandProxies.put(toProxy, proxied); From 4400ac4297b6a3a61bd24df7119f2dfb6233fe15 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 13:16:18 +0200 Subject: [PATCH 218/366] Fixed npe in chat command --- .../command/commands/island/ChatCommand.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 a1142150..2b902c89 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 @@ -67,13 +67,18 @@ public class ChatCommand extends SubCommand { if (playerData.getOwner() != null) { island = plugin.getIslandManager().getIsland(player); } - - Island finalIsland = island; - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(), - String.join(" ", args), configLoad.getString("Island.Chat.Format.Message")); - Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); - }); + + if (island != null) { + Island finalIsland = island; + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(), + String.join(" ", args), configLoad.getString("Island.Chat.Format.Message")); + Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); + }); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } } } } From 2b99f411c3e961f8384fa5d6830bb69b2df0f805 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 14:02:15 +0200 Subject: [PATCH 219/366] Reverted Scoreboard to a sync state --- .../scoreboard/ScoreboardManager.java | 198 +++++++++--------- 1 file changed, 102 insertions(+), 96 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index dbf35928..154d7a5b 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -39,112 +39,118 @@ public class ScoreboardManager { this.plugin = plugin; this.playerDataManager = plugin.getPlayerDataManager(); Bukkit.getScheduler().runTask(plugin, () -> reloadScoreboards(true)); - Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::updateScoreboards, 20L, 40L); + Bukkit.getScheduler().runTaskTimer(plugin, this::updateScoreboards, 20L, 40L); } private synchronized void updateScoreboards() { - final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); - final Set objectives = primary.getObjectives(); - final Set teams = primary.getTeams(); + Bukkit.getScheduler().runTask(plugin, () -> { + final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); + final Set objectives = primary.getObjectives(); + final Set teams = primary.getTeams(); - /* - * Unregister all teams or objectives that are no longer present in the main - * scoreboard. - */ - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); - - for (String name : objectiveNames) { - - if (primary.getObjective(name) != null) continue; - - final Objective objective = board.getObjective(name); - - if (objective != null) objective.unregister(); - } - - for (String name : teamNames) { - - if (primary.getTeam(name) != null) continue; - - final Team team = board.getTeam(name); - - if (team != null) team.unregister(); - } - } - } - - /* - * Update the objective/team names. - */ - - objectiveNames.clear(); - teamNames.clear(); - - for(Objective objective : objectives) { - if (primary.getObjective(objective.getName()) != null) { - objectiveNames.add(objective.getName()); - } - } - - for(Team team : teams) { - if (primary.getTeam(team.getName()) != null) { - teamNames.add(team.getName()); - } - } - - /* - * Update or add any missing information to the player's scoreboard. - */ - - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - PlayerData pd = playerDataManager.getPlayerData(player); - if(pd != null && pd.isScoreboard()){ - final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - - for (Objective primaryObjective : objectives) { + /* + * Unregister all teams or objectives that are no longer present in the main + * scoreboard. + */ + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); - Objective obj = playerBoard.getObjective(primaryObjective.getName()); - - if (obj == null) - obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); - - obj.setDisplayName(primaryObjective.getDisplayName()); - obj.setDisplaySlot(primaryObjective.getDisplaySlot()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); + for (String name : objectiveNames) { + + if (primary.getObjective(name) != null) continue; + + final Objective objective = board.getObjective(name); + + if (objective != null) objective.unregister(); } - - for (Team primaryTeam : teams) { - Team obj = playerBoard.getTeam(primaryTeam.getName()); - - if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); - - obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); - obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); - obj.setDisplayName(primaryTeam.getDisplayName()); - obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); - obj.setPrefix(primaryTeam.getPrefix()); - obj.setSuffix(primaryTeam.getSuffix()); - - for (String primaryEntry : primaryTeam.getEntries()) { - obj.addEntry(primaryEntry); - } - - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { - for (Option option : Option.values()) { - obj.setOption(option, primaryTeam.getOption(option)); + for (String name : teamNames) { + + if (primary.getTeam(name) != null) continue; + + final Team team = board.getTeam(name); + + if (team != null) team.unregister(); + } + } + } + + Bukkit.getScheduler().runTask(plugin, () -> { + /* + * Update the objective/team names. + */ + + objectiveNames.clear(); + teamNames.clear(); + + for(Objective objective : objectives) { + if (primary.getObjective(objective.getName()) != null) { + objectiveNames.add(objective.getName()); + } + } + + for(Team team : teams) { + if (primary.getTeam(team.getName()) != null) { + teamNames.add(team.getName()); + } + } + + Bukkit.getScheduler().runTask(plugin, () -> { + /* + * Update or add any missing information to the player's scoreboard. + */ + + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + PlayerData pd = playerDataManager.getPlayerData(player); + if(pd != null && pd.isScoreboard()){ + final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); + + for (Objective primaryObjective : objectives) { + + Objective obj = playerBoard.getObjective(primaryObjective.getName()); + + if (obj == null) + obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); + + obj.setDisplayName(primaryObjective.getDisplayName()); + obj.setDisplaySlot(primaryObjective.getDisplaySlot()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); + } + + for (Team primaryTeam : teams) { + + Team obj = playerBoard.getTeam(primaryTeam.getName()); + + if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); + + obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); + obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); + obj.setDisplayName(primaryTeam.getDisplayName()); + obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); + obj.setPrefix(primaryTeam.getPrefix()); + obj.setSuffix(primaryTeam.getSuffix()); + + for (String primaryEntry : primaryTeam.getEntries()) { + obj.addEntry(primaryEntry); + } + + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { + for (Option option : Option.values()) { + obj.setOption(option, primaryTeam.getOption(option)); + } + } + } } } } - } - } - } + }); + }); + }); } public synchronized void reloadScoreboards(boolean createNew) { From 96b440cec3f782287a586dee383c0b4a032dc6ca Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 14:16:40 +0200 Subject: [PATCH 220/366] Added parameters to Unlock command --- .../songoda/skyblock/command/commands/island/UnlockCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java index 2a75da26..7376304b 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java @@ -106,6 +106,6 @@ public class UnlockCommand extends SubCommand { @Override public String[] getArguments() { - return new String[0]; + return new String[]{"Nether", "End"}; } } From e67106cb46713de430a6435277b29dabb057b35e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 14:33:25 +0200 Subject: [PATCH 221/366] Do not generate plains in nether and end --- .../skyblock/world/generator/VoidGenerator.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index fb7b3ea7..8566635f 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -29,7 +29,21 @@ public class VoidGenerator extends ChunkGenerator { final Configuration configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); - Biome biome = CompatibleBiome.valueOf(configLoad.getString("Island.Biome.Default.Type").toUpperCase()).getBiome(); + Biome biome; + + switch (world.getEnvironment()) { + case NORMAL: + biome = CompatibleBiome.valueOf(configLoad.getString("Island.Biome.Default.Type", "PLAINS").toUpperCase()).getBiome(); + break; + case NETHER: + biome = CompatibleBiome.NETHER_WASTES.getBiome(); + break; + case THE_END: + biome = CompatibleBiome.THE_END.getBiome(); + break; + default: + throw new IllegalStateException("Unexpected value: " + world.getEnvironment()); + } if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there setChunkBiome3D(biome, biomeGrid, world); From 338119ac76a8e1b8e9772ad9e6361d81a9ae8080 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 14:44:45 +0200 Subject: [PATCH 222/366] Initial support for biome update in other dimensions --- .../skyblock/api/biome/BiomeManager.java | 3 +- .../songoda/skyblock/biome/BiomeManager.java | 8 ++--- .../commands/admin/SetBiomeCommand.java | 32 +++++++++++++++---- .../songoda/skyblock/gui/biome/GuiBiome.java | 2 +- .../skyblock/island/IslandManager.java | 2 +- .../com/songoda/skyblock/menus/Biome.java | 2 +- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java index c73ad556..b6ebdf0a 100644 --- a/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java @@ -2,6 +2,7 @@ package com.songoda.skyblock.api.biome; import com.google.common.base.Preconditions; import com.songoda.skyblock.api.island.Island; +import com.songoda.skyblock.island.IslandWorld; import org.bukkit.block.Biome; public class BiomeManager { @@ -19,6 +20,6 @@ public class BiomeManager { Preconditions.checkArgument(island != null, "Cannot set biome to null island"); Preconditions.checkArgument(biome != null, "Cannot set biome to null biome"); - this.biomeManager.setBiome(island.getIsland(), biome, null); + this.biomeManager.setBiome(island.getIsland(), IslandWorld.Normal, biome, null); } } diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 98e9018b..b5727232 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -49,17 +49,17 @@ public class BiomeManager { updatingIslands.remove(island); } - public void setBiome(Island island, Biome biome, CompleteTask task) { + public void setBiome(Island island, IslandWorld world, Biome biome, CompleteTask task) { addUpdatingIsland(island); - if (island.getLocation(IslandWorld.Normal, IslandEnvironment.Island) == null) return; + if (island.getLocation(world, IslandEnvironment.Island) == null) return; if(plugin.isPaperAsync()){ // We keep it sequentially in order to use less RAM int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d)); AtomicInteger progress = new AtomicInteger(); - ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunk, syncChunk) -> { + ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (asyncChunk, syncChunk) -> { Chunk chunk = asyncChunk.join(); if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there setChunkBiome3D(biome, chunk); // 2D for the moment @@ -95,7 +95,7 @@ public class BiomeManager { } })); } else { - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { + ChunkLoader.startChunkLoading(island, world, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { int progress = 0; for(Chunk chunk : syncChunks){ diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java index e5a6f2af..c42d9856 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java @@ -8,6 +8,7 @@ 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.IslandWorld; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.sound.SoundManager; @@ -45,9 +46,23 @@ public class SetBiomeCommand extends SubCommand { Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (args.length == 2) { + if (args.length >= 2) { String biomeName = args[1].toUpperCase().trim(); - + + IslandWorld world = null; + if(args[2] != null) { + String worldName = args[2].toUpperCase().trim(); + for(IslandWorld islandWorld : IslandWorld.values()) { + if(islandWorld.name().equalsIgnoreCase(worldName)) { + world = islandWorld; + } + } + } + + if(world == null) { + world = IslandWorld.Normal; + } + CompatibleBiome biome = null; for (CompatibleBiome cbiome : CompatibleBiome.values()) { if (cbiome.isCompatible() && cbiome.name().equals(biomeName)) { @@ -77,8 +92,10 @@ public class SetBiomeCommand extends SubCommand { } else { if (islandManager.containsIsland(islandOwnerUUID)) { Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); - biomeManager.setBiome(island, biome.getBiome(), null); - island.setBiome(biome.getBiome()); + biomeManager.setBiome(island, world, biome.getBiome(), null); + if(world.equals(IslandWorld.Normal)) { + island.setBiome(biome.getBiome()); + } } else { islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); Island island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); @@ -88,8 +105,11 @@ public class SetBiomeCommand extends SubCommand { soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { CompatibleBiome finalBiome = biome; - biomeManager.setBiome(island, biome.getBiome(), () -> { - island.setBiome(finalBiome.getBiome()); + IslandWorld finalWorld = world; + biomeManager.setBiome(island, world, biome.getBiome(), () -> { + if(finalWorld.equals(IslandWorld.Normal)) { + island.setBiome(finalBiome.getBiome()); + } }); } } diff --git a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java index de566538..ffea945f 100644 --- a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java +++ b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java @@ -189,7 +189,7 @@ public class GuiBiome extends Gui { } cooldownManager.createPlayer(CooldownType.Biome, player); Bukkit.getScheduler().runTask(plugin, () -> { - biomeManager.setBiome(island, icon.biome.getBiome(), () -> { + biomeManager.setBiome(island, IslandWorld.Normal, icon.biome.getBiome(), () -> { if(languageLoad.getBoolean("Command.Island.Biome.Completed.Should-Display-Message")){ messageManager.sendMessage(player, languageLoad.getString("Command.Island.Biome.Completed.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index ba3e8e6f..65d5dfe8 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -282,7 +282,7 @@ public class IslandManager { Biome biome = cBiome.getBiome(); Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { - plugin.getBiomeManager().setBiome(island, biome, () -> { + plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, biome, () -> { if (structure.getCommands() != null) { for (String commandList : structure.getCommands()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); diff --git a/src/main/java/com/songoda/skyblock/menus/Biome.java b/src/main/java/com/songoda/skyblock/menus/Biome.java index 2b137c2c..2ba6b24d 100644 --- a/src/main/java/com/songoda/skyblock/menus/Biome.java +++ b/src/main/java/com/songoda/skyblock/menus/Biome.java @@ -135,7 +135,7 @@ public class Biome { SBiome selectedBiomeType = SBiome.getFromGuiIcon(is.getType(), is.getData().getData()); cooldownManager.createPlayer(CooldownType.Biome, player); - biomeManager.setBiome(island, selectedBiomeType.getBiome(), null); + biomeManager.setBiome(island,IslandWorld.Normal, selectedBiomeType.getBiome(), null); island.setBiome(selectedBiomeType.getBiome()); island.save(); From 0caa61906affa0adb18a5107f9cdbc993aa39e51 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 15:09:26 +0200 Subject: [PATCH 223/366] Fix for challenges --- src/main/resources/challenges.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index 95c0b5fb..8bddd3f1 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -335,7 +335,7 @@ challenges: # BANK: gives amount to the island's bank reward: - 'CMD:eco give {player} 100' - - 'ITEM:iron_ingot 20' + - 'ITEM:iron_ingot 10' - 'ITEM:name_tag 1' # The maximum amount of time this challenge is repeatable maxtimes: 5 @@ -355,7 +355,7 @@ challenges: - '&c&lFor this challenge, you''ll need:' - '&e- 2 stacks of cobblestone' - '&c&lReward:' - - '&e- 20 iron ingots' + - '&e- 10 iron ingots' - '&e- 1 name tag' - '&e- 100 $' '2': @@ -617,7 +617,7 @@ challenges: - '&e- 1 stack of gunpowder' - '&e- 1 stack of arrows' - '&e- 1 stack of bones' - - '&c&lRewards:' + - '&c&lRewards:' - '&e- 16 iron ingots' - '&e- 8 redstone blocks' - '&e- 250 $' From 011f59b0c13dbc018680ef9250d2934ef7d25260 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 15:09:33 +0200 Subject: [PATCH 224/366] Unlimited challenges --- .../songoda/skyblock/challenge/FabledChallenge.java | 12 ++++++------ .../challenge/challenge/ChallengeCategory.java | 10 +++++++++- .../skyblock/challenge/challenge/ItemChallenge.java | 12 +++++++++++- src/main/resources/challenges.yml | 4 ++-- src/main/resources/language.yml | 2 ++ 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java b/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java index ede403f1..13532dff 100644 --- a/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/FabledChallenge.java @@ -11,13 +11,13 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; public class FabledChallenge { - private SkyBlock plugin; - private ChallengeManager challengeManager; - private PlayerManager playerManager; + private final SkyBlock plugin; + private final ChallengeManager challengeManager; + private final PlayerManager playerManager; // I use my own inventory api bc it's hard to implement inventories with the - private InventoryManager inventoryManager; - private DefaultInventory defaultInventory; - private ChallengeInventory challengeInventory; + private final InventoryManager inventoryManager; + private final DefaultInventory defaultInventory; + private final ChallengeInventory challengeInventory; public FabledChallenge(SkyBlock plugin) { this.plugin = plugin; diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java index 695c748d..8507ac82 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java @@ -38,7 +38,15 @@ public class ChallengeCategory { String name = ChatColor.translateAlternateColorCodes('&', config.getString(key + ".name")); List require = toColor(config.getStringList(key + ".require")); List reward = toColor(config.getStringList(key + ".reward")); - int maxTimes = config.getInt(key + ".maxtimes"); + int maxTimes = 0; + try { + Integer.parseInt(config.getString(key + ".maxtimes", "unlimited")); + maxTimes = config.getInt(key + ".maxtimes"); + } catch(NumberFormatException ignored) { + if(config.getString(key + ".maxtimes", "unlimited").equalsIgnoreCase("unlimited")) { + maxTimes = Integer.MAX_VALUE; + } + } boolean showInChat = config.getBoolean(key + ".showInChat"); // Item boolean show = config.getBoolean(key + ".item.show"); diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java index f2a8ea8a..42522b60 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java @@ -38,14 +38,24 @@ public class ItemChallenge { } public ItemStack createItem(UUID player, int amount) { + FileManager.Config langConfig = SkyBlock.getInstance().getFileManager() + .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")); + FileConfiguration langConfigLoad = langConfig.getFileConfiguration(); + ItemStack is = type.getItem(); is.setAmount(this.amount); // Air ItemMeta im = is.getItemMeta(); if (im != null) { + String maxAmount; + if(challenge.getMaxTimes() == Integer.MAX_VALUE) { + maxAmount = langConfigLoad.getString("Challenge.Inventory.Unlimited.Message"); + } else { + maxAmount = String.valueOf(challenge.getMaxTimes()); + } im.setDisplayName(ChatColor.translateAlternateColorCodes('&', itemTitle.replace("%challenge", challenge.getName()).replace("%amount", Integer.toString(amount)) - .replace("%max", Integer.toString(challenge.getMaxTimes())))); + .replace("%max", maxAmount))); im.setLore(lore); is.setItemMeta(im); } diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index 8bddd3f1..5e9f79c4 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -337,8 +337,8 @@ challenges: - 'CMD:eco give {player} 100' - 'ITEM:iron_ingot 10' - 'ITEM:name_tag 1' - # The maximum amount of time this challenge is repeatable - maxtimes: 5 + # The maximum amount of time this challenge is repeatable. Unlimited for endless challenge + maxtimes: Unlimited # If true, broadcast a message when this challenge is completed showInChat: true item: diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 7e0ae24f..e886b5a0 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -3874,6 +3874,8 @@ Hologram: Message: '%blocks: %amount' Challenge: Inventory: + Unlimited: + Message: 'Unlimited' Item: Title: '%challenge &e%amount &6/ &e%max' Broadcast: '&bSkyBlock &8| &6%player &7has completed challenge %challenge (%amount From 7d11802471777ad19c157636aa5f21d8943da99d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 17:17:02 +0200 Subject: [PATCH 225/366] Fix wrong imports --- src/main/java/com/songoda/skyblock/listeners/Block.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index a2939e58..aaa2c170 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -672,7 +672,7 @@ public class Block implements Listener { if(onlyOwner && plugin.getVaultPermission() != null) { OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); event.setCancelled(true); - World finalWorld = event.getBlock().getWorld(); + org.bukkit.World finalWorld = event.getBlock().getWorld(); Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || @@ -715,7 +715,7 @@ public class Block implements Listener { } } - private boolean applyGenerator(World world, org.bukkit.block.Block block, WorldManager worldManager, IslandLevelManager islandLevelManager, Island island, BlockState state, GeneratorManager generatorManager, Generator generator) { + private boolean applyGenerator(org.bukkit.World world, org.bukkit.block.Block block, WorldManager worldManager, IslandLevelManager islandLevelManager, Island island, BlockState state, GeneratorManager generatorManager, Generator generator) { if(worldManager.getIslandWorld(world).equals(generator.getIsWorld())){ BlockState genState = generatorManager.generateBlock(generator, block); state.setType(genState.getType()); From b40afbe16781b0eaf61dd22b9ea8e5ead5e16467 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 17:17:25 +0200 Subject: [PATCH 226/366] Fix for biomes broken in 2.3.4 in Nether and End --- .../java/com/songoda/skyblock/SkyBlock.java | 1 + .../com/songoda/skyblock/listeners/World.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/listeners/World.java diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index b64589fe..7f5e8e70 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -213,6 +213,7 @@ public class SkyBlock extends SongodaPlugin { pluginManager.registerEvents(new Grow(this), this); pluginManager.registerEvents(new Piston(this), this); pluginManager.registerEvents(new FallBreak(this), this); + pluginManager.registerEvents(new World(this), this); if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this); diff --git a/src/main/java/com/songoda/skyblock/listeners/World.java b/src/main/java/com/songoda/skyblock/listeners/World.java new file mode 100644 index 00000000..e082cb94 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/listeners/World.java @@ -0,0 +1,48 @@ +package com.songoda.skyblock.listeners; + +import com.songoda.core.compatibility.CompatibleBiome; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.biome.BiomeManager; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandWorld; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; + +public class World implements Listener { + + private final SkyBlock plugin; + + public World(SkyBlock plugin) { + this.plugin = plugin; + } + + // Hotfix for wrong biome in other worlds; + @EventHandler(ignoreCancelled = true) + public void onWorldChange(PlayerChangedWorldEvent event) { + IslandManager islandManager = plugin.getIslandManager(); + BiomeManager biomeManager = plugin.getBiomeManager(); + + Location to = event.getPlayer().getLocation(); + Island island = islandManager.getIslandAtLocation(to); + + if(island != null) { + switch (to.getWorld().getEnvironment()) { + case NORMAL: + break; + case NETHER: + if(!to.getBlock().getBiome().equals(CompatibleBiome.NETHER_WASTES.getBiome())) { + biomeManager.setBiome(island, IslandWorld.Nether, CompatibleBiome.NETHER_WASTES.getBiome(), null); + } + break; + case THE_END: + if(!to.getBlock().getBiome().equals(CompatibleBiome.THE_END.getBiome())) { + biomeManager.setBiome(island, IslandWorld.End, CompatibleBiome.THE_END.getBiome(), null); + } + break; + } + } + } +} From b71a5e79e990ff3dd70be83df99e04ee2cc968d7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 17:30:14 +0200 Subject: [PATCH 227/366] Simplify code --- src/main/java/com/songoda/skyblock/listeners/Teleport.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index 251c104c..a7d5a5df 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -55,8 +55,7 @@ public class Teleport implements Listener { Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if(worldManager.isIslandWorld(event.getFrom().getWorld()) - || (event.getTo() != null && worldManager.isIslandWorld(event.getTo().getWorld()))) { + if(worldManager.isIslandWorld(event.getFrom().getWorld()) || worldManager.isIslandWorld(event.getTo().getWorld())) { Bukkit.getScheduler().runTaskLater(plugin, () -> islandManager.updateFlight(player), 1L); } islandManager.loadPlayer(player); From b48ad784715c863a0288cf454bb32a496054576b Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 17:40:25 +0200 Subject: [PATCH 228/366] Deprecate a method --- .../java/com/songoda/skyblock/limit/impl/BlockLimitation.java | 1 + src/main/java/com/songoda/skyblock/listeners/Block.java | 2 +- src/main/java/com/songoda/skyblock/listeners/Interact.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) 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 58d63665..756b3870 100644 --- a/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java +++ b/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java @@ -56,6 +56,7 @@ public final class BlockLimitation extends EnumLimitation { } + @Deprecated public long getBlockLimit(Player player, Block block) { return this.getBlockLimit(player, block.getType()); } diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index aaa2c170..40960d3c 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -302,7 +302,7 @@ public class Block implements Listener { BlockLimitation limits = plugin.getLimitationHandler().getInstance(BlockLimitation.class); - long limit = limits.getBlockLimit(player, block); + long limit = limits.getBlockLimit(player, block.getType()); if (limits.isBlockLimitExceeded(block, limit)) { CompatibleMaterial material = null; diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 5b11faca..15670455 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -188,7 +188,7 @@ public class Interact implements Listener { BlockLimitation limits = plugin.getLimitationHandler().getInstance(BlockLimitation.class); - long limit = limits.getBlockLimit(player, block); + long limit = limits.getBlockLimit(player, block.getType()); if (limits.isBlockLimitExceeded(block, limit)) { plugin.getMessageManager().sendMessage(player, From 38fa050576b92bb14daba0b87135b90cc8bc3e4c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 17:44:15 +0200 Subject: [PATCH 229/366] Removed unused imports --- .../com/songoda/skyblock/gui/permissions/GuiPermissions.java | 2 -- .../java/com/songoda/skyblock/scoreboard/ScoreboardManager.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java index 7de71d08..fd5e6303 100644 --- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java +++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java @@ -6,7 +6,6 @@ import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.gui.GuiSignatureEditor; import com.songoda.skyblock.gui.GuiWelcomeEditor; import com.songoda.skyblock.island.Island; @@ -23,7 +22,6 @@ import org.bukkit.entity.Player; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 154d7a5b..33b102dc 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -11,12 +11,10 @@ import com.songoda.skyblock.island.IslandManager; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team.Option; From 6420666a7a5e9627d62872a4a5856bfaf82d7274 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 18:33:48 +0200 Subject: [PATCH 230/366] 2.3.5-RC5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7a630588..28b11e36 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC5-DEV3 + 2.3.5-RC5 jar UTF-8 From facb19000cedd14ecc93e469dfd1949d8e25b913 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 18:33:58 +0200 Subject: [PATCH 231/366] Ignore empty messages --- src/main/java/com/songoda/skyblock/message/MessageManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/message/MessageManager.java b/src/main/java/com/songoda/skyblock/message/MessageManager.java index 061f910d..5285d36f 100644 --- a/src/main/java/com/songoda/skyblock/message/MessageManager.java +++ b/src/main/java/com/songoda/skyblock/message/MessageManager.java @@ -19,7 +19,8 @@ public class MessageManager { public void sendMessage(CommandSender sender, String message) { - if (message == null) return; + if (message == null || message.equals("")) return; + if (sender instanceof Player) { PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); From 6327a33b4a7e90c35875af89e1d9058b53997a28 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 19:17:32 +0200 Subject: [PATCH 232/366] Fixed size perm --- src/main/java/com/songoda/skyblock/island/Island.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index a8664af9..69eda110 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -124,6 +124,8 @@ public class Island { if (configLoad.getString("Size") != null) { size = configLoad.getInt("Size"); + } else { + configLoad.set("Size", size); } if (configLoad.getString("Settings") != null) { From e9b1a070838bb69807622650704ac9688ed450c1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 19:17:48 +0200 Subject: [PATCH 233/366] 2.3.5-RC6-DEV1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28b11e36..cbe6e6c6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC5 + 2.3.5-RC6-DEV1 jar UTF-8 From 8f3bbfadfca5c1943f70b479351a50e500c9c26d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 19:32:01 +0200 Subject: [PATCH 234/366] Finalizing the fix --- src/main/java/com/songoda/skyblock/island/Island.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 69eda110..cd8107cd 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -44,7 +44,7 @@ public class Island { private UUID islandUUID; private UUID ownerUUID; - private IslandLevel level; + private final IslandLevel level; private IslandStatus status; private int size; private int maxMembers; @@ -242,6 +242,7 @@ public class Island { 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()); + configLoad.set("Size", size); for (IslandRole roleList : IslandRole.getRoles()) { List allPermissions = plugin.getPermissionManager().getPermissions(); @@ -258,7 +259,6 @@ public class Island { status = IslandStatus.getEnum(mainConfigLoad.getString("Island.Visitor.Status")); - save(); Player onlinePlayer = Bukkit.getServer().getPlayer(ownerUUID); @@ -272,7 +272,9 @@ public class Island { playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date())); playerData.save(); } - + + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); + if (!mainConfigLoad.getBoolean("Island.Coop.Unload")) { File coopDataFile = new File(plugin.getDataFolder().toString() + "/coop-data", getOwnerUUID().toString() + ".yml"); From 74eae7037a3e64d4770a642ed5348e53fa89d0cd Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 19:32:30 +0200 Subject: [PATCH 235/366] 2.3.5-RC6-DEV2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cbe6e6c6..7c70fe71 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC6-DEV1 + 2.3.5-RC6-DEV2 jar UTF-8 From 80cc409899dd3d212e91b5573a5b8d9346270355 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 19:36:13 +0200 Subject: [PATCH 236/366] Redo async scoreboards --- .../scoreboard/ScoreboardManager.java | 192 +++++++++--------- 1 file changed, 93 insertions(+), 99 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 33b102dc..60f57dfd 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -37,118 +37,112 @@ public class ScoreboardManager { this.plugin = plugin; this.playerDataManager = plugin.getPlayerDataManager(); Bukkit.getScheduler().runTask(plugin, () -> reloadScoreboards(true)); - Bukkit.getScheduler().runTaskTimer(plugin, this::updateScoreboards, 20L, 40L); + Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::updateScoreboards, 20L, 40L); } private synchronized void updateScoreboards() { - Bukkit.getScheduler().runTask(plugin, () -> { - final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); - final Set objectives = primary.getObjectives(); - final Set teams = primary.getTeams(); - - /* - * Unregister all teams or objectives that are no longer present in the main - * scoreboard. - */ - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); + final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); + final Set objectives = primary.getObjectives(); + final Set teams = primary.getTeams(); + + /* + * Unregister all teams or objectives that are no longer present in the main + * scoreboard. + */ + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); + + for (String name : objectiveNames) { - for (String name : objectiveNames) { - - if (primary.getObjective(name) != null) continue; - - final Objective objective = board.getObjective(name); - - if (objective != null) objective.unregister(); - } + if (primary.getObjective(name) != null) continue; - for (String name : teamNames) { - - if (primary.getTeam(name) != null) continue; - - final Team team = board.getTeam(name); - - if (team != null) team.unregister(); - } + final Objective objective = board.getObjective(name); + + if (objective != null) objective.unregister(); + } + + for (String name : teamNames) { + + if (primary.getTeam(name) != null) continue; + + final Team team = board.getTeam(name); + + if (team != null) team.unregister(); } } + } + + /* + * Update the objective/team names. + */ + + objectiveNames.clear(); + teamNames.clear(); + + for(Objective objective : objectives) { + if (primary.getObjective(objective.getName()) != null) { + objectiveNames.add(objective.getName()); + } + } + + for(Team team : teams) { + if (primary.getTeam(team.getName()) != null) { + teamNames.add(team.getName()); + } + } + + /* + * Update or add any missing information to the player's scoreboard. + */ + + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + PlayerData pd = playerDataManager.getPlayerData(player); + if(pd != null && pd.isScoreboard()){ + final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - Bukkit.getScheduler().runTask(plugin, () -> { - /* - * Update the objective/team names. - */ - - objectiveNames.clear(); - teamNames.clear(); - - for(Objective objective : objectives) { - if (primary.getObjective(objective.getName()) != null) { - objectiveNames.add(objective.getName()); + for (Objective primaryObjective : objectives) { + + Objective obj = playerBoard.getObjective(primaryObjective.getName()); + + if (obj == null) + obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); + + obj.setDisplayName(primaryObjective.getDisplayName()); + obj.setDisplaySlot(primaryObjective.getDisplaySlot()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); } - } - for(Team team : teams) { - if (primary.getTeam(team.getName()) != null) { - teamNames.add(team.getName()); - } - } - - Bukkit.getScheduler().runTask(plugin, () -> { - /* - * Update or add any missing information to the player's scoreboard. - */ - - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - PlayerData pd = playerDataManager.getPlayerData(player); - if(pd != null && pd.isScoreboard()){ - final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - - for (Objective primaryObjective : objectives) { - - Objective obj = playerBoard.getObjective(primaryObjective.getName()); - - if (obj == null) - obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); - - obj.setDisplayName(primaryObjective.getDisplayName()); - obj.setDisplaySlot(primaryObjective.getDisplaySlot()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); - } - - for (Team primaryTeam : teams) { - - Team obj = playerBoard.getTeam(primaryTeam.getName()); - - if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); - - obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); - obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); - obj.setDisplayName(primaryTeam.getDisplayName()); - obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); - obj.setPrefix(primaryTeam.getPrefix()); - obj.setSuffix(primaryTeam.getSuffix()); - - for (String primaryEntry : primaryTeam.getEntries()) { - obj.addEntry(primaryEntry); - } - - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { - for (Option option : Option.values()) { - obj.setOption(option, primaryTeam.getOption(option)); - } - } - } + for (Team primaryTeam : teams) { + + Team obj = playerBoard.getTeam(primaryTeam.getName()); + + if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); + + obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); + obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); + obj.setDisplayName(primaryTeam.getDisplayName()); + obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); + obj.setPrefix(primaryTeam.getPrefix()); + obj.setSuffix(primaryTeam.getSuffix()); + + for (String primaryEntry : primaryTeam.getEntries()) { + obj.addEntry(primaryEntry); + } + + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { + for (Option option : Option.values()) { + obj.setOption(option, primaryTeam.getOption(option)); } } } - }); - }); - }); + } + } + } } public synchronized void reloadScoreboards(boolean createNew) { From 4452fa33fc00c2da6fe73475af399e4d1fa7d5ff Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 19:42:56 +0200 Subject: [PATCH 237/366] Edit sync-async scoreboard --- .../scoreboard/ScoreboardManager.java | 182 +++++++++--------- 1 file changed, 92 insertions(+), 90 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 60f57dfd..6b73bd82 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -37,7 +37,7 @@ public class ScoreboardManager { this.plugin = plugin; this.playerDataManager = plugin.getPlayerDataManager(); Bukkit.getScheduler().runTask(plugin, () -> reloadScoreboards(true)); - Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::updateScoreboards, 20L, 40L); + Bukkit.getScheduler().runTaskTimer(plugin, this::updateScoreboards, 20L, 40L); } private synchronized void updateScoreboards() { @@ -45,104 +45,106 @@ public class ScoreboardManager { final Set objectives = primary.getObjectives(); final Set teams = primary.getTeams(); - /* - * Unregister all teams or objectives that are no longer present in the main - * scoreboard. - */ - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); - - for (String name : objectiveNames) { + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + /* + * Unregister all teams or objectives that are no longer present in the main + * scoreboard. + */ + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); - if (primary.getObjective(name) != null) continue; - - final Objective objective = board.getObjective(name); - - if (objective != null) objective.unregister(); - } - - for (String name : teamNames) { - - if (primary.getTeam(name) != null) continue; - - final Team team = board.getTeam(name); - - if (team != null) team.unregister(); - } - } - } - - /* - * Update the objective/team names. - */ - - objectiveNames.clear(); - teamNames.clear(); - - for(Objective objective : objectives) { - if (primary.getObjective(objective.getName()) != null) { - objectiveNames.add(objective.getName()); - } - } - - for(Team team : teams) { - if (primary.getTeam(team.getName()) != null) { - teamNames.add(team.getName()); - } - } - - /* - * Update or add any missing information to the player's scoreboard. - */ - - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - PlayerData pd = playerDataManager.getPlayerData(player); - if(pd != null && pd.isScoreboard()){ - final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - - for (Objective primaryObjective : objectives) { - - Objective obj = playerBoard.getObjective(primaryObjective.getName()); - - if (obj == null) - obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); - - obj.setDisplayName(primaryObjective.getDisplayName()); - obj.setDisplaySlot(primaryObjective.getDisplaySlot()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); + for (String name : objectiveNames) { + + if (primary.getObjective(name) != null) continue; + + final Objective objective = board.getObjective(name); + + if (objective != null) objective.unregister(); } + + for (String name : teamNames) { + + if (primary.getTeam(name) != null) continue; + + final Team team = board.getTeam(name); + + if (team != null) team.unregister(); + } + } + } - for (Team primaryTeam : teams) { - - Team obj = playerBoard.getTeam(primaryTeam.getName()); - - if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); - - obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); - obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); - obj.setDisplayName(primaryTeam.getDisplayName()); - obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); - obj.setPrefix(primaryTeam.getPrefix()); - obj.setSuffix(primaryTeam.getSuffix()); - - for (String primaryEntry : primaryTeam.getEntries()) { - obj.addEntry(primaryEntry); + /* + * Update the objective/team names. + */ + + objectiveNames.clear(); + teamNames.clear(); + + for(Objective objective : objectives) { + if (primary.getObjective(objective.getName()) != null) { + objectiveNames.add(objective.getName()); + } + } + + for(Team team : teams) { + if (primary.getTeam(team.getName()) != null) { + teamNames.add(team.getName()); + } + } + + /* + * Update or add any missing information to the player's scoreboard. + */ + + for (UUID uuid : scoreboardStorage.keySet()) { + Player player = Bukkit.getPlayer(uuid); + if(player != null) { + PlayerData pd = playerDataManager.getPlayerData(player); + if(pd != null && pd.isScoreboard()){ + final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); + + for (Objective primaryObjective : objectives) { + + Objective obj = playerBoard.getObjective(primaryObjective.getName()); + + if (obj == null) + obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); + + obj.setDisplayName(primaryObjective.getDisplayName()); + obj.setDisplaySlot(primaryObjective.getDisplaySlot()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); } - - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { - for (Option option : Option.values()) { - obj.setOption(option, primaryTeam.getOption(option)); + + for (Team primaryTeam : teams) { + + Team obj = playerBoard.getTeam(primaryTeam.getName()); + + if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); + + obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); + obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); + obj.setDisplayName(primaryTeam.getDisplayName()); + obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); + obj.setPrefix(primaryTeam.getPrefix()); + obj.setSuffix(primaryTeam.getSuffix()); + + for (String primaryEntry : primaryTeam.getEntries()) { + obj.addEntry(primaryEntry); + } + + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { + for (Option option : Option.values()) { + obj.setOption(option, primaryTeam.getOption(option)); + } } } } } } - } + }); } public synchronized void reloadScoreboards(boolean createNew) { From 5c0305e9509c16088b0723916b72df5bc95bb9d6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 19:46:17 +0200 Subject: [PATCH 238/366] Fix for scoreboard on login --- src/main/java/com/songoda/skyblock/listeners/Join.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index 02d49c83..66ffa190 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -94,7 +94,7 @@ public class Join implements Listener { PlayerData playerData = playerDataManager.getPlayerData(player); playerData.setTexture(playerTexture[0], playerTexture[1]); - playerData.save(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, playerData::save); } else { playerDataManager.createPlayerData(player); playerDataManager.loadPlayerData(player); @@ -106,7 +106,7 @@ public class Join implements Listener { cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player)); cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player)); - if (scoreboardManager != null) { + if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) { scoreboardManager.addPlayer(player); } From 9b46a0d0dcca8733014feeeb2f36ed755e4e2518 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 13:33:20 +0200 Subject: [PATCH 239/366] Optimized Island management --- .../songoda/skyblock/biome/BiomeManager.java | 126 ++++++------------ .../skyblock/blockscanner/BlockScanner.java | 7 +- .../skyblock/blockscanner/ChunkLoader.java | 31 ++--- .../skyblock/island/IslandManager.java | 52 +++----- .../skyblock/levelling/IslandScan.java | 20 ++- 5 files changed, 74 insertions(+), 162 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index b5727232..5719ca7d 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -53,96 +53,46 @@ public class BiomeManager { addUpdatingIsland(island); if (island.getLocation(world, IslandEnvironment.Island) == null) return; - - if(plugin.isPaperAsync()){ - // We keep it sequentially in order to use less RAM - int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d)); - AtomicInteger progress = new AtomicInteger(); + + // We keep it sequentially in order to use less RAM + int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d)); + AtomicInteger progress = new AtomicInteger(); + + ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (futureChunk) -> { + Chunk chunk = futureChunk.join(); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there + setChunkBiome3D(biome, chunk); + } else { + try { + setChunkBiome2D(biome, chunk); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } + } + updateBiomePacket(island, chunk); + + progress.getAndIncrement(); + + if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") && + progress.get() == 1 || progress.get() == chunkAmount || progress.get() % runEveryX == 0){ + final double percent = ((double) progress.get() / (double) chunkAmount) * 100; - ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (asyncChunk, syncChunk) -> { - Chunk chunk = asyncChunk.join(); - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(biome, chunk); // 2D for the moment - } else { - try { - setChunkBiome2D(biome, chunk); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); - } + String message = language.getString("Command.Island.Biome.Progress.Message"); + message = message.replace("%current_updated_chunks%", String.valueOf(progress.get())); + message = message.replace("%max_chunks%", String.valueOf(chunkAmount)); + message = message.replace("%percent_whole%", String.valueOf((int) percent)); + message = message.replace("%percent%", NumberFormat.getInstance().format(percent)); + + for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { + plugin.getMessageManager().sendMessage(player, message); } - updateBiomePacket(island, chunk); - - progress.getAndIncrement(); - - if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") && - progress.get() == 1 || progress.get() == chunkAmount || progress.get() % runEveryX == 0){ - final double percent = ((double) progress.get() / (double) chunkAmount) * 100; - - String message = language.getString("Command.Island.Biome.Progress.Message"); - message = message.replace("%current_updated_chunks%", String.valueOf(progress.get())); - message = message.replace("%max_chunks%", String.valueOf(chunkAmount)); - message = message.replace("%percent_whole%", String.valueOf((int) percent)); - message = message.replace("%percent%", NumberFormat.getInstance().format(percent)); - - for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { - plugin.getMessageManager().sendMessage(player, message); - } - } - }, (island1 -> { - removeUpdatingIsland(island1); - if(task != null) { - task.onCompleteUpdate(); - } - })); - } else { - ChunkLoader.startChunkLoading(island, world, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - int progress = 0; - for(Chunk chunk : syncChunks){ - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there - setChunkBiome3D(biome, chunk); // 2D for the moment - } else { - try { - setChunkBiome2D(biome, chunk); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); - } - } - if(ServerVersion.isServerVersionAtLeast(ASYNC_OBFUSCATOR_VERSION)) { - updateBiomePacket(island, chunk); - } - progress++; - - if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") && - progress == 1 || progress == syncChunks.size() || progress % runEveryX == 0){ - final double percent = ((double) progress / (double) syncChunks.size()) * 100; - - String message = language.getString("Command.Island.Biome.Progress.Message"); - message = message.replace("%current_updated_chunks%", String.valueOf(progress)); - message = message.replace("%max_chunks%", String.valueOf(syncChunks.size())); - message = message.replace("%percent_whole%", String.valueOf((int) percent)); - message = message.replace("%percent%", NumberFormat.getInstance().format(percent)); - - for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) { - plugin.getMessageManager().sendMessage(player, message); - } - } - } - if(ServerVersion.isServerVersionBelow(ASYNC_OBFUSCATOR_VERSION)) { - Bukkit.getScheduler().runTask(plugin, () -> { - for(Chunk chunk : syncChunks){ - updateBiomePacket(island, chunk); - } - }); - } - }); - }, (island1 -> { - removeUpdatingIsland(island1); - if(task != null) { - task.onCompleteUpdate(); - } - })); - } + } + }, (island1 -> { + removeUpdatingIsland(island1); + if(task != null) { + task.onCompleteUpdate(); + } + })); } private void setChunkBiome2D(Biome biome, Chunk chunk) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index 8cd3f4bd..054fa1e1 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -57,12 +57,10 @@ public final class BlockScanner extends BukkitRunnable { private final Queue blocks; private final ScannerTasks tasks; - private boolean ignoreLiquids; - private boolean ignoreLiquidsY; - private boolean ignoreAir; + private final boolean ignoreLiquids; + private final boolean ignoreAir; private BlockScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { - this.ignoreLiquidsY = ignoreLiquidsY; this.ignoreLiquids = ignoreLiquids; this.ignoreAir = ignoreAir; this.blocks = new ConcurrentLinkedQueue<>(); @@ -105,7 +103,6 @@ public final class BlockScanner extends BukkitRunnable { for (List sub : parts) { queueWork(world, startY, sub); } - } this.threadCount = threadCount; diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java index ebe7d7fb..1ffbeda3 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -16,8 +16,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; public class ChunkLoader extends BukkitRunnable { - public final List> asyncPositions = new LinkedList<>(); - public final List syncPositions = new LinkedList<>(); + public final List> positions = new LinkedList<>(); private ChunkScannerTask generalTask; private ChunkForChunkScannerTask chunkTask; @@ -60,7 +59,7 @@ public class ChunkLoader extends BukkitRunnable { x = minX; z = minZ; - + if(paper){ this.runTaskAsynchronously(SkyBlock.getInstance()); } else { @@ -109,20 +108,10 @@ public class ChunkLoader extends BukkitRunnable { if(x < maxX){ if(z < maxZ){ if(!chunkForChunk){ - if(paper){ - asyncPositions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); - } else { - syncPositions.add(world.getChunkAt(x >> 4, z >> 4)); - } + positions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); } else { - if(paper){ - if(chunkTask != null) { - chunkTask.onChunkComplete(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4), null); - } - } else { - if(chunkTask != null) { - chunkTask.onChunkComplete(null, world.getChunkAt(x >> 4, z >> 4)); - } + if(chunkTask != null) { + chunkTask.onChunkComplete(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); } } @@ -133,7 +122,7 @@ public class ChunkLoader extends BukkitRunnable { } } else { if(generalTask != null) { - generalTask.onComplete(asyncPositions, syncPositions); + generalTask.onComplete(positions); } if(completeTask != null) { completeTask.onComplete(island); @@ -153,15 +142,11 @@ public class ChunkLoader extends BukkitRunnable { } public interface ChunkScannerTask { - - void onComplete(List> asyncChunks, List syncChunks); - + void onComplete(List> chunks); } public interface ChunkForChunkScannerTask { - - void onChunkComplete(CompletableFuture asyncChunk, Chunk syncChunk); - + void onChunkComplete(CompletableFuture chunk); } public interface CompleteTask { diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 65d5dfe8..d403aa79 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -177,8 +177,8 @@ public class IslandManager { } posX = posX * offset; posY = posY * offset; - islandPositionList.setX((double) posX); - islandPositionList.setZ((double) posY); + islandPositionList.setX(posX); + islandPositionList.setZ(posY); // Check if there was an island at this position int oldFormatPos = oldSystemIslands.get(world); Location islandLocation = new org.bukkit.Location(plugin.getWorldManager().getWorld(world), islandPositionList.getX(), islandHeight, islandPositionList.getZ()); @@ -281,15 +281,14 @@ public class IslandManager { } Biome biome = cBiome.getBiome(); - Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { - plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, biome, () -> { - if (structure.getCommands() != null) { - for (String commandList : structure.getCommands()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); - } + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> + plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, biome, () -> { + if (structure.getCommands() != null) { + for (String commandList : structure.getCommands()) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName())); } - }); - }, 20L); + } + }), 20L); // Recalculate island level after 5 seconds if (configLoad.getBoolean("Island.Levelling.ScanAutomatically")) @@ -654,26 +653,15 @@ public class IslandManager { if (location == null) continue; final World world = worldManager.getWorld(worldList); - - if(plugin.isPaperAsync()){ - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { - List positions = new LinkedList<>(); - for (CompletableFuture chunk : asyncChunks) { - positions.add(chunk.join()); - } - snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); - ChunkDeleteSplitter.startDeletion(snapshots); - }, null); - } else { - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> { - Bukkit.getScheduler().runTask(plugin, () -> { - final List list = syncChunks.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); - - snapshots.put(world, list); - ChunkDeleteSplitter.startDeletion(snapshots); - }); - }, null); - } + + ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (chunks) -> { + List positions = new LinkedList<>(); + for (CompletableFuture chunk : chunks) { + positions.add(chunk.join()); + } + snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); + ChunkDeleteSplitter.startDeletion(snapshots); + }, null); } } @@ -826,8 +814,6 @@ public class IslandManager { Location islandLocation = fileManager.getLocation(config, "Location.Normal.Island", false); if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) { - UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", "")); - // return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)); return; } } catch (Exception e) { @@ -835,8 +821,6 @@ public class IslandManager { } } } - - return; } public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) { diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java index 26e2504f..eefd5983 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -196,19 +196,15 @@ public final class IslandScan extends BukkitRunnable { private void populate(Map> snapshots, IslandWorld world, boolean paper, PopulateTask task) { final SkyBlock plugin = SkyBlock.getInstance(); - - ChunkLoader.startChunkLoading(island, IslandWorld.Normal, paper, (asyncPositions, syncPositions) -> { - if(paper){ - List positions = new LinkedList<>(); - for(CompletableFuture chunk : asyncPositions){ - positions.add(chunk.join().getChunkSnapshot()); - } - snapshots.put(plugin.getWorldManager().getWorld(world), positions); - } else { - snapshots.put(plugin.getWorldManager().getWorld(world), syncPositions.stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList())); - } + + List positions = new LinkedList<>(); + + ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, paper, (chunkCompletableFuture) -> + positions.add(chunkCompletableFuture.join().getChunkSnapshot()), + value -> { + snapshots.put(plugin.getWorldManager().getWorld(world), positions); task.onComplete(); - }, null); + }); } private interface PopulateTask { From a58782cb0ae41729919d14c1dd18702767799ef4 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 13:33:36 +0200 Subject: [PATCH 240/366] Scoreboard max lenght 128 --- .../com/songoda/skyblock/scoreboard/Scoreboard.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java index 1d2168f4..abb0dcfa 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.scoreboard; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandLevel; @@ -70,7 +71,14 @@ public class Scoreboard { obj.setDisplaySlot(DisplaySlot.SIDEBAR); String formattedDisplayName = ChatColor.translateAlternateColorCodes('&', replaceDisplayName(displayName)); - int max = NMSUtil.getVersionNumber() > 8 ? 32 : 16; + int max; + if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { + max = 16; + } else if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { + max = 32; + } else { + max = 128; + } if (formattedDisplayName.length() > max) { obj.setDisplayName(ChatColor.RED + "Too long..."); } else { From 5142c0015a9896dc81f00b8e4c9364c0d830f043 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 13:33:48 +0200 Subject: [PATCH 241/366] Initial work to Scoreboard rewrite --- .../skyblock/scoreboard/wip/Board.java | 4 ++++ .../skyblock/scoreboard/wip/Driver.java | 16 +++++++++++++ .../skyblock/scoreboard/wip/Manager.java | 24 +++++++++++++++++++ .../songoda/skyblock/scoreboard/wip/Row.java | 4 ++++ 4 files changed, 48 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java new file mode 100644 index 00000000..59a8c178 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java @@ -0,0 +1,4 @@ +package com.songoda.skyblock.scoreboard.wip; + +public class Board { +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java new file mode 100644 index 00000000..bc52b8f8 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java @@ -0,0 +1,16 @@ +package com.songoda.skyblock.scoreboard.wip; + +import org.bukkit.scheduler.BukkitRunnable; + +public class Driver extends BukkitRunnable { + public Driver(String board) { + } + + @Override + public void run() { + + } + + public void setDefault(boolean isDefault) { + } +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java new file mode 100644 index 00000000..91054545 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java @@ -0,0 +1,24 @@ +package com.songoda.skyblock.scoreboard.wip; + +import com.songoda.skyblock.SkyBlock; + +import java.util.Map; + +public class Manager { + + Map drivers; + + public void newDriver(String board, boolean isDefault) { + Driver driver = new Driver(board); + driver.runTaskTimerAsynchronously(SkyBlock.getInstance(), 1L, 1L); + drivers.put(board, driver); + driver.setDefault(isDefault); + } + + public void clearDrivers() + { + for(Driver driver : drivers.values()) + driver.cancel(); + drivers.clear(); + } +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java new file mode 100644 index 00000000..1a430b8c --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java @@ -0,0 +1,4 @@ +package com.songoda.skyblock.scoreboard.wip; + +public class Row { +} From 6d0696b64cd13c4f8beb399f81709e5aba07322a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 16:27:21 +0200 Subject: [PATCH 242/366] Undo 128 chats in scoreboard --- src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java index abb0dcfa..134d2588 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java @@ -74,10 +74,8 @@ public class Scoreboard { int max; if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { max = 16; - } else if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { - max = 32; } else { - max = 128; + max = 32; } if (formattedDisplayName.length() > max) { obj.setDisplayName(ChatColor.RED + "Too long..."); From 91b54fd64af4cf684649428fd843549161d753c0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 16:34:07 +0200 Subject: [PATCH 243/366] 2.3.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c70fe71..63a072b1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5-RC6-DEV2 + 2.3.5 jar UTF-8 From 9a4cb931de3b5b757a4486be6e98606c4ee16f8b Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 17:49:30 +0200 Subject: [PATCH 244/366] Fixed PaperLib import --- .../java/com/songoda/skyblock/blockscanner/ChunkLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java index 1ffbeda3..dcdb88b6 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -1,10 +1,10 @@ package com.songoda.skyblock.blockscanner; -import com.sk89q.worldedit.bukkit.paperlib.PaperLib; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; +import io.papermc.lib.PaperLib; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; From 2c3b54057e6b94caa43e38f51a76d0fa019c96e0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 18:22:50 +0200 Subject: [PATCH 245/366] Fixed some messages --- src/main/resources/language.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index e886b5a0..6cf4d6ff 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -201,7 +201,7 @@ Command: Balance: Message: ' %player% have %bal%.' Info: - Message: '&bSkyBlock &8| &cError&8: /island admin bank [] [Player]' + Message: '&f&oManage a player''s island bank.' SuccesWithdraw: Message: 'Succesfully removed %ammount% from %player%''s island' SuccesDeposit: @@ -276,7 +276,7 @@ Command: Set: Message: '&bSkyBlock &8| &aInfo&8: &eYou have set &d%player''s &eIsland biome to &d%biome&e.' Info: - Message: '&f&oSets the size of a player''s Island.' + Message: '&f&oSets the biome of a player''s Island.' Invalid: Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin setbiome ' InvalidBiome: From 03efacf747addefc90f3fd4d43784f2c8e7fb751 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 18:57:08 +0200 Subject: [PATCH 246/366] Added exclusions to pom --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 63a072b1..27b88270 100644 --- a/pom.xml +++ b/pom.xml @@ -214,6 +214,12 @@ com.sk89q worldedit-bukkit 7.1.0 + + + io.papermc + paperlib + + com.songoda From 432d4b2d8c12804116b2cbf532ab986f0c636063 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 18:57:22 +0200 Subject: [PATCH 247/366] Added IronGolems settings --- .../permission/PermissionManager.java | 1 + .../listening/IronGolemPermission.java | 36 +++++++++++++++++++ .../listening/MobGriefingPermission.java | 12 ++++--- src/main/resources/language.yml | 4 +++ src/main/resources/settings.yml | 1 + 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index da139af3..8ffc6ca6 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -83,6 +83,7 @@ public class PermissionManager { new ItemDropPermission(), new FishingPermission(plugin), new CauldronPermission(plugin), + new IronGolemPermission(plugin), // Basic new MemberPermission(), diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java new file mode 100644 index 00000000..36bde502 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java @@ -0,0 +1,36 @@ +package com.songoda.skyblock.permission.permissions.listening; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.permission.ListeningPermission; +import com.songoda.skyblock.permission.PermissionHandler; +import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; +import org.bukkit.event.vehicle.VehicleDestroyEvent; + +public class IronGolemPermission extends ListeningPermission { + + private final SkyBlock plugin; + + public IronGolemPermission(SkyBlock plugin) { + super("IronGolems", CompatibleMaterial.IRON_BLOCK, PermissionType.ISLAND); + this.plugin = plugin; + } + + @PermissionHandler + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + if (event.getDamager() instanceof IronGolem) { + event.setCancelled(true); + } + } +} + diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java index 55e88cf0..f8497c44 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java @@ -5,6 +5,7 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.entity.IronGolem; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; @@ -29,7 +30,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityExplode(EntityExplodeEvent event) { if (!(event.getEntity() instanceof Player) && (!(event.getEntity() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) && !(event.getEntity() instanceof TNTPrimed) && !(event.getEntity() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -40,7 +41,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDamage(VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -51,7 +52,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDestroy(VehicleDestroyEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -62,9 +63,10 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (!(event.getDamager() instanceof Player) && (!(event.getDamager() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) && !(event.getDamager() instanceof TNTPrimed) - && !(event.getDamager() instanceof ExplosiveMinecart)) { + && !(event.getDamager() instanceof ExplosiveMinecart) + && !(event.getDamager() instanceof IronGolem)) { event.setCancelled(true); } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 6cf4d6ff..b98a1332 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1323,6 +1323,8 @@ Menu: Displayname: '&aLeaf Decay' MobGriefing: Displayname: '&aMob Griefing' + IronGolems: + Displayname: '&aIron Golems' Status: Enabled: Lore: @@ -1793,6 +1795,8 @@ Menu: Displayname: '&aNatural Mob Spawning' MobGriefing: Displayname: '&aMob Griefing' + IronGolems: + Displayname: '&aIron Golems' PvP: Displayname: '&aPvP' Explosions: diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 0e50ae85..f32380de 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -167,6 +167,7 @@ Settings: Owner: NaturalMobSpawning: true MobGriefing: true + IronGolems: true Explosions: true FireSpread: true LeafDecay: true From 73d5cf505e7b4176d154957c18c51d7f99cd1a01 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 14 Jul 2020 08:16:47 +0200 Subject: [PATCH 248/366] Removed unused managers --- src/main/java/com/songoda/skyblock/listeners/Chat.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index 6a007947..0e2bbd36 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -38,9 +38,6 @@ public class Chat implements Listener { PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); - MessageManager messageManager = plugin.getMessageManager(); - IslandManager islandManager = plugin.getIslandManager(); - FileManager fileManager = plugin.getFileManager(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); From 42486d0a3b65ef0606b2cdd44aeff38ebcdd75e7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 14 Jul 2020 10:42:42 +0200 Subject: [PATCH 249/366] Use the biome generator only on 1.16+ --- .../world/generator/VoidGenerator.java | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index 8566635f..672cc9fa 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -29,29 +29,30 @@ public class VoidGenerator extends ChunkGenerator { final Configuration configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); - Biome biome; - - switch (world.getEnvironment()) { - case NORMAL: - biome = CompatibleBiome.valueOf(configLoad.getString("Island.Biome.Default.Type", "PLAINS").toUpperCase()).getBiome(); - break; - case NETHER: - biome = CompatibleBiome.NETHER_WASTES.getBiome(); - break; - case THE_END: - biome = CompatibleBiome.THE_END.getBiome(); - break; - default: - throw new IllegalStateException("Unexpected value: " + world.getEnvironment()); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { + Biome biome; + + switch (world.getEnvironment()) { + case NORMAL: + biome = CompatibleBiome.valueOf(configLoad.getString("Island.Biome.Default.Type", "PLAINS").toUpperCase()).getBiome(); + break; + case NETHER: + biome = CompatibleBiome.NETHER_WASTES.getBiome(); + break; + case THE_END: + biome = CompatibleBiome.THE_END.getBiome(); + break; + default: + throw new IllegalStateException("Unexpected value: " + world.getEnvironment()); + } + + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there + setChunkBiome3D(biome, biomeGrid, world); + } else { + setChunkBiome2D(biome, biomeGrid); + } } - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there - setChunkBiome3D(biome, biomeGrid, world); - } else { - setChunkBiome2D(biome, biomeGrid); - } - - for (IslandWorld worldList : IslandWorld.values()) { if (world.getEnvironment() == World.Environment.NETHER || world.getEnvironment() == World.Environment.NORMAL From 9b6e8d9baaa9250cbbe803b97bc894c20d8ce715 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 14 Jul 2020 10:43:04 +0200 Subject: [PATCH 250/366] Add alias to levelscan command --- .../skyblock/command/commands/admin/LevelScanCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java index 53c0f63d..c0b3d14d 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/LevelScanCommand.java @@ -72,7 +72,7 @@ public class LevelScanCommand extends SubCommand { @Override public String[] getAliases() { - return new String[0]; + return new String[]{"scanlevel"}; } @Override From ca7af0d2903ca675f61d73788ac7a48d879162f7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 14 Jul 2020 10:43:26 +0200 Subject: [PATCH 251/366] Do not disable plugin on unsupported versions --- src/main/java/com/songoda/skyblock/SkyBlock.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 7f5e8e70..b1ff5b8c 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -114,9 +114,7 @@ public class SkyBlock extends SongodaPlugin { @Override public void onPluginEnable() { if(ServerVersion.isServerVersionAbove(ServerVersion.V1_16)) { - this.getLogger().warning("This Minecraft version is not supported. Disabling..."); - getServer().getPluginManager().disablePlugin(this); - return; + this.getLogger().warning("This Minecraft version is not officially supported."); } if(paper = ServerProject.isServer(ServerProject.PAPER)){ From 5ed66a0b90ca4f677615923cd8992a541b86b1ea Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 14 Jul 2020 10:43:34 +0200 Subject: [PATCH 252/366] 2.3.6-DEV1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 27b88270..a906171a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.5 + 2.3.6-DEV1 jar UTF-8 @@ -224,7 +224,7 @@ com.songoda SongodaCore - LATEST + 2.3.42 compile From 2fe3f5c661be6e54cb5e6ff88aa0c76a3301c66c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 14 Jul 2020 19:39:09 +0200 Subject: [PATCH 253/366] Made final some vars --- .../songoda/skyblock/levelling/IslandLevelManager.java | 9 ++++----- .../com/songoda/skyblock/placeholder/Placeholder.java | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java index ba5b2d42..695621b8 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java @@ -30,11 +30,10 @@ import java.util.*; import java.util.Map.Entry; public final class IslandLevelManager { - - private final static int VERSION = NMSUtil.getVersionNumber(); - private Map inScan; - private Map worth; - private Map cachedPairs; + + private final Map inScan; + private final Map worth; + private final Map cachedPairs; private final SkyBlock plugin; public IslandLevelManager(SkyBlock plugin) { diff --git a/src/main/java/com/songoda/skyblock/placeholder/Placeholder.java b/src/main/java/com/songoda/skyblock/placeholder/Placeholder.java index 98cc0359..068d748f 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/Placeholder.java +++ b/src/main/java/com/songoda/skyblock/placeholder/Placeholder.java @@ -2,8 +2,8 @@ package com.songoda.skyblock.placeholder; public class Placeholder { - private String placeholder; - private String result; + private final String placeholder; + private final String result; public Placeholder(String placeholder, String result) { this.placeholder = placeholder; From a53729bed042780c04f1ba22bdd8f537575e1381 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 14 Jul 2020 19:40:23 +0200 Subject: [PATCH 254/366] Initial rework to Placeholder Manager --- .../skyblock/placeholder/wip/Placeholder.java | 20 ++++++++++ .../placeholder/wip/PlaceholderManager.java | 4 ++ .../placeholder/wip/PlaceholderProcessor.java | 13 ++++++ .../placeholder/wip/hook/MVdWPlaceholder.java | 4 ++ .../placeholder/wip/hook/PlaceholderAPI.java | 40 +++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java create mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java create mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java create mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java create mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/hook/PlaceholderAPI.java diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java b/src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java new file mode 100644 index 00000000..6debe567 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java @@ -0,0 +1,20 @@ +package com.songoda.skyblock.placeholder.wip; + +public class Placeholder { + + private final String placeholder; + private final String result; + + public Placeholder(String placeholder, String result) { + this.placeholder = placeholder; + this.result = result; + } + + public String getPlaceholder() { + return placeholder; + } + + public String getResult() { + return result; + } +} \ No newline at end of file diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java new file mode 100644 index 00000000..5fa424c6 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java @@ -0,0 +1,4 @@ +package com.songoda.skyblock.placeholder.wip; + +public class PlaceholderManager { +} diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java new file mode 100644 index 00000000..dda79fd7 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java @@ -0,0 +1,13 @@ +package com.songoda.skyblock.placeholder.wip; + +import org.bukkit.entity.Player; + +public class PlaceholderProcessor { + + public static String processPlaceholder(Player player, String placeholder) { + if(player == null || placeholder == null) { + return ""; + } + return "To be implemented"; + } +} diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java b/src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java new file mode 100644 index 00000000..24ef95db --- /dev/null +++ b/src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java @@ -0,0 +1,4 @@ +package com.songoda.skyblock.placeholder.wip.hook; + +public class MVdWPlaceholder { +} diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/hook/PlaceholderAPI.java b/src/main/java/com/songoda/skyblock/placeholder/wip/hook/PlaceholderAPI.java new file mode 100644 index 00000000..f11fb13b --- /dev/null +++ b/src/main/java/com/songoda/skyblock/placeholder/wip/hook/PlaceholderAPI.java @@ -0,0 +1,40 @@ +package com.songoda.skyblock.placeholder.wip.hook; + +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.placeholder.wip.PlaceholderProcessor; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import org.bukkit.entity.Player; + +public class PlaceholderAPI extends PlaceholderExpansion { + + private final SkyBlock plugin; + + public PlaceholderAPI(SkyBlock plugin) { + this.plugin = plugin; + } + + public String getIdentifier() { + return "fabledskyblock"; + } + + public String getPlugin() { + return null; + } + + public String getAuthor() { + return plugin.getDescription().getAuthors().get(0); + } + + public String getVersion() { + return plugin.getDescription().getVersion(); + } + + public boolean persist() { + return true; + } + + public String onPlaceholderRequest(Player player, String identifier) { + + return PlaceholderProcessor.processPlaceholder(player, "fabledskyblock_" + identifier); + } +} From 7de0b553d3cb15840e8df06f96396f66763cb7e9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 16 Jul 2020 11:06:21 +0200 Subject: [PATCH 255/366] Implemented more methods in Manager --- src/main/java/com/songoda/skyblock/manager/Manager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/manager/Manager.java b/src/main/java/com/songoda/skyblock/manager/Manager.java index 90ac07d7..e11d1a05 100644 --- a/src/main/java/com/songoda/skyblock/manager/Manager.java +++ b/src/main/java/com/songoda/skyblock/manager/Manager.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.manager; import com.songoda.skyblock.SkyBlock; +import org.bukkit.entity.Player; public abstract class Manager { @@ -13,11 +14,15 @@ public abstract class Manager { /** * Reloads the Manager's settings */ - public abstract void reload(); + public void reload() {}; /** * Cleans up the Manager's resources */ - public abstract void disable(); + public void disable() {}; + + public void triggerPlayerLogin(Player player) {} + + public void triggerPlayerLogout(Player player) {} } From e71c0ef4de208e95eb8f40ed2f418b1977356c60 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 16 Jul 2020 11:06:39 +0200 Subject: [PATCH 256/366] Some work to PlaceholderManager --- .../placeholder/wip/PlaceholderManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java index 5fa424c6..b3c6ec20 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java @@ -1,4 +1,16 @@ package com.songoda.skyblock.placeholder.wip; -public class PlaceholderManager { +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.manager.Manager; +import org.bukkit.entity.Player; + +public class PlaceholderManager extends Manager { + + public PlaceholderManager(SkyBlock plugin) { + super(plugin); + } + + public String parsePlaceholders(Player player, String message) { + return ""; + } } From 933ec952aaf1143b1c3997073a55472923950152 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 16 Jul 2020 11:07:08 +0200 Subject: [PATCH 257/366] Added option to change Economy Manager --- .../java/com/songoda/skyblock/SkyBlock.java | 23 ++++++- .../skyblock/api/bank/TransactionLog.java | 3 +- .../songoda/skyblock/bank/BankManager.java | 32 +++++----- .../challenge/challenge/Challenge.java | 12 ++-- .../command/commands/admin/AdminBank.java | 18 +++--- .../commands/island/ConfirmCommand.java | 9 +-- .../commands/island/UnlockCommand.java | 7 ++- .../commands/island/UpgradeCommand.java | 5 +- .../skyblock/economy/EconomyManager.java | 37 +++++++++++ .../skyblock/gui/bank/GuiBankSelector.java | 5 +- .../skyblock/island/reward/LevelReward.java | 5 +- .../com/songoda/skyblock/menus/Upgrade.java | 61 ++++++++++--------- .../skyblock/playerdata/PlayerData.java | 2 +- src/main/resources/config.yml | 3 + src/main/resources/plugin.yml | 4 +- 15 files changed, 149 insertions(+), 77 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/economy/EconomyManager.java diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index b1ff5b8c..d79d8c52 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -7,7 +7,6 @@ import com.songoda.core.compatibility.ServerProject; import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.configuration.Config; import com.songoda.core.gui.GuiManager; -import com.songoda.core.hooks.EconomyManager; import com.songoda.skyblock.api.SkyBlockAPI; import com.songoda.skyblock.ban.BanManager; import com.songoda.skyblock.bank.BankManager; @@ -18,6 +17,7 @@ import com.songoda.skyblock.command.commands.SkyBlockCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.confirmation.ConfirmationTask; import com.songoda.skyblock.cooldown.CooldownManager; +import com.songoda.skyblock.economy.EconomyManager; import com.songoda.skyblock.generator.GeneratorManager; import com.songoda.skyblock.invite.InviteManager; import com.songoda.skyblock.island.IslandManager; @@ -77,6 +77,7 @@ public class SkyBlock extends SongodaPlugin { private InviteManager inviteManager; private BiomeManager biomeManager; private IslandLevelManager levellingManager; + private com.songoda.skyblock.economy.EconomyManager economyManager; private CommandManager commandManager; private StructureManager structureManager; private StackableManager stackableManager; @@ -131,7 +132,7 @@ public class SkyBlock extends SongodaPlugin { SongodaCore.registerPlugin(this, 17, CompatibleMaterial.GRASS_BLOCK); // Load Economy - EconomyManager.load(); + economyManager = new EconomyManager(this); // Load Holograms com.songoda.core.hooks.HologramManager.load(this); @@ -180,7 +181,7 @@ public class SkyBlock extends SongodaPlugin { rewardManager = new RewardManager(this); rewardManager.loadRewards(); - bankManager = new BankManager(); + bankManager = new BankManager(this); new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L); new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L); @@ -227,6 +228,18 @@ public class SkyBlock extends SongodaPlugin { if (pluginManager.isPluginEnabled("Vault")) { this.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider(); } + + switch (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getString("Economy.Manager", "Default")) { + case "Vault": + getEconomyManager().setEconomy("Vault"); + break; + case "PlayerPoints": + getEconomyManager().setEconomy("PlayerPoints"); + break; + case "Reserve": + getEconomyManager().setEconomy("Reserve"); + break; + } this.coreProtectAPI = loadCoreProtect(); @@ -454,4 +467,8 @@ public class SkyBlock extends SongodaPlugin { public Permission getVaultPermission() { return vaultPermission; } + + public EconomyManager getEconomyManager() { + return economyManager; + } } diff --git a/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java b/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java index 00885205..e2c261fa 100644 --- a/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java +++ b/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.api.bank; +import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.bank.Transaction; import org.bukkit.Bukkit; @@ -10,7 +11,7 @@ import java.util.UUID; public class TransactionLog { public BankManager getImplementation() { - return BankManager.getInstance(); + return SkyBlock.getInstance().getBankManager(); } public List getLogForPlayer(UUID uuid) { diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 21ceae38..1573e7a6 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -1,8 +1,9 @@ package com.songoda.skyblock.bank; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.economy.EconomyManager; import com.songoda.skyblock.island.Island; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -11,16 +12,15 @@ import java.io.File; import java.util.*; public class BankManager { - private static BankManager instance; - - public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;} private final HashMap> log; + + private final SkyBlock plugin; public FileConfiguration lang; - public BankManager() { - SkyBlock plugin = SkyBlock.getInstance(); + public BankManager(SkyBlock plugin) { + this.plugin = plugin; FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); lang = config.getFileConfiguration(); log = new HashMap<>(); @@ -76,14 +76,16 @@ public class BankManager { } public List getBalanceLore(Player player) { + Economy economy = plugin.getEconomyManager().getEconomy(); + List result = new ArrayList<>(); result.add("Some error occurred while loading your balance!"); Island island = SkyBlock.getInstance().getIslandManager().getIsland(player); result.add("If this is null then its a easy to fix bug: "+island.toString()); if (island != null) { result.clear(); - result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(player))); - result.add(player.getDisplayName()+"'s island has "+EconomyManager.formatEconomy(island.getBankBalance())); + result.add(player.getDisplayName()+"'s balance is "+economy.formatEconomy(economy.getBalance(player))); + result.add(player.getDisplayName()+"'s island has "+ economy.formatEconomy(island.getBankBalance())); } return result; } @@ -97,7 +99,7 @@ public class BankManager { } public BankResponse deposit(Player player, Island island, double amt, boolean admin) { - SkyBlock plugin = SkyBlock.getInstance(); + Economy economy = plugin.getEconomyManager().getEconomy(); FileManager fileManager = plugin.getFileManager(); // Make sure the amount is positive @@ -114,11 +116,11 @@ public class BankManager { } if(!admin) { - if (!EconomyManager.hasBalance(player, amt)) { + if (!economy.hasBalance(player, amt)) { return BankResponse.NOT_ENOUGH_MONEY; } - - EconomyManager.withdrawBalance(player, amt); + + economy.withdrawBalance(player, amt); } island.addToBank(amt); @@ -133,7 +135,7 @@ public class BankManager { } public BankResponse withdraw(Player player, Island island, double amt, boolean admin) { - SkyBlock plugin = SkyBlock.getInstance(); + Economy economy = plugin.getEconomyManager().getEconomy(); FileManager fileManager = plugin.getFileManager(); // Make sure the amount is positive @@ -153,8 +155,8 @@ public class BankManager { if (amt > island.getBankBalance()) { return BankResponse.NOT_ENOUGH_MONEY; } - - EconomyManager.deposit(player, amt); + + economy.deposit(player, amt); } island.removeFromBank(amt); 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 f1f8e8eb..527e18ea 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java @@ -1,7 +1,7 @@ package com.songoda.skyblock.challenge.challenge; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.island.Island; @@ -23,6 +23,7 @@ import java.util.List; import java.util.regex.Pattern; public class Challenge { + private final ChallengeCategory category; private final int id; private final String name; @@ -492,23 +493,26 @@ public class Challenge { @Override public boolean has(Player p, Object obj) { + Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy(); if (obj instanceof Number) { - return EconomyManager.getBalance(p) >= ((Number) obj).doubleValue(); + return economy.getBalance(p) >= ((Number) obj).doubleValue(); } return false; } @Override public void executeRequire(Player p, Object obj) { + Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy(); if (obj instanceof Number && ((Number) obj).doubleValue() > 0) { - EconomyManager.withdrawBalance(p, ((Number) obj).doubleValue()); + economy.withdrawBalance(p, ((Number) obj).doubleValue()); } } @Override public void executeReward(Player p, Object obj) { + Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy(); if (obj instanceof Number && ((Number) obj).doubleValue() > 0) { - EconomyManager.deposit(p, ((Number) obj).doubleValue()); + economy.deposit(p, ((Number) obj).doubleValue()); } } }, diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index e316f3c3..eb9a75f8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -1,7 +1,7 @@ package com.songoda.skyblock.command.commands.admin; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.gui.bank.GuiBank; @@ -29,6 +29,7 @@ public class AdminBank extends SubCommand { IslandManager islandManager = plugin.getIslandManager(); FileManager fileManager = plugin.getFileManager(); SoundManager soundManager = plugin.getSoundManager(); + Economy economy = plugin.getEconomyManager().getEconomy(); FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -47,15 +48,15 @@ public class AdminBank extends SubCommand { switch (args[0].toLowerCase()) { case "balance": if (args.length >= 3) { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID()))))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID()))))); } else { - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1]))))); } return; case "deposit": if (args.length >= 3) { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2])); - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2])))); }else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } @@ -63,7 +64,7 @@ public class AdminBank extends SubCommand { case "withdraw": if (args.length >= 3) { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2])); - messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2])))); }else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } @@ -101,6 +102,7 @@ public class AdminBank extends SubCommand { MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); FileManager fileManager = plugin.getFileManager(); + Economy economy = plugin.getEconomyManager().getEconomy(); FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -111,12 +113,12 @@ public class AdminBank extends SubCommand { } switch (args[0]) { case "balance": - messageManager.sendMessage(sender,configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%",args[1]).replace("%bal%",""+ EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1]))))); + messageManager.sendMessage(sender,configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%",args[1]).replace("%bal%",""+ economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1]))))); return; case "deposit": if (args.length >= 3) { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2])); - messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2])))); }else { messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } @@ -124,7 +126,7 @@ public class AdminBank extends SubCommand { case "withdraw": if (args.length >= 3) { islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2])); - messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2])))); + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2])))); }else { messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message")); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java index 9da979c0..88a015bd 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java @@ -1,7 +1,7 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -39,6 +39,7 @@ public class ConfirmCommand extends SubCommand { IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); + Economy economy = plugin.getEconomyManager().getEconomy(); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); @@ -127,15 +128,15 @@ public class ConfirmCommand extends SubCommand { return; } - if (EconomyManager.isEnabled() && island.getStructure() != null + if (economy.isEnabled() && island.getStructure() != null && !island.getStructure().isEmpty() && structureManager.containsStructure(island.getStructure())) { Structure structure = structureManager.getStructure(island.getStructure()); double deletionCost = structure.getDeletionCost(); if (deletionCost != 0.0D) { - if (EconomyManager.hasBalance(player, deletionCost)) { - EconomyManager.withdrawBalance(player, deletionCost); + if (economy.hasBalance(player, deletionCost)) { + economy.withdrawBalance(player, deletionCost); } else { messageManager.sendMessage(player, configLoad.getString( diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java index 7376304b..b488951f 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java @@ -1,7 +1,7 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -26,6 +26,7 @@ public class UnlockCommand extends SubCommand { IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); + Economy economy = plugin.getEconomyManager().getEconomy(); Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -68,7 +69,7 @@ public class UnlockCommand extends SubCommand { double price = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) .getFileConfiguration().getDouble("Island.World." + islandWorld.name() + ".UnlockPrice"); - if (!EconomyManager.hasBalance(player, price)) { + if (!economy.hasBalance(player, price)) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Money.Message").replace( "%cost%", NumberUtil.formatNumberByDecimal(price))); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -76,7 +77,7 @@ public class UnlockCommand extends SubCommand { } soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - EconomyManager.withdrawBalance(player, price); + economy.withdrawBalance(player, price); islandManager.unlockIslandWorld(island, islandWorld); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java index 755f583c..a90df98c 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java @@ -1,7 +1,7 @@ package com.songoda.skyblock.command.commands.island; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.menus.Upgrade; @@ -19,6 +19,7 @@ public class UpgradeCommand extends SubCommand { public void onCommandByPlayer(Player player, String[] args) { MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); + Economy economy = plugin.getEconomyManager().getEconomy(); Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); @@ -28,7 +29,7 @@ public class UpgradeCommand extends SubCommand { configLoad.getString("Command.Island.Upgrade.Owner.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else { - if (!EconomyManager.isEnabled()) { + if (!economy.isEnabled()) { messageManager.sendMessage(player, configLoad.getString("Command.Island.Upgrade.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return; diff --git a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java new file mode 100644 index 00000000..48a6ad64 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java @@ -0,0 +1,37 @@ +package com.songoda.skyblock.economy; + +import com.songoda.core.hooks.Hook; +import com.songoda.core.hooks.economies.Economy; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.manager.Manager; +import org.bukkit.Bukkit; + +import java.util.Arrays; + +public class EconomyManager extends Manager { + + private Economy economy; + + public EconomyManager(SkyBlock plugin) { + super(plugin); + com.songoda.core.hooks.EconomyManager.load(); + economy = com.songoda.core.hooks.EconomyManager.getEconomy(); + } + + public boolean setEconomy(String economyString) { + Hook hook = com.songoda.core.hooks.EconomyManager.getManager().getHook(economyString); + if(hook != null && + hook.isEnabled() && + hook instanceof Economy && + !hook.equals(com.songoda.core.hooks.EconomyManager.getManager().getCurrentHook())) { + this.economy = (Economy) hook; + return true; + } + return false; + } + + public Economy getEconomy() { + return this.economy; + } + +} diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index 5df17f83..34961d65 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -5,7 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.gui.AnvilGui; import com.songoda.core.gui.Gui; import com.songoda.core.gui.GuiUtils; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; @@ -50,6 +50,7 @@ public class GuiBankSelector extends Gui { } public void paint() { + Economy economy = plugin.getEconomyManager().getEconomy(); if (inventory != null) inventory.clear(); setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); @@ -90,7 +91,7 @@ public class GuiBankSelector extends Gui { switch(type){ case DEPOSIT: - amount = EconomyManager.getBalance(event.player); + amount = economy.getBalance(event.player); if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) { amount = Math.floor(amount); } diff --git a/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java b/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java index b69075b5..96a89695 100644 --- a/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java +++ b/src/main/java/com/songoda/skyblock/island/reward/LevelReward.java @@ -1,6 +1,6 @@ package com.songoda.skyblock.island.reward; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import org.bukkit.entity.Player; @@ -20,6 +20,7 @@ public class LevelReward { } public void give(Player player, SkyBlock plugin, long level) { + Economy economy = plugin.getEconomyManager().getEconomy(); if (islandBalance > 0) { Island island = plugin.getIslandManager().getIsland(player); @@ -27,7 +28,7 @@ public class LevelReward { } if (money > 0) - EconomyManager.deposit(player, money); + economy.deposit(player, money); if (!commands.isEmpty()) { for (String cmd : commands) { diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java index ad970c76..c043fae3 100644 --- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java +++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java @@ -2,7 +2,7 @@ package com.songoda.skyblock.menus; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.hooks.EconomyManager; +import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.api.event.island.IslandUpgradeEvent; import com.songoda.skyblock.api.utils.APIUtil; @@ -55,11 +55,12 @@ public class Upgrade { IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); + Economy economy = plugin.getEconomyManager().getEconomy(); FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")) .getFileConfiguration(); - if (!EconomyManager.isEnabled()) { + if (!economy.isEnabled()) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -70,7 +71,7 @@ public class Upgrade { Island island = islandManager.getIsland(player); nInventoryUtil nInv = new nInventoryUtil(player, event -> { - if (!EconomyManager.isEnabled()) { + if (!economy.isEnabled()) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -116,13 +117,13 @@ public class Upgrade { if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message") .replace("%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - EconomyManager.withdrawBalance(player, upgrade.getCost()); + economy.withdrawBalance(player, upgrade.getCost()); island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Speed, true); @@ -171,13 +172,13 @@ public class Upgrade { if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message") .replace("%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - EconomyManager.withdrawBalance(player, upgrade.getCost()); + economy.withdrawBalance(player, upgrade.getCost()); island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Jump, true); @@ -221,13 +222,13 @@ public class Upgrade { if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message") .replace("%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - EconomyManager.withdrawBalance(player, upgrade.getCost()); + economy.withdrawBalance(player, upgrade.getCost()); island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Crop, true); @@ -272,13 +273,13 @@ public class Upgrade { if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message") .replace("%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - EconomyManager.withdrawBalance(player, upgrade.getCost()); + economy.withdrawBalance(player, upgrade.getCost()); island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Fly, true); @@ -324,13 +325,13 @@ public class Upgrade { if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message") .replace("%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - - EconomyManager.withdrawBalance(player, upgrade.getCost()); + + economy.withdrawBalance(player, upgrade.getCost()); island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Drops, true); @@ -368,14 +369,14 @@ public class Upgrade { .replace("%tier", "" + tier)))) { if (upgrade.getValue() > island.getMaxMembers() && upgrade.getValue() != island.getMaxMembers()) { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message").replace( "%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - EconomyManager.withdrawBalance(player, upgrade.getCost()); + economy.withdrawBalance(player, upgrade.getCost()); island.setMaxMembers(upgrade.getValue()); Bukkit.getServer().getPluginManager().callEvent(new IslandUpgradeEvent( @@ -421,14 +422,14 @@ public class Upgrade { .replace("%tier", "" + tier)))) { if (upgrade.getValue() > island.getSize() && upgrade.getValue() != island.getSize()) { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message").replace( "%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - - EconomyManager.withdrawBalance(player, upgrade.getCost()); + + economy.withdrawBalance(player, upgrade.getCost()); island.setSize(upgrade.getValue()); islandManager.updateBorder(island); @@ -482,13 +483,13 @@ public class Upgrade { if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) { com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0); - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Bought.Message") .replace("%upgrade", is.getItemMeta().getDisplayName())); soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F); - - EconomyManager.withdrawBalance(player, upgrade.getCost()); + + economy.withdrawBalance(player, upgrade.getCost()); island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner, true); @@ -551,7 +552,7 @@ public class Upgrade { getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Speed))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem(nInv.createItem(potion, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")), @@ -604,7 +605,7 @@ public class Upgrade { getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Jump))}, null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem(nInv.createItem(potion, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")), @@ -642,7 +643,7 @@ public class Upgrade { getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Crop))}, null, null), 3); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")), @@ -680,7 +681,7 @@ public class Upgrade { getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Fly))}, null, null), 4); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")), @@ -718,7 +719,7 @@ public class Upgrade { getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Drops))}, null, null), 5); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")), @@ -765,7 +766,7 @@ public class Upgrade { new Placeholder("%maxMembers", "" + upgrade.getValue())}, null, null), 6); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem( nInv.createItem(new ItemStack(Material.BOOKSHELF), ChatColor.translateAlternateColorCodes('&', @@ -827,7 +828,7 @@ public class Upgrade { new Placeholder("%size", "" + upgrade.getValue())}, null, null), 7); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem( nInv.createItem(new ItemStack(Material.BEACON), ChatColor.translateAlternateColorCodes('&', @@ -880,7 +881,7 @@ public class Upgrade { getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner))}, null, null), 8); } else { - if (EconomyManager.hasBalance(player, upgrade.getCost())) { + if (economy.hasBalance(player, upgrade.getCost())) { nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")), diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 47c4d276..b0566103 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -282,7 +282,7 @@ public class PlayerData { } public synchronized void save() { - transactions = BankManager.getInstance().getTransactionList(getPlayerUUID()); + transactions = plugin.getBankManager().getTransactionList(getPlayerUUID()); Config config = getConfig(); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Statistics.Island.Playtime", getPlaytime()); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9e9138d3..56cea745 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -8,6 +8,9 @@ Command: Sound: # When disabled all sounds will be disabled. Enable: true +Economy: + # Possible managers: Default, Vault, PlayerPoints and Reserve + Manager: Default Island: Performance: # Chunk loading per tick affecting operations like island deletion, scan and biome changing. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7954dbcd..201888a3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,8 +5,8 @@ api-version: 1.13 description: A unique SkyBlock plugin author: Songoda authors: [Fabrimat] -softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, - EpicSpawners, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector] +softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, PlayerPoints, + LeaderHeads, EpicSpawners, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector] loadbefore: [Multiverse-Core, ProtocolLib] commands: island: From bc4af8972b569cb605c4420fbd9985ddfac987f2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 16 Jul 2020 11:07:36 +0200 Subject: [PATCH 258/366] Revert "Added IronGolems settings" This reverts commit 432d4b2d8c12804116b2cbf532ab986f0c636063. --- .../permission/PermissionManager.java | 1 - .../listening/IronGolemPermission.java | 36 ------------------- .../listening/MobGriefingPermission.java | 12 +++---- src/main/resources/language.yml | 4 --- src/main/resources/settings.yml | 1 - 5 files changed, 5 insertions(+), 49 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 8ffc6ca6..da139af3 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -83,7 +83,6 @@ public class PermissionManager { new ItemDropPermission(), new FishingPermission(plugin), new CauldronPermission(plugin), - new IronGolemPermission(plugin), // Basic new MemberPermission(), diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java deleted file mode 100644 index 36bde502..00000000 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.songoda.skyblock.permission.permissions.listening; - -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.permission.ListeningPermission; -import com.songoda.skyblock.permission.PermissionHandler; -import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.IronGolem; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.minecart.ExplosiveMinecart; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.hanging.HangingBreakByEntityEvent; -import org.bukkit.event.vehicle.VehicleDamageEvent; -import org.bukkit.event.vehicle.VehicleDestroyEvent; - -public class IronGolemPermission extends ListeningPermission { - - private final SkyBlock plugin; - - public IronGolemPermission(SkyBlock plugin) { - super("IronGolems", CompatibleMaterial.IRON_BLOCK, PermissionType.ISLAND); - this.plugin = plugin; - } - - @PermissionHandler - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if (event.getDamager() instanceof IronGolem) { - event.setCancelled(true); - } - } -} - diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java index f8497c44..55e88cf0 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java @@ -5,7 +5,6 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.IronGolem; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; @@ -30,7 +29,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityExplode(EntityExplodeEvent event) { if (!(event.getEntity() instanceof Player) && (!(event.getEntity() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) && !(event.getEntity() instanceof TNTPrimed) && !(event.getEntity() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -41,7 +40,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDamage(VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -52,7 +51,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDestroy(VehicleDestroyEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -63,10 +62,9 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (!(event.getDamager() instanceof Player) && (!(event.getDamager() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) && !(event.getDamager() instanceof TNTPrimed) - && !(event.getDamager() instanceof ExplosiveMinecart) - && !(event.getDamager() instanceof IronGolem)) { + && !(event.getDamager() instanceof ExplosiveMinecart)) { event.setCancelled(true); } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index b98a1332..6cf4d6ff 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1323,8 +1323,6 @@ Menu: Displayname: '&aLeaf Decay' MobGriefing: Displayname: '&aMob Griefing' - IronGolems: - Displayname: '&aIron Golems' Status: Enabled: Lore: @@ -1795,8 +1793,6 @@ Menu: Displayname: '&aNatural Mob Spawning' MobGriefing: Displayname: '&aMob Griefing' - IronGolems: - Displayname: '&aIron Golems' PvP: Displayname: '&aPvP' Explosions: diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index f32380de..0e50ae85 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -167,7 +167,6 @@ Settings: Owner: NaturalMobSpawning: true MobGriefing: true - IronGolems: true Explosions: true FireSpread: true LeafDecay: true From 5c9c4275176f7a781b1b4e2a8921be8c222a94a9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 20 Jul 2020 23:51:51 +0200 Subject: [PATCH 259/366] Fix for missing userCache --- .../com/songoda/skyblock/utils/player/OfflinePlayer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java index 9ee02fde..2bec5d2b 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java +++ b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java @@ -58,8 +58,12 @@ public class OfflinePlayer { this.name = bukkitOfflinePlayer.getName(); this.uuid = uuid; - if (this.name == null && userCacheManager.hasUser(uuid)) { - this.name = userCacheManager.getUser(uuid); + if (this.name == null) { + if(userCacheManager.hasUser(uuid)) { + this.name = userCacheManager.getUser(uuid); + } else { + this.name = "Unknown"; + } } FileConfiguration configLoad = YamlConfiguration.loadConfiguration( From 938ea2c7a2b27546223456536a55dccab7ec1e1a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 21 Jul 2020 21:13:19 +0200 Subject: [PATCH 260/366] Fix for biome conversion error --- src/main/java/com/songoda/skyblock/island/Island.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index cd8107cd..dcca809f 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.island; +import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.utils.PlayerUtils; import com.songoda.skyblock.SkyBlock; @@ -468,9 +469,9 @@ public class Island { } public Biome getBiome() { - return Biome.valueOf(plugin.getFileManager().getConfig( + return CompatibleBiome.valueOf(plugin.getFileManager().getConfig( new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) - .getFileConfiguration().getString("Biome.Type")); + .getFileConfiguration().getString("Biome.Type")).getBiome(); } public void setBiome(Biome biome) { From a67808188fabc14a7e0086f88fec7f3fa38afde6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 21 Jul 2020 21:13:42 +0200 Subject: [PATCH 261/366] Do not use async paper on pre 1.13 --- src/main/java/com/songoda/skyblock/SkyBlock.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index d79d8c52..7ea7e09f 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -118,7 +118,8 @@ public class SkyBlock extends SongodaPlugin { this.getLogger().warning("This Minecraft version is not officially supported."); } - if(paper = ServerProject.isServer(ServerProject.PAPER)){ + if(paper = ServerProject.isServer(ServerProject.PAPER) && + ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ try { Bukkit.spigot().getClass().getMethod("getPaperConfig"); paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); From 5b4601198fa3ad3c87be28a4240529605993f51e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 21 Jul 2020 21:14:45 +0200 Subject: [PATCH 262/366] Fixed npe in restricted blocks --- .../com/songoda/skyblock/listeners/Block.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 40960d3c..f19c0af7 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -246,24 +246,28 @@ public class Block implements Listener { 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, false)){ - plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) - .getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message"))); - event.setCancelled(true); + if(configLoad.getConfigurationSection("Island.Restrict.NetherBlocks") != null) { + for(String s : configLoad.getConfigurationSection("Island.Restrict.NetherBlocks").getKeys(false)){ + if(s.equalsIgnoreCase(block.getType().toString())){ + if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)){ + plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.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)){ - plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) - .getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message"))); - event.setCancelled(true); + if(configLoad.getConfigurationSection("Island.Restrict.EndBlocks") != null) { + for(String s : configLoad.getConfigurationSection("Island.Restrict.EndBlocks").getKeys(false)){ + if(s.equalsIgnoreCase(block.getType().toString())){ + if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){ + plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message"))); + event.setCancelled(true); + } } } } From ed6a16e65ff15d888b893a3d83d2d3258396cac5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 21 Jul 2020 22:52:28 +0200 Subject: [PATCH 263/366] Fix getDefinitiveLocation --- .../java/com/songoda/skyblock/utils/world/LocationUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5b11fc45..06587587 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -72,7 +72,7 @@ public final class LocationUtil { public static @Nonnull Location getDefinitiveLocation(@Nonnull Location loc){ Location locWorking = loc.clone(); - for(int i=locWorking.getBlockY(); i>=0; i--){ + for(locWorking.setY(locWorking.getBlockY()); locWorking.getBlockY()>=0; locWorking.setY(locWorking.getBlockY()-1)){ if(!locWorking.getBlock().isEmpty()){ if(locWorking.getBlock().getType().equals(CompatibleMaterial.WATER.getMaterial()) || (NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ From 28a6bbe7ef8dcde818b15556c93e392737d10a04 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 22 Jul 2020 00:21:56 +0200 Subject: [PATCH 264/366] Fix issues with island size and worldborder --- .../com/songoda/skyblock/island/Island.java | 22 +++----- .../skyblock/island/IslandManager.java | 54 ++++++++++--------- .../songoda/skyblock/listeners/Interact.java | 4 +- .../com/songoda/skyblock/listeners/Move.java | 2 +- .../playerdata/PlayerDataManager.java | 2 +- .../skyblock/utils/world/LocationUtil.java | 7 ++- .../skyblock/utils/world/WorldBorder.java | 40 +++++++------- src/main/resources/config.yml | 5 +- 8 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index dcca809f..10287b85 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -66,10 +66,6 @@ public class Island { if (this.size > 1000) { this.size = 50; } - - if(this.size % 2 != 0) { - this.size += 1; - } if (player.isOnline()) { int customSize = PlayerUtils.getNumberFromPermission(player.getPlayer(), "fabledskyblock.size", 0); @@ -336,7 +332,7 @@ public class Island { if (size > 1000 || size < 0) { size = 50; } - + this.size = size; plugin.getFileManager().getConfig( new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) @@ -344,7 +340,7 @@ public class Island { } public double getRadius() { - return (size / 2d) + 0.5d; + return (((size%2==0) ? size : (size-1d)) / 2d); } public boolean hasPassword() { @@ -457,15 +453,11 @@ public class Island { Location islandLocation = getLocation(worldManager.getIslandWorld(blockLocation.getWorld()), IslandEnvironment.Island); double halfSize = Math.floor(getRadius()); - - if (blockLocation.getBlockX() > (islandLocation.getBlockX() + halfSize) - || blockLocation.getBlockX() < (islandLocation.getBlockX() - halfSize - 1) - || blockLocation.getBlockZ() > (islandLocation.getBlockZ() + halfSize) - || blockLocation.getBlockZ() < (islandLocation.getBlockZ() - halfSize - 1)) { - return false; - } - - return true; + + return !(blockLocation.getBlockX() > (islandLocation.getBlockX() + halfSize)) + && !(blockLocation.getBlockX() < (islandLocation.getBlockX() - halfSize - 1)) + && !(blockLocation.getBlockZ() > (islandLocation.getBlockZ() + halfSize)) + && !(blockLocation.getBlockZ() < (islandLocation.getBlockZ() - halfSize - 1)); } public Biome getBiome() { diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index d403aa79..256499ad 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -7,6 +7,7 @@ import com.google.common.base.Preconditions; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.api.event.island.*; import com.songoda.skyblock.ban.BanManager; @@ -63,10 +64,10 @@ public class IslandManager { private final SkyBlock plugin; - private List islandPositions = new ArrayList<>(); - private Map islandProxies = new HashMap<>(); - private Map islandStorage = new HashMap<>(); - private int offset; + private final List islandPositions = new ArrayList<>(); + private final Map islandProxies = new HashMap<>(); + private final Map islandStorage = new HashMap<>(); + private final int offset; private HashMap oldSystemIslands; @@ -813,7 +814,7 @@ public class IslandManager { Location islandLocation = fileManager.getLocation(config, "Location.Normal.Island", false); - if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) { + if (LocationUtil.isLocationInLocationRadius(location, islandLocation, size)) { return; } } catch (Exception e) { @@ -1395,9 +1396,13 @@ public class IslandManager { return; } } - + + double increment = island.getSize() % 2 != 0 ? 0.5d : 0.0d; + if (configLoad.getBoolean("Island.WorldBorder.Enable") && island.isBorder()) { - WorldBorder.send(player, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(player.getWorld()), IslandEnvironment.Island)); + WorldBorder.send(player, island.getBorderColor(), island.getSize(), + island.getLocation(worldManager.getIslandWorld(player.getWorld()), + IslandEnvironment.Island).clone().add(increment, 0, increment)); } else { WorldBorder.send(player, null, 1.4999992E7D, new org.bukkit.Location(player.getWorld(), 0, 0, 0)); } @@ -1534,29 +1539,25 @@ public class IslandManager { if (island.isBorder()) { if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) { + double increment = island.getSize() % 2 != 0 ? 0.5d : 0.0d; + for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { - if (worldList == IslandWorld.Nether) { - if (NMSUtil.getVersionNumber() < 13) { - continue; + if (worldList != IslandWorld.Nether || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { + for (Player all : getPlayersAtIsland(island)) { + WorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island).clone().add(increment, 0, increment)); } } - - for (Player all : getPlayersAtIsland(island)) { - WorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island)); - } + } } } else { for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { - if (worldList == IslandWorld.Nether) { - if (NMSUtil.getVersionNumber() < 13) { - continue; + if (worldList != IslandWorld.Nether || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { + for (Player all : getPlayersAtIsland(island)) { + WorldBorder.send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0)); } } - - for (Player all : getPlayersAtIsland(island)) { - WorldBorder.send(all, null, 1.4999992E7D, new org.bukkit.Location(all.getWorld(), 0, 0, 0)); - } + } } } @@ -1623,9 +1624,14 @@ public class IslandManager { public boolean isLocationAtIsland(Island island, org.bukkit.Location location, IslandWorld world) { Location islandLocation = island.getLocation(world, IslandEnvironment.Island); - if (islandLocation == null) return false; - - return LocationUtil.isLocationAtLocationRadius(location.clone().add(0.5, 0, 0.5), islandLocation, island.getRadius() + 1); + if (islandLocation != null && location.getWorld().equals(islandLocation.getWorld())) { + double locIncrement = island.getSize() % 2d != 0d ? 0.50d + Double.MIN_VALUE : -Double.MIN_VALUE; + return LocationUtil.isLocationInLocationRadius( + islandLocation.clone().add(locIncrement, 0d, locIncrement), + location.toCenterLocation(), + island.getRadius() + Math.round(locIncrement)); + } + return false; } public Island getIslandByPlayer(org.bukkit.OfflinePlayer player) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 15670455..a932f5e3 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -145,7 +145,9 @@ public class Interact implements Listener { StackableManager stackableManager = plugin.getStackableManager(); IslandLevelManager levellingManager = plugin.getLevellingManager(); - Island island = islandManager.getIslandAtLocation(player.getLocation()); + Island island = (block != null) ? + islandManager.getIslandAtLocation(block.getLocation()) : + islandManager.getIslandAtLocation(player.getLocation()); if (island == null) { event.setCancelled(true); return; diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 5c996c9d..3f452327 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -149,7 +149,7 @@ public class Move implements Listener { } } } else { - if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius())) { + if(!islandManager.isLocationAtIsland(island, to)) { teleportPlayerToIslandSpawn(player, world, island); Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index 0b9cdb85..507269b9 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -232,7 +232,7 @@ public class PlayerDataManager { Visit visit = visitIslands.get(visitIslandList); IslandLocation location = visit.getLocation(world); - if (location != null && LocationUtil.isLocationAtLocationRadius(player.getLocation(), location.getLocation(), visit.getRadius())) { + if (location != null && LocationUtil.isLocationInLocationRadius(player.getLocation(), location.getLocation(), visit.getRadius())) { Player targetPlayer = Bukkit.getServer().getPlayer(visitIslandList); String targetPlayerName; 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 06587587..9dc37099 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -148,16 +148,15 @@ public final class LocationUtil { || isLocationLocation(location2.subtract(0, 1, 0), location1); } - public static boolean isLocationAtLocationRadius(Location location1, Location location2, double radius) { + public static boolean isLocationInLocationRadius(Location location1, Location location2, double radius) { if (location1 == null || location2 == null || location1.getWorld() == null || location2.getWorld() == null || !location1.getWorld().getName().equals(location2.getWorld().getName())) { return false; } - double x = Math.abs(location1.getX() - location2.getX()); double z = Math.abs(location1.getZ() - location2.getZ()); - - return x <= radius && z <= radius; + + return x < radius && z < radius; } public static List getLocations(Location minLocation, Location maxLocation) { diff --git a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java b/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java index 12f9c9a1..d15ea8ff 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java +++ b/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java @@ -10,39 +10,38 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public final class WorldBorder { - - private static Class packetPlayOutWorldBorder, packetPlayOutWorldBorderEnumClass, worldBorderClass, - craftWorldClass; + + private static Class packetPlayOutWorldBorderEnumClass; + private static Class worldBorderClass; + private static Class craftWorldClass; private static Constructor packetPlayOutWorldBorderConstructor; static { try { - packetPlayOutWorldBorder = NMSUtil.getNMSClass("PacketPlayOutWorldBorder"); + Class packetPlayOutWorldBorder = NMSUtil.getNMSClass("PacketPlayOutWorldBorder"); - if (NMSUtil.getVersionNumber() > 10) { - packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[0]; - } else { - packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[1]; + if(packetPlayOutWorldBorder != null) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { + packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[0]; + } else { + packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[1]; + } + + worldBorderClass = NMSUtil.getNMSClass("WorldBorder"); + craftWorldClass = NMSUtil.getCraftClass("CraftWorld"); + + packetPlayOutWorldBorderConstructor = packetPlayOutWorldBorder.getConstructor(worldBorderClass, + packetPlayOutWorldBorderEnumClass); } - - worldBorderClass = NMSUtil.getNMSClass("WorldBorder"); - craftWorldClass = NMSUtil.getCraftClass("CraftWorld"); - - packetPlayOutWorldBorderConstructor = packetPlayOutWorldBorder.getConstructor(worldBorderClass, - packetPlayOutWorldBorderEnumClass); } catch (Exception e) { e.printStackTrace(); } } public static void send(Player player, Color color, double size, Location centerLocation) { - size +=2; try { if (centerLocation == null || centerLocation.getWorld() == null) return; - - if (size % 2 == 1) - size++; Object worldBorder = worldBorderClass.getConstructor().newInstance(); @@ -54,13 +53,16 @@ public final class WorldBorder { } Method setCenter = worldBorder.getClass().getMethod("setCenter", double.class, double.class); - setCenter.invoke(worldBorder, centerLocation.getBlockX(), centerLocation.getBlockZ()); + setCenter.invoke(worldBorder, centerLocation.getX(), centerLocation.getZ()); Method setSize = worldBorder.getClass().getMethod("setSize", double.class); setSize.invoke(worldBorder, size); Method setWarningTime = worldBorder.getClass().getMethod("setWarningTime", int.class); setWarningTime.invoke(worldBorder, 0); + + Method setWarningDistance = worldBorder.getClass().getMethod("setWarningDistance", int.class); + setWarningDistance.invoke(worldBorder, 0); Method transitionSizeBetween = worldBorder.getClass().getMethod("transitionSizeBetween", double.class, double.class, long.class); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 56cea745..243ef243 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -19,12 +19,11 @@ Island: ChunkPerTick: 15 Size: # Warning: The maximum is capped at 1000 - # Warning: Only even numbers are accepted # Warning: Do not go over the maximum # The size of an Island when created - Minimum: 100 + Minimum: 51 # The maximum size of an Island based on the permission node 'fabledskyblock.size.'. - Maximum: 200 + Maximum: 1000 Creation: # Rather than opening the 'Island Creator' menu. Create an island # as soon as a player performs the '/island' or '/island create' From 9c7efdae0645022aaff829aba2824beb5c7e342a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 22 Jul 2020 14:20:55 +0200 Subject: [PATCH 265/366] Fix for npe in admin bank command --- .../songoda/skyblock/command/commands/admin/AdminBank.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index eb9a75f8..90798d3e 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -43,7 +43,12 @@ public class AdminBank extends SubCommand { } if (args.length < 1) { - plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true)); + if (island != null){ + plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true)); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } } else { switch (args[0].toLowerCase()) { case "balance": From 4121ecc769c3ec54d58b9ebebb96e271c8e6a19e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 22 Jul 2020 15:13:43 +0200 Subject: [PATCH 266/366] Update drop upgrade to 1.16 --- .../com/songoda/skyblock/listeners/Entity.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 0e0c2e7f..ec779772 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -490,7 +490,7 @@ public class Entity implements Listener { if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled() && island.isUpgrade(Upgrade.Type.Drops)) { Set dontMultiply = new HashSet<>(); - if (NMSUtil.getVersionNumber() > 8) { + if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) { EntityEquipment equipment = livingEntity.getEquipment(); if (equipment != null) { for (ItemStack item : event.getDrops()) { @@ -502,9 +502,16 @@ public class Entity implements Listener { } } - if (livingEntity instanceof Pig) { - Pig pig = (Pig) livingEntity; - if (pig.hasSaddle()) dontMultiply.add(new ItemStack(Material.SADDLE, 1)); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { + if (livingEntity instanceof Steerable) { + Steerable steerable = (Steerable) livingEntity; + if (steerable.hasSaddle()) dontMultiply.add(new ItemStack(CompatibleMaterial.SADDLE.getMaterial(), 1)); + } + } else { + if (livingEntity instanceof Pig) { + Pig pig = (Pig) livingEntity; + if (pig.hasSaddle()) dontMultiply.add(new ItemStack(CompatibleMaterial.SADDLE.getMaterial(), 1)); + } } } From c6791b104e7ad39cdfd2d752f0af7231bdb3d4c0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 28 Jul 2020 22:20:22 +0200 Subject: [PATCH 267/366] Fix npe in entity explode --- src/main/java/com/songoda/skyblock/listeners/Entity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index ec779772..b50886e2 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -364,7 +364,7 @@ public class Entity implements Listener { Island island = islandManager.getIslandAtLocation(entity.getLocation()); plugin.getPermissionManager().processPermission(event, null, island); - if (!event.isCancelled()) { + if (!event.isCancelled() && island != null) { StackableManager stackableManager = plugin.getStackableManager(); From 8786cdd710497219a2432ac308eff3bbe284808b Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 28 Jul 2020 23:26:00 +0200 Subject: [PATCH 268/366] Fix for furnaces not covering all furnaces types --- .../permission/permissions/listening/FurnacePermission.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FurnacePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FurnacePermission.java index 07c21595..64c1f769 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FurnacePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FurnacePermission.java @@ -7,6 +7,7 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; import org.bukkit.block.Block; +import org.bukkit.block.Furnace; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; @@ -24,15 +25,13 @@ public class FurnacePermission extends ListeningPermission { @PermissionHandler public void onInteract(PlayerInteractEvent event) { - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return; Player player = event.getPlayer(); Block block = event.getClickedBlock(); - if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.FURNACE) + if (block != null && block.getState() instanceof Furnace) cancelAndMessage(event, player, plugin, messageManager); } } From 959d52a43137a8eee89c10499a1a960e00a56fc6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 28 Jul 2020 23:26:10 +0200 Subject: [PATCH 269/366] Fix doors not covering all openables --- .../permission/permissions/listening/DoorPermission.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java index 53543b04..7844dc6b 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java @@ -9,6 +9,7 @@ import com.songoda.skyblock.permission.PermissionType; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.material.Openable; public class DoorPermission extends ListeningPermission { @@ -27,13 +28,10 @@ public class DoorPermission extends ListeningPermission { if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return; - - CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock()); + Player player = event.getPlayer(); - if (material == CompatibleMaterial.BIRCH_DOOR || material == CompatibleMaterial.ACACIA_DOOR - || material == CompatibleMaterial.DARK_OAK_DOOR || material == CompatibleMaterial.JUNGLE_DOOR - || material == CompatibleMaterial.SPRUCE_DOOR || material == CompatibleMaterial.OAK_DOOR) + if (event.getClickedBlock() instanceof Openable) cancelAndMessage(event, player, plugin, messageManager); } } From 93ae6fd49405378cab3dd24d37c93b8a58597699 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 28 Jul 2020 23:47:14 +0200 Subject: [PATCH 270/366] Added ProtectorDamage setting --- .../permission/PermissionManager.java | 1 + .../listening/MobGriefingPermission.java | 18 +++++++----- .../listening/ProtectorDamagePermission.java | 29 +++++++++++++++++++ src/main/resources/language.yml | 4 +++ src/main/resources/settings.yml | 1 + 5 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index da139af3..17ae3fd6 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -83,6 +83,7 @@ public class PermissionManager { new ItemDropPermission(), new FishingPermission(plugin), new CauldronPermission(plugin), + new ProtectorDamagePermission(plugin), // Basic new MemberPermission(), diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java index 55e88cf0..fbeae21e 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java @@ -5,9 +5,7 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.*; import org.bukkit.entity.minecart.ExplosiveMinecart; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -29,7 +27,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityExplode(EntityExplodeEvent event) { if (!(event.getEntity() instanceof Player) && (!(event.getEntity() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) && !(event.getEntity() instanceof TNTPrimed) && !(event.getEntity() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -40,7 +38,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDamage(VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -51,7 +49,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDestroy(VehicleDestroyEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -62,9 +60,13 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (!(event.getDamager() instanceof Player) && (!(event.getDamager() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) && !(event.getDamager() instanceof TNTPrimed) - && !(event.getDamager() instanceof ExplosiveMinecart)) { + && !(event.getDamager() instanceof ExplosiveMinecart) + && !(event.getDamager() instanceof IronGolem) + && !(event.getDamager() instanceof Snowman) + && !(event.getDamager() instanceof Wolf && + ((Wolf) event.getDamager()).isTamed())) { event.setCancelled(true); } } diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java new file mode 100644 index 00000000..35f7e129 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java @@ -0,0 +1,29 @@ +package com.songoda.skyblock.permission.permissions.listening; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.permission.ListeningPermission; +import com.songoda.skyblock.permission.PermissionHandler; +import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.entity.*; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +public class ProtectorDamagePermission extends ListeningPermission { + + private final SkyBlock plugin; + + public ProtectorDamagePermission(SkyBlock plugin) { + super("ProtectorDamagePermission", CompatibleMaterial.CARVED_PUMPKIN, PermissionType.ISLAND); + this.plugin = plugin; + } + + @PermissionHandler + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + if(event.getDamager() instanceof IronGolem || + event.getDamager() instanceof Snowman || + (event.getDamager() instanceof Wolf && + ((Wolf) event.getDamager()).isTamed())) { + event.setCancelled(true); + } + } +} diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 6cf4d6ff..eee4d2c3 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1323,6 +1323,8 @@ Menu: Displayname: '&aLeaf Decay' MobGriefing: Displayname: '&aMob Griefing' + ProtectorDamage: + Displayname: '&aProtector damage' Status: Enabled: Lore: @@ -1793,6 +1795,8 @@ Menu: Displayname: '&aNatural Mob Spawning' MobGriefing: Displayname: '&aMob Griefing' + ProtectorDamage: + Displayname: '&aProtector Damage' PvP: Displayname: '&aPvP' Explosions: diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 0e50ae85..1948f949 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -168,6 +168,7 @@ Settings: NaturalMobSpawning: true MobGriefing: true Explosions: true + ProtectorDamage: true FireSpread: true LeafDecay: true KeepItemsOnDeath: false \ No newline at end of file From 838af0724654b36103c78fe2489c036de9b89361 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 00:09:07 +0200 Subject: [PATCH 271/366] Optimize UUID string parser --- .../java/com/songoda/skyblock/ban/Ban.java | 9 +++++---- .../com/songoda/skyblock/ban/BanManager.java | 7 ++++--- .../challenge/player/PlayerManager.java | 11 ++++++----- .../commands/admin/AddUpgradeCommand.java | 3 ++- .../com/songoda/skyblock/island/Island.java | 17 +++++++++-------- .../skyblock/island/IslandManager.java | 19 ++++++++++--------- .../com/songoda/skyblock/listeners/Block.java | 3 ++- .../skyblock/playerdata/PlayerData.java | 11 ++++++----- .../skyblock/stackable/StackableManager.java | 5 +++-- .../skyblock/usercache/UserCacheManager.java | 17 +++++++++-------- .../skyblock/utils/player/NameFetcher.java | 3 ++- .../skyblock/utils/player/OfflinePlayer.java | 9 +++++---- .../com/songoda/skyblock/visit/Visit.java | 13 +++++++------ .../songoda/skyblock/visit/VisitManager.java | 5 +++-- 14 files changed, 73 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/ban/Ban.java b/src/main/java/com/songoda/skyblock/ban/Ban.java index e7879239..1aa19075 100644 --- a/src/main/java/com/songoda/skyblock/ban/Ban.java +++ b/src/main/java/com/songoda/skyblock/ban/Ban.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.ban; +import com.eatthepath.uuid.FastUUID; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.api.event.island.IslandBanEvent; import com.songoda.skyblock.api.event.island.IslandUnbanEvent; @@ -38,10 +39,10 @@ public class Ban { for (String islandBanList : plugin.getFileManager() .getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), - islandOwnerUUID.toString() + ".yml")) + FastUUID.toString(islandOwnerUUID) + ".yml")) .getFileConfiguration().getStringList("Bans")) { - UUID uuid = UUID.fromString(islandBanList); + UUID uuid = FastUUID.parseUUID(islandBanList); if (!Bukkit.getOfflinePlayer(uuid).hasPlayedBefore()) continue; @@ -64,7 +65,7 @@ public class Ban { List islandBans = new ArrayList<>(); FileConfiguration configLoad = plugin.getFileManager() .getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), - islandOwnerUUID.toString() + ".yml")) + FastUUID.toString(islandOwnerUUID) + ".yml")) .getFileConfiguration(); for (String islandBanList : configLoad.getStringList("Bans")) { @@ -86,7 +87,7 @@ public class Ban { .getFileConfiguration(); for (String islandBanList : configLoad.getStringList("Bans")) { - if (!uuid.toString().equals(islandBanList)) { + if (!FastUUID.toString(uuid).equals(islandBanList)) { islandBans.add(islandBanList); } } diff --git a/src/main/java/com/songoda/skyblock/ban/BanManager.java b/src/main/java/com/songoda/skyblock/ban/BanManager.java index b156f475..53046e40 100644 --- a/src/main/java/com/songoda/skyblock/ban/BanManager.java +++ b/src/main/java/com/songoda/skyblock/ban/BanManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.ban; +import com.eatthepath.uuid.FastUUID; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; @@ -45,7 +46,7 @@ public class BanManager { if (configFile.exists()) { for (File fileList : configFile.listFiles()) { - UUID islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", "")); + UUID islandOwnerUUID = FastUUID.parseUUID(fileList.getName().replaceFirst("[.][^.]+$", "")); createIsland(islandOwnerUUID); } } @@ -59,9 +60,9 @@ public class BanManager { ban.save(); File oldBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"), - uuid1.toString() + ".yml"); + FastUUID.toString(uuid1) + ".yml"); File newBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"), - uuid2.toString() + ".yml"); + FastUUID.toString(uuid2) + ".yml"); fileManager.unloadConfig(oldBanDataFile); fileManager.unloadConfig(newBanDataFile); 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 7ee489b2..387ea423 100644 --- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java +++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.challenge.player; +import com.eatthepath.uuid.FastUUID; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.challenge.challenge.Challenge; import com.songoda.skyblock.challenge.challenge.Challenge.Type; @@ -70,7 +71,7 @@ public class PlayerManager { } } Config config = plugin.getFileManager().getConfig(new File(playersDirectory, - uuid.toString() + ".yml")); + FastUUID.toString(uuid) + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); HashMap challenges = new HashMap<>(); ConfigurationSection section = fileConfig.getConfigurationSection("challenges"); @@ -120,7 +121,7 @@ public class PlayerManager { } islands.remove(uuid); plugin.getFileManager().unloadConfig(new File(playersDirectory, - uuid.toString() + ".yml")); + FastUUID.toString(uuid) + ".yml")); } @@ -212,7 +213,7 @@ public class PlayerManager { } } Config config = plugin.getFileManager().getConfig(new File(playersDirectory, - uuid.toString() + ".yml")); + FastUUID.toString(uuid) + ".yml")); FileConfiguration fileConfig = config.getFileConfiguration(); int ccId = c.getCategory().getId(); int cId = c.getId(); @@ -223,7 +224,7 @@ public class PlayerManager { fileConfig.set("challenges." + ccId + ".challenges." + cId + ".id", cId); fileConfig.set("challenges." + ccId + ".challenges." + cId + ".count", count); try { - fileConfig.save(new File(playersDirectory, uuid.toString() + ".yml")); + fileConfig.save(new File(playersDirectory, FastUUID.toString(uuid) + ".yml")); } catch (IOException ex) { ex.printStackTrace(); } @@ -253,7 +254,7 @@ public class PlayerManager { // Not connected, check in file Config config = plugin.getFileManager().getConfig(new File(playersDirectory, - uuid.toString() + ".yml")); + FastUUID.toString(uuid) + ".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/admin/AddUpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java index 76967c3b..8b3efe13 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AddUpgradeCommand.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.command.commands.admin; +import com.eatthepath.uuid.FastUUID; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; @@ -89,7 +90,7 @@ public class AddUpgradeCommand extends SubCommand { island.setUpgrade(null, upgrade, true); } else { File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data", - islandOwnerUUID.toString() + ".yml"); + FastUUID.toString(islandOwnerUUID) + ".yml"); if (!fileManager.isFileExist(islandDataFile)) { messageManager.sendMessage(sender, diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 10287b85..22d91d9f 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.island; +import com.eatthepath.uuid.FastUUID; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.utils.PlayerUtils; @@ -108,7 +109,7 @@ public class Island { FileConfiguration configLoad = config.getFileConfiguration(); if (configLoad.getString("UUID") != null) { - islandUUID = UUID.fromString(configLoad.getString("UUID")); + islandUUID = FastUUID.parseUUID(configLoad.getString("UUID")); } else { configLoad.set("UUID", islandUUID.toString()); } @@ -203,7 +204,7 @@ public class Island { if (configLoad.getString("Whitelist") != null) { for (String whitelistedUUID : configLoad.getStringList("Whitelist")) { - whitelistedPlayers.add(UUID.fromString(whitelistedUUID)); + whitelistedPlayers.add(FastUUID.parseUUID(whitelistedUUID)); } } @@ -282,7 +283,7 @@ public class Island { if (coopDataConfigLoad.getString("CoopPlayers") != null) { for (String coopPlayerList : coopDataConfigLoad.getStringList("CoopPlayers")) { - coopPlayers.put(UUID.fromString(coopPlayerList), IslandCoop.NORMAL); + coopPlayers.put(FastUUID.parseUUID(coopPlayerList), IslandCoop.NORMAL); } } } @@ -305,7 +306,7 @@ public class Island { } public UUID getOriginalOwnerUUID() { - return UUID.fromString(plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + return FastUUID.parseUUID(plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) .getFileConfiguration().getString("Ownership.Original")); } @@ -592,7 +593,7 @@ public class Island { if (configLoad.getString(role.name() + "s") != null) { for (String playerList : configLoad.getStringList(role.name() + "s")) { - islandRoles.add(UUID.fromString(playerList)); + islandRoles.add(FastUUID.parseUUID(playerList)); } } } @@ -642,7 +643,7 @@ public class Island { islandMembers = configLoad.getStringList(role.name() + "s"); } - islandMembers.add(uuid.toString()); + islandMembers.add(FastUUID.toString(uuid)); configLoad.set(role.name() + "s", islandMembers); try { @@ -670,7 +671,7 @@ public class Island { FileConfiguration configLoad = config.getFileConfiguration(); List islandMembers = configLoad.getStringList(role.name() + "s"); - islandMembers.remove(uuid.toString()); + islandMembers.remove(FastUUID.toString(uuid)); configLoad.set(role.name() + "s", islandMembers); try { @@ -883,7 +884,7 @@ public class Island { List tempWhitelist = new ArrayList<>(); for(UUID uuid : whitelistedPlayers) { - tempWhitelist.add(uuid.toString()); + tempWhitelist.add(FastUUID.toString(uuid)); } config.getFileConfiguration().set("Whitelist", tempWhitelist); config.getFileConfiguration().set("Visitor.Status", status.toString()); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 256499ad..38687293 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -3,6 +3,7 @@ package com.songoda.skyblock.island; import com.bekvon.bukkit.residence.Residence; import com.bekvon.bukkit.residence.containers.Flags; import com.bekvon.bukkit.residence.protection.ClaimedResidence; +import com.eatthepath.uuid.FastUUID; import com.google.common.base.Preconditions; import com.songoda.core.compatibility.CompatibleBiome; import com.songoda.core.compatibility.CompatibleMaterial; @@ -669,15 +670,15 @@ public class IslandManager { public synchronized void deleteIslandData(UUID uuid) { FileManager fileManager = plugin.getFileManager(); - fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml")); - fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/ban-data", uuid.toString() + ".yml")); - fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/coop-data", uuid.toString() + ".yml")); - fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/level-data", uuid.toString() + ".yml")); - fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/setting-data", uuid.toString() + ".yml")); - fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/visit-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/island-data", FastUUID.toString(uuid) + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/ban-data", FastUUID.toString(uuid) + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/coop-data", FastUUID.toString(uuid) + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/level-data", FastUUID.toString(uuid) + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/setting-data", FastUUID.toString(uuid) + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/visit-data", FastUUID.toString(uuid) + ".yml")); if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() .getBoolean("Island.Challenge.PerIsland", true)){ - fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/challenge-data", uuid.toString() + ".yml")); + fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/challenge-data", FastUUID.toString(uuid) + ".yml")); } } @@ -702,7 +703,7 @@ public class IslandManager { islandOwnerUUID = player.getUniqueId(); } else { if (configLoad.getString("Island.Owner") != null) { - islandOwnerUUID = UUID.fromString(configLoad.getString("Island.Owner")); + islandOwnerUUID = FastUUID.parseUUID(configLoad.getString("Island.Owner")); } } @@ -1263,7 +1264,7 @@ public class IslandManager { } public boolean isIslandExist(UUID uuid) { - return plugin.getFileManager().isFileExist(new File(new File(plugin.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); + return plugin.getFileManager().isFileExist(new File(new File(plugin.getDataFolder().toString() + "/island-data"), FastUUID.toString(uuid) + ".yml")); } /* diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index f19c0af7..c36f6e3b 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -647,12 +647,13 @@ public class Block implements Listener { // Filter valid players on the island. List possiblePlayers = new ArrayList<>(); + Set visitors = island.getVisit().getVisitors(); for (Player player : Bukkit.getOnlinePlayers()) { 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.getVisit().getVisitors().contains(player.getUniqueId()) && + (visitors.contains(player.getUniqueId()) && player.hasPermission("fabledskyblock.generator.anywhere") && !ignoreVisitors); diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index b0566103..b5d632db 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.playerdata; +import com.eatthepath.uuid.FastUUID; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.bank.Transaction; @@ -63,7 +64,7 @@ public class PlayerData { if (getConfig().getFileConfiguration().getString("ChatSpiedIslands") != null) { for (String islandUUID : getConfig().getFileConfiguration().getStringList("ChatSpiedIslands")) { - spiedIslands.add(UUID.fromString(islandUUID)); + spiedIslands.add(FastUUID.parseUUID(islandUUID)); } } @@ -75,7 +76,7 @@ public class PlayerData { Transaction t = new Transaction(); t.action = Transaction.Type.valueOf(configLoad.getString("Bank.Transactions."+i+".Action")); t.amount = Float.parseFloat(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Amount"))); - t.player = Bukkit.getOfflinePlayer(UUID.fromString(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Player")))); + t.player = Bukkit.getOfflinePlayer(FastUUID.parseUUID(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Player")))); Date d = new Date(); d.setTime(configLoad.getLong("Bank.Transactions."+i+".Date")); t.timestamp = d; @@ -202,7 +203,7 @@ public class PlayerData { public UUID getOwner() { String islandOwnerUUID = getConfig().getFileConfiguration().getString("Island.Owner"); - return (islandOwnerUUID == null) ? null : UUID.fromString(islandOwnerUUID); + return (islandOwnerUUID == null) ? null : FastUUID.parseUUID(islandOwnerUUID); } public void setOwner(UUID islandOwnerUUID) { @@ -303,7 +304,7 @@ public class PlayerData { configLoad.set("ChatSpy", chatSpy); List tempSpiedIslands = new ArrayList<>(); for(UUID uuid : spiedIslands){ - tempSpiedIslands.add(uuid.toString()); + tempSpiedIslands.add(FastUUID.toString(uuid)); } configLoad.set("ChatSpiedIslands", tempSpiedIslands); @@ -316,7 +317,7 @@ public class PlayerData { private Config getConfig() { SkyBlock plugin = SkyBlock.getInstance(); - return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); + return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), FastUUID.toString(uuid) + ".yml")); } public Player getPlayer() { diff --git a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java index ca83c253..f46ffd6f 100644 --- a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java +++ b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.stackable; +import com.eatthepath.uuid.FastUUID; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; @@ -56,7 +57,7 @@ public class StackableManager { * section.get("Location"); org.bukkit.Material material = * org.bukkit.Material.valueOf(section.getString("Material")); int size = * section.getInt("Size"); if (size == 0) continue; this.addStack(new - * Stackable(UUID.fromString(uuid), location, material, size)); } } } + * Stackable(FastUUID.parseUUID(uuid), location, material, size)); } } } */ @SuppressWarnings("deprecation") @@ -89,7 +90,7 @@ public class StackableManager { if (size == 0) continue; - this.addStack(new Stackable(UUID.fromString(key), loc, type, size)); + this.addStack(new Stackable(FastUUID.parseUUID(key), loc, type, size)); } diff --git a/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java b/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java index b352778a..d7815dbf 100644 --- a/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java +++ b/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.usercache; +import com.eatthepath.uuid.FastUUID; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; @@ -45,14 +46,14 @@ public final class UserCacheManager { final String ownerUUIDString = fileName.substring(0, fileName.indexOf('.')); Set islandMembers = new HashSet<>(); - islandMembers.add(UUID.fromString(ownerUUIDString)); + islandMembers.add(FastUUID.parseUUID(ownerUUIDString)); for (String memberList : configLoad.getStringList("Members")) { - islandMembers.add(UUID.fromString(memberList)); + islandMembers.add(FastUUID.parseUUID(memberList)); } for (String operatorList : configLoad.getStringList("Operators")) { - islandMembers.add(UUID.fromString(operatorList)); + islandMembers.add(FastUUID.parseUUID(operatorList)); } for (UUID islandMemberList : islandMembers) { @@ -86,14 +87,14 @@ public final class UserCacheManager { } public void addUser(UUID uuid, String name) { - config.getFileConfiguration().set(uuid.toString(), name); + config.getFileConfiguration().set(FastUUID.toString(uuid), name); } public String getUser(UUID uuid) { FileConfiguration configLoad = config.getFileConfiguration(); - if (configLoad.getString(uuid.toString()) != null) { - return configLoad.getString(uuid.toString()); + if (configLoad.getString(FastUUID.toString(uuid)) != null) { + return configLoad.getString(FastUUID.toString(uuid)); } return null; @@ -104,7 +105,7 @@ public final class UserCacheManager { for (String userList : configLoad.getConfigurationSection("").getKeys(false)) { if (configLoad.getString(userList).equalsIgnoreCase(name)) { - return UUID.fromString(userList); + return FastUUID.parseUUID(userList); } } @@ -112,7 +113,7 @@ public final class UserCacheManager { } public boolean hasUser(UUID uuid) { - return config.getFileConfiguration().getString(uuid.toString()) != null; + return config.getFileConfiguration().getString(FastUUID.toString(uuid)) != null; } public boolean hasUser(String name) { diff --git a/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java b/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java index 7f18116e..406cc286 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java +++ b/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.utils.player; +import com.eatthepath.uuid.FastUUID; import com.google.gson.Gson; import java.io.IOException; @@ -21,7 +22,7 @@ public final class NameFetcher { Names[] names = null; - Scanner jsonScanner = new Scanner((new URL("https://api.mojang.com/user/profiles/" + uuid.toString().replaceAll("-", "") + "/names")).openConnection().getInputStream(), "UTF-8"); + Scanner jsonScanner = new Scanner((new URL("https://api.mojang.com/user/profiles/" + FastUUID.toString(uuid).replaceAll("-", "") + "/names")).openConnection().getInputStream(), "UTF-8"); names = new Gson().fromJson(jsonScanner.next(), Names[].class); jsonScanner.close(); diff --git a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java index 2bec5d2b..30681f5f 100644 --- a/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java +++ b/src/main/java/com/songoda/skyblock/utils/player/OfflinePlayer.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.utils.player; +import com.eatthepath.uuid.FastUUID; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.usercache.UserCacheManager; import org.bukkit.Bukkit; @@ -38,14 +39,14 @@ public class OfflinePlayer { this.name = bukkitOfflinePlayer.getName(); FileConfiguration configLoad = YamlConfiguration.loadConfiguration( - new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); + new File(new File(plugin.getDataFolder().toString() + "/player-data"), FastUUID.toString(uuid) + ".yml")); texture = new String[]{configLoad.getString("Texture.Signature"), configLoad.getString("Texture.Value")}; playtime = configLoad.getInt("Statistics.Island.Playtime"); memberSince = configLoad.getString("Statistics.Island.Join"); lastOnline = configLoad.getString("Statistics.Island.LastOnline"); if (!(configLoad.getString("Island.Owner") == null || configLoad.getString("Island.Owner").isEmpty())) { - owner = UUID.fromString(configLoad.getString("Island.Owner")); + owner = FastUUID.parseUUID(configLoad.getString("Island.Owner")); } } @@ -67,14 +68,14 @@ public class OfflinePlayer { } FileConfiguration configLoad = YamlConfiguration.loadConfiguration( - new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml")); + new File(new File(plugin.getDataFolder().toString() + "/player-data"), FastUUID.toString(uuid) + ".yml")); texture = new String[]{configLoad.getString("Texture.Signature"), configLoad.getString("Texture.Value")}; playtime = configLoad.getInt("Statistics.Island.Playtime"); memberSince = configLoad.getString("Statistics.Island.Join"); lastOnline = configLoad.getString("Statistics.Island.LastOnline"); if (!(configLoad.getString("Island.Owner") == null || configLoad.getString("Island.Owner").isEmpty())) { - owner = UUID.fromString(configLoad.getString("Island.Owner")); + owner = FastUUID.parseUUID(configLoad.getString("Island.Owner")); } } diff --git a/src/main/java/com/songoda/skyblock/visit/Visit.java b/src/main/java/com/songoda/skyblock/visit/Visit.java index a360b87d..89585dc7 100644 --- a/src/main/java/com/songoda/skyblock/visit/Visit.java +++ b/src/main/java/com/songoda/skyblock/visit/Visit.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.visit; +import com.eatthepath.uuid.FastUUID; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.ban.Ban; import com.songoda.skyblock.config.FileManager; @@ -114,7 +115,7 @@ public class Visit { .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration().getStringList("Visitors")) { - islandVisitors.add(UUID.fromString(islandVisitorList)); + islandVisitors.add(FastUUID.parseUUID(islandVisitorList)); } return islandVisitors; @@ -131,7 +132,7 @@ public class Visit { islandVisitors.add(islandVisitorList); } - islandVisitors.add(uuid.toString()); + islandVisitors.add(FastUUID.toString(uuid)); configLoad.set("Visitors", islandVisitors); } @@ -146,7 +147,7 @@ public class Visit { islandVisitors.add(islandVisitorList); } - islandVisitors.remove(uuid.toString()); + islandVisitors.remove(FastUUID.toString(uuid)); configLoad.set("Visitors", islandVisitors); } @@ -161,7 +162,7 @@ public class Visit { .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")) .getFileConfiguration().getStringList("Voters")) { - islandVoters.add(UUID.fromString(islandVisitorList)); + islandVoters.add(FastUUID.parseUUID(islandVisitorList)); } return islandVoters; @@ -176,7 +177,7 @@ public class Visit { islandVoters.addAll(configLoad.getStringList("Voters")); - islandVoters.add(uuid.toString()); + islandVoters.add(FastUUID.toString(uuid)); configLoad.set("Voters", islandVoters); } @@ -188,7 +189,7 @@ public class Visit { .getFileConfiguration(); for (String islandVoterList : configLoad.getStringList("Voters")) { - if (!uuid.toString().equals(islandVoterList)) { + if (!FastUUID.toString(uuid).equals(islandVoterList)) { islandVoters.add(islandVoterList); } } diff --git a/src/main/java/com/songoda/skyblock/visit/VisitManager.java b/src/main/java/com/songoda/skyblock/visit/VisitManager.java index 35aacd2a..69e29a90 100644 --- a/src/main/java/com/songoda/skyblock/visit/VisitManager.java +++ b/src/main/java/com/songoda/skyblock/visit/VisitManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.visit; +import com.eatthepath.uuid.FastUUID; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; @@ -51,10 +52,10 @@ public class VisitManager { FileManager.Config config = new FileManager.Config(fileManager, fileList); FileConfiguration configLoad = config.getFileConfiguration(); - UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", "")); + UUID islandOwnerUUID = FastUUID.parseUUID(fileList.getName().replace(".yml", "")); if (islandOwnerUUID == null) { - islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", "")); + islandOwnerUUID = FastUUID.parseUUID(fileList.getName().replaceFirst("[.][^.]+$", "")); if (islandOwnerUUID == null) { continue; From dadb5d3f8fe0c515867548fd9553ee00e206e3aa Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 00:14:58 +0200 Subject: [PATCH 272/366] Added pom dependencies for fast uuid --- pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pom.xml b/pom.xml index a906171a..3eee7b2b 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,7 @@ com.songoda:SongodaCore io.papermc:paperlib + com.eatthepath:fast-uuid @@ -92,6 +93,10 @@ io.papermc.lib ${project.groupId}.paperlib + + com.eatthepath.uuid + ${project.groupId}.fast-uuid + @@ -239,5 +244,11 @@ provided 2.18.2 + + com.eatthepath + fast-uuid + 0.1 + compile + From 94040e42869f47a796fc37648fbbc1be70f0534f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 00:35:35 +0200 Subject: [PATCH 273/366] Optimize visitors management --- .../com/songoda/skyblock/visit/Visit.java | 58 +++++++------------ 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/visit/Visit.java b/src/main/java/com/songoda/skyblock/visit/Visit.java index 89585dc7..546cf927 100644 --- a/src/main/java/com/songoda/skyblock/visit/Visit.java +++ b/src/main/java/com/songoda/skyblock/visit/Visit.java @@ -8,11 +8,13 @@ import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.island.IslandLocation; import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.island.IslandWorld; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import java.io.File; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class Visit { @@ -24,8 +26,9 @@ public class Visit { private int islandSize; private int islandMembers; private int safeLevel; - private double islandBankBalance; + private final double islandBankBalance; private List islandSignature; + private final Set islandVisitors; private IslandStatus status; @@ -41,6 +44,16 @@ public class Visit { this.islandLevel = islandLevel; this.islandSignature = islandSignature; this.status = status; + this.islandVisitors = new HashSet<>(); + + FileConfiguration configLoad = plugin.getFileManager() + .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), + islandOwnerUUID.toString() + ".yml")) + .getFileConfiguration(); + + for (String visitor : configLoad.getStringList("Visitors")) { + islandVisitors.add(FastUUID.parseUUID(visitor)); + } } public UUID getOwnerUUID() { @@ -109,46 +122,17 @@ public class Visit { } public Set getVisitors() { - Set islandVisitors = new HashSet<>(); - - for (String islandVisitorList : plugin.getFileManager() - .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), - islandOwnerUUID.toString() + ".yml")) - .getFileConfiguration().getStringList("Visitors")) { - islandVisitors.add(FastUUID.parseUUID(islandVisitorList)); - } - return islandVisitors; } public void addVisitor(UUID uuid) { - List islandVisitors = new ArrayList<>(); - FileConfiguration configLoad = plugin.getFileManager() - .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), - islandOwnerUUID.toString() + ".yml")) - .getFileConfiguration(); - - for (String islandVisitorList : configLoad.getStringList("Visitors")) { - islandVisitors.add(islandVisitorList); - } - - islandVisitors.add(FastUUID.toString(uuid)); - configLoad.set("Visitors", islandVisitors); + islandVisitors.add(uuid); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public void removeVisitor(UUID uuid) { - List islandVisitors = new ArrayList<>(); - FileConfiguration configLoad = plugin.getFileManager() - .getConfig(new File(new File(plugin.getDataFolder().toString() + "/visit-data"), - islandOwnerUUID.toString() + ".yml")) - .getFileConfiguration(); - - for (String islandVisitorList : configLoad.getStringList("Visitors")) { - islandVisitors.add(islandVisitorList); - } - - islandVisitors.remove(FastUUID.toString(uuid)); - configLoad.set("Visitors", islandVisitors); + islandVisitors.remove(uuid); + Bukkit.getScheduler().runTaskAsynchronously(plugin, this::save); } public boolean isVoter(UUID uuid) { @@ -209,10 +193,12 @@ public class Visit { return plugin.getBanManager().getIsland(getOwnerUUID()); } - public void save() { + public synchronized void save() { FileManager.Config config = plugin.getFileManager().getConfig(new File( new File(plugin.getDataFolder().toString() + "/visit-data"), islandOwnerUUID.toString() + ".yml")); - + + config.getFileConfiguration().set("Visitors", new ArrayList<>(islandVisitors.stream().map(UUID::toString).collect(Collectors.toSet()))); + try { config.getFileConfiguration().save(config.getFile()); } catch (IOException e) { From 4c494c572e33fb9cd202366cd7f511f220b74d21 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 00:41:07 +0200 Subject: [PATCH 274/366] Optimized condition --- src/main/java/com/songoda/skyblock/listeners/Block.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index c36f6e3b..67ad636b 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -653,9 +653,9 @@ public class Block implements Listener { island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Coop, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || - (visitors.contains(player.getUniqueId()) && - player.hasPermission("fabledskyblock.generator.anywhere") && - !ignoreVisitors); + (!ignoreVisitors && + visitors.contains(player.getUniqueId()) && + player.hasPermission("fabledskyblock.generator.anywhere")); if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) { possiblePlayers.add(player); From 5f6a1d2f5757f8f053ae3afedcfd7215f66f1b3a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 00:57:40 +0200 Subject: [PATCH 275/366] Add setting check for item frame place --- .../permission/permissions/listening/PlacePermission.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java index cfa494cd..9831b590 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockMultiPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.player.PlayerInteractEvent; public class PlacePermission extends ListeningPermission { @@ -43,4 +44,9 @@ public class PlacePermission extends ListeningPermission { public void onMultiPlace(BlockMultiPlaceEvent event) { cancelAndMessage(event, event.getPlayer(), plugin, messageManager); } + + @PermissionHandler + public void onHangingPlace(HangingPlaceEvent event) { + cancelAndMessage(event, event.getPlayer(), plugin, messageManager); + } } From e58cd903d0a8f62c1045068b79f7c52ff1a0a9c4 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 00:57:50 +0200 Subject: [PATCH 276/366] == to equals --- .../permission/permissions/listening/PlacePermission.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java index 9831b590..088921ac 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PlacePermission.java @@ -31,7 +31,7 @@ public class PlacePermission extends ListeningPermission { Player player = event.getPlayer(); - if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BONE_MEAL) + if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()).equals(CompatibleMaterial.BONE_MEAL)) cancelAndMessage(event, player, plugin, messageManager); } From f59879dd050568c4e3d9946aabb80fdd73e2269f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 01:19:54 +0200 Subject: [PATCH 277/366] 1.8.8 compatibility --- .../java/com/songoda/skyblock/island/IslandManager.java | 2 +- .../com/songoda/skyblock/utils/world/LocationUtil.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 38687293..6d115bce 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1629,7 +1629,7 @@ public class IslandManager { double locIncrement = island.getSize() % 2d != 0d ? 0.50d + Double.MIN_VALUE : -Double.MIN_VALUE; return LocationUtil.isLocationInLocationRadius( islandLocation.clone().add(locIncrement, 0d, locIncrement), - location.toCenterLocation(), + LocationUtil.toCenterLocation(location), island.getRadius() + Math.round(locIncrement)); } return false; 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 9dc37099..821be37b 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -369,4 +369,12 @@ public final class LocationUtil { return rndLoc; } } + + public static Location toCenterLocation(Location loc) { + Location centerLoc = loc.clone(); + centerLoc.setX((double)loc.getBlockX() + 0.5D); + centerLoc.setY((double)loc.getBlockY() + 0.5D); + centerLoc.setZ((double)loc.getBlockZ() + 0.5D); + return centerLoc; + } } From 56b379189afcf2469387780e1f0624984d4443e1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 01:23:26 +0200 Subject: [PATCH 278/366] Renamed ProtectorDamage --- .../permissions/listening/ProtectorDamagePermission.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java index 35f7e129..7af194e8 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java @@ -13,7 +13,7 @@ public class ProtectorDamagePermission extends ListeningPermission { private final SkyBlock plugin; public ProtectorDamagePermission(SkyBlock plugin) { - super("ProtectorDamagePermission", CompatibleMaterial.CARVED_PUMPKIN, PermissionType.ISLAND); + super("ProtectorDamage", CompatibleMaterial.CARVED_PUMPKIN, PermissionType.ISLAND); this.plugin = plugin; } From 358a0d5e222c38e8a104af0d661a28d544278542 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 01:58:41 +0200 Subject: [PATCH 279/366] Added challenges as challenge alias --- .../skyblock/command/commands/island/ChallengeCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 aa1610ce..bc4a42b4 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 @@ -109,7 +109,7 @@ public class ChallengeCommand extends SubCommand { @Override public String[] getAliases() { - return new String[] { "c" }; + return new String[] { "c", "challenges" }; } @Override From 70fdd5ab88480ad8ff1618fe91a211a5955c22bf Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 02:03:13 +0200 Subject: [PATCH 280/366] 2.3.6-DEV2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3eee7b2b..104dfc47 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.6-DEV1 + 2.3.6-DEV2 jar UTF-8 From 551af025709c796bb2e58f4b3c217070063d5b58 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 21:33:20 +0200 Subject: [PATCH 281/366] Generators unlockLevel and update older versions to the new generator system --- .../songoda/skyblock/generator/Generator.java | 16 +- .../skyblock/generator/GeneratorManager.java | 7 +- .../com/songoda/skyblock/listeners/Block.java | 196 ++++++++++++------ src/main/resources/generators.yml | 3 + 4 files changed, 146 insertions(+), 76 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/generator/Generator.java b/src/main/java/com/songoda/skyblock/generator/Generator.java index 95f0e365..2f1dc15f 100644 --- a/src/main/java/com/songoda/skyblock/generator/Generator.java +++ b/src/main/java/com/songoda/skyblock/generator/Generator.java @@ -7,17 +7,19 @@ import java.util.List; public class Generator { - private String name; - private IslandWorld isWorld; - private CompatibleMaterial materials; - private List generatorMaterials; + private final String name; + private final IslandWorld isWorld; + private final CompatibleMaterial materials; + private final List generatorMaterials; + private final long level; private boolean permission; - public Generator(String name, IslandWorld isWorld, CompatibleMaterial materials, List generatorMaterials, boolean permission) { + public Generator(String name, IslandWorld isWorld, CompatibleMaterial materials, List generatorMaterials, long level, boolean permission) { this.name = name; this.isWorld = isWorld; this.materials = materials; this.generatorMaterials = generatorMaterials; + this.level = level; this.permission = permission; } @@ -48,4 +50,8 @@ public class Generator { public void setPermission(boolean permission) { this.permission = permission; } + + public long getLevel() { + return level; + } } diff --git a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java index 6e32035c..793e97d8 100644 --- a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java +++ b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java @@ -22,7 +22,7 @@ import java.util.Random; public class GeneratorManager { private final SkyBlock plugin; - private List generatorStorage = new ArrayList<>(); + private final List generatorStorage = new ArrayList<>(); public GeneratorManager(SkyBlock plugin) { this.plugin = plugin; @@ -62,6 +62,7 @@ public class GeneratorManager { generatorStorage.add(new Generator(configLoad.getString("Generators." + generatorList + ".Name"), IslandWorld.valueOf(configLoad.getString("Generators." + generatorList + ".World", "Normal")), icon, generatorMaterials, + configLoad.getLong("Generators." + generatorList + ".UnlockLevel", 0L), configLoad.getBoolean("Generators." + generatorList + ".Permission"))); } } @@ -155,11 +156,11 @@ public class GeneratorManager { return CompatibleMaterial.COBBLESTONE; } - public void addGenerator(String name, IslandWorld isWorld, List generatorMaterials, boolean permission) { + public void addGenerator(String name, IslandWorld isWorld, List generatorMaterials, int level, 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, isWorld, oreMaterials[new Random().nextInt(oreMaterials.length)], - generatorMaterials, permission)); + generatorMaterials, level, permission)); } public void removeGenerator(Generator generator) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 67ad636b..ecad2d0f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -405,41 +405,98 @@ public class Block implements Listener { } // Generators - if (NMSUtil.getVersionNumber() < 12) { - if (generatorManager != null && generatorManager.getGenerators().size() > 0 && generatorManager.isGenerator(block)) { - List generators = new ArrayList<>(generatorManager.getGenerators()); - Collections.reverse(generators); // Use the highest generator available - - // Filter valid players on the island - Set possiblePlayers = new HashSet<>(); - for (Player p : Bukkit.getOnlinePlayers()) { - boolean isMember = island.hasRole(IslandRole.Owner, p.getUniqueId()) || island.hasRole(IslandRole.Member, p.getUniqueId()) || island.hasRole(IslandRole.Coop, p.getUniqueId()) - || island.hasRole(IslandRole.Operator, p.getUniqueId()); - if (isMember && islandManager.isLocationAtIsland(island, p.getLocation(), world)) { - possiblePlayers.add(p); - } + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_12)) { + CompatibleMaterial material = CompatibleMaterial.getMaterial(block); + if (material != CompatibleMaterial.WATER + && material != CompatibleMaterial.LAVA) + return; + + BlockState state = event.getToBlock().getState(); + Material type = state.getType(); + + if (type != Material.COBBLESTONE && type != Material.STONE) return; + + if (generatorManager == null) return; + + List generators = Lists.newArrayList(generatorManager.getGenerators()); + + if (generators.isEmpty()) return; + + Collections.reverse(generators); // Use the highest generator available + + boolean ignoreVisitors = configLoad.getBoolean("Island.Generator.IgnoreVisitors", false); + + // Filter valid players on the island. + List possiblePlayers = new ArrayList<>(); + Set visitors = island.getVisit().getVisitors(); + for (Player player : Bukkit.getOnlinePlayers()) { + 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()) || + (!ignoreVisitors && + visitors.contains(player.getUniqueId()) && + player.hasPermission("fabledskyblock.generator.anywhere")); + + if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) { + possiblePlayers.add(player); } - + } + + if(!possiblePlayers.isEmpty()){ + boolean nearestPlayer = configLoad.getBoolean("Island.Generator.CheckOnlyNearestPlayer", false); + + if(nearestPlayer){ + possiblePlayers.sort(Comparator.comparingDouble(a -> a.getLocation().distance(block.getLocation()))); + } + + boolean onlyOwner = configLoad.getBoolean("Island.Generator.CheckOnlyOwnerPermissions", false); + + double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation()); // Find highest generator available for (Generator generator : generators) { - 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(island.getLevel().getLevel() >= generator.getLevel()) { + if(onlyOwner && plugin.getVaultPermission() != null) { + OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); + event.setCancelled(true); + org.bukkit.World finalWorld = event.getBlock().getWorld(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { + Bukkit.getScheduler().runTask(plugin, () -> { + if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ + BlockState genState = generatorManager.generateBlock(generator, block); + block.setType(genState.getType()); + + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { + BlockState tempState = block.getState(); + tempState.setData(genState.getData()); + tempState.update(true, true); + } + islandLevelManager.updateLevel(island, genState.getLocation()); + } + }); + } else { + Bukkit.getScheduler().runTask(plugin, () -> { + block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); + }); + } + }); + } else { + for (Player player : possiblePlayers) { + if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){ + break; + } + if (generator.isPermission()) { + if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) { + continue; + } + } + + if (applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator)) + 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(); - islandLevelManager.updateLevel(island, genState.getLocation()); - return; } } } @@ -624,6 +681,7 @@ public class Block implements Listener { } } + // Generators CompatibleMaterial material = CompatibleMaterial.getMaterial(block); if (material != CompatibleMaterial.WATER && material != CompatibleMaterial.LAVA) @@ -674,46 +732,48 @@ public class Block implements Listener { double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation()); // Find highest generator available for (Generator generator : generators) { - if(onlyOwner && plugin.getVaultPermission() != null) { - OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); - event.setCancelled(true); - org.bukkit.World finalWorld = event.getBlock().getWorld(); - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || - plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || - plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { - Bukkit.getScheduler().runTask(plugin, () -> { - if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ - BlockState genState = generatorManager.generateBlock(generator, block); - block.setType(genState.getType()); - - if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { - BlockState tempState = block.getState(); - tempState.setData(genState.getData()); - tempState.update(true, true); + if(island.getLevel().getLevel() >= generator.getLevel()) { + if(onlyOwner && plugin.getVaultPermission() != null) { + OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); + event.setCancelled(true); + org.bukkit.World finalWorld = event.getBlock().getWorld(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { + Bukkit.getScheduler().runTask(plugin, () -> { + if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ + BlockState genState = generatorManager.generateBlock(generator, block); + block.setType(genState.getType()); + + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { + BlockState tempState = block.getState(); + tempState.setData(genState.getData()); + tempState.update(true, true); + } + islandLevelManager.updateLevel(island, genState.getLocation()); } - islandLevelManager.updateLevel(island, genState.getLocation()); - } - }); - } else { - Bukkit.getScheduler().runTask(plugin, () -> { - block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); - }); - } - }); - } else { - for (Player player : possiblePlayers) { - if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){ - break; - } - if (generator.isPermission()) { - if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) { - continue; + }); + } else { + Bukkit.getScheduler().runTask(plugin, () -> { + block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); + }); } + }); + } else { + for (Player player : possiblePlayers) { + if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){ + break; + } + if (generator.isPermission()) { + if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) { + continue; + } + } + + if (applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator)) + return; } - - if (applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator)) - return; } } } diff --git a/src/main/resources/generators.yml b/src/main/resources/generators.yml index 842098f2..ed541a7f 100644 --- a/src/main/resources/generators.yml +++ b/src/main/resources/generators.yml @@ -3,6 +3,7 @@ Generators: Name: Normal World: Normal Permission: false + UnlockLevel: 0 Materials: COBBLESTONE: Chance: 60 @@ -20,6 +21,7 @@ Generators: Name: Nether World: Nether Permission: false + UnlockLevel: 0 Materials: NETHERRACK: Chance: 80 @@ -31,6 +33,7 @@ Generators: Name: End World: End Permission: false + UnlockLevel: 0 Materials: END_STONE: Chance: 100.0 \ No newline at end of file From 735f7cacd72fb9639c6fe3b824119c57e9c46fbb Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 21:33:48 +0200 Subject: [PATCH 282/366] Do not process normal permissions for operators and owners --- .../java/com/songoda/skyblock/island/Island.java | 2 +- .../skyblock/permission/PermissionManager.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 22d91d9f..c751e497 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -725,7 +725,7 @@ public class Island { public boolean hasPermission(IslandRole role, BasicPermission permission) { if (islandPermissions.containsKey(role)) { for (IslandPermission islandPermission : islandPermissions.get(role)) { - if (islandPermission.getPermission() == permission) + if (islandPermission.getPermission().equals(permission)) return islandPermission.getStatus(); } } diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 17ae3fd6..20f0eff9 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -238,11 +238,19 @@ public class PermissionManager { switch(island.getRole(player)){ case Owner: if(!configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ - return island.hasPermission(IslandRole.Owner, permission); + if(permission.getType().equals(PermissionType.ISLAND)) { + return island.hasPermission(IslandRole.Owner, permission); + } else { + return true; + } } case Operator: if(!configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ - return island.hasPermission(IslandRole.Operator, permission); + if(permission.getType().equals(PermissionType.OPERATOR)) { + return island.hasPermission(IslandRole.Operator, permission); + } else { + return true; + } } case Member: return island.hasPermission(IslandRole.Member, permission); From 4ca77fe9895a29f476faf6faa3444efdd9f0df87 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 23:00:50 +0200 Subject: [PATCH 283/366] Fix for pvp option not working --- .../com/songoda/skyblock/listeners/Entity.java | 14 ++++++++++---- .../permissions/listening/PvpPermission.java | 16 ++-------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index b50886e2..b998a582 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -92,6 +92,8 @@ public class Entity implements Listener { @EventHandler(ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { IslandManager islandManager = plugin.getIslandManager(); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); org.bukkit.entity.Entity victim = event.getEntity(); Island island = islandManager.getIslandAtLocation(victim.getLocation()); @@ -103,10 +105,14 @@ public class Entity implements Listener { } if(victim instanceof Player && attacker instanceof Player) { // PVP - if(plugin.getPermissionManager() - .processPermission(event, (Player) attacker, island)) { - plugin.getPermissionManager() - .processPermission(event, (Player) victim, island); + if(configLoad.getBoolean("Island.PvP.Enable")) { + if(plugin.getPermissionManager() + .processPermission(event, (Player) attacker, island)) { + plugin.getPermissionManager() + .processPermission(event, (Player) victim, island); + } + } else { + event.setCancelled(true); } } else if(victim instanceof Player) { // EVP plugin.getPermissionManager() diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java index 334162e5..bed7259f 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PvpPermission.java @@ -2,29 +2,23 @@ package com.songoda.skyblock.permission.permissions.listening; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import java.io.File; - public class PvpPermission extends ListeningPermission { private final SkyBlock plugin; private final MessageManager messageManager; - private final FileManager fileManager; - + public PvpPermission(SkyBlock plugin) { super("PvP", CompatibleMaterial.DIAMOND_SWORD, PermissionType.GENERIC); this.plugin = plugin; this.messageManager = plugin.getMessageManager(); - this.fileManager = plugin.getFileManager(); } @PermissionHandler @@ -37,13 +31,7 @@ public class PvpPermission extends ListeningPermission { } if(attacker != null && event.getEntity() instanceof Player){ - - FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Settings.PvP.Enable") || !configLoad.getBoolean("Island.PvP.Enable")) { - event.setCancelled(true); - } + event.setCancelled(true); cancelAndMessage(event, attacker, plugin, messageManager); } From 65e269a9f99f830e336cfc93931ae39fa277c2f2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 29 Jul 2020 23:58:49 +0200 Subject: [PATCH 284/366] Fix for default generator creator --- src/main/java/com/songoda/skyblock/menus/admin/Generator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8c75f51a..c0fba741 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java @@ -278,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(), IslandWorld.Normal, new ArrayList<>(), false); + generatorManager.addGenerator(event1.getName(), IslandWorld.Normal, new ArrayList<>(), 0, false); messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Created.Message") From e84fa0570a2d629082d99431bb0b0dea0f651da9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 30 Jul 2020 15:02:00 +0200 Subject: [PATCH 285/366] Optimize on Player move --- .../skyblock/island/IslandManager.java | 122 ++++++++++++------ .../com/songoda/skyblock/listeners/Move.java | 47 ++++--- 2 files changed, 106 insertions(+), 63 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 6d115bce..0ac45ca5 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -59,6 +59,7 @@ import java.io.File; import java.io.IOException; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; public class IslandManager { @@ -67,7 +68,7 @@ public class IslandManager { private final List islandPositions = new ArrayList<>(); private final Map islandProxies = new HashMap<>(); - private final Map islandStorage = new HashMap<>(); + private final Map islandStorage = new ConcurrentHashMap<>(); private final int offset; private HashMap oldSystemIslands; @@ -706,47 +707,80 @@ public class IslandManager { islandOwnerUUID = FastUUID.parseUUID(configLoad.getString("Island.Owner")); } } - - if (islandOwnerUUID != null) { - if (containsIsland(islandOwnerUUID)) { - //return getIsland(player); - return; - } else { - config = fileManager.getConfig(new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml")); - - if (config.getFileConfiguration().getString("Location") == null) { - deleteIslandData(islandOwnerUUID); - configLoad.set("Island.Owner", null); - - return; - } - - Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); - islandStorage.put(islandOwnerUUID, island); - - for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { - prepareIsland(island, worldList); - } - - if (!visitManager.hasIsland(island.getOwnerUUID())) { - visitManager.createIsland(island.getOwnerUUID(), - new IslandLocation[]{island.getIslandLocation(IslandWorld.Normal, IslandEnvironment.Island), island.getIslandLocation(IslandWorld.Nether, IslandEnvironment.Island), - island.getIslandLocation(IslandWorld.End, IslandEnvironment.Island)}, - island.getSize(), island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1, island.getBankBalance(), visitManager.getIslandSafeLevel(island.getOwnerUUID()), - island.getLevel(), island.getMessage(IslandMessage.Signature), island.getStatus()); - } - - if (!banManager.hasIsland(island.getOwnerUUID())) { - banManager.createIsland(island.getOwnerUUID()); - } - - Bukkit.getScheduler().runTask(plugin, () -> - Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper()))); - + + if (islandOwnerUUID != null && !containsIsland(islandOwnerUUID)) { + config = fileManager.getConfig(new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml")); + + if (config.getFileConfiguration().getString("Location") == null) { + deleteIslandData(islandOwnerUUID); + configLoad.set("Island.Owner", null); + return; } + + Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); + islandStorage.put(islandOwnerUUID, island); + + for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { + prepareIsland(island, worldList); + } + + if (!visitManager.hasIsland(island.getOwnerUUID())) { + visitManager.createIsland(island.getOwnerUUID(), + new IslandLocation[]{island.getIslandLocation(IslandWorld.Normal, IslandEnvironment.Island), island.getIslandLocation(IslandWorld.Nether, IslandEnvironment.Island), + island.getIslandLocation(IslandWorld.End, IslandEnvironment.Island)}, + island.getSize(), island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1, island.getBankBalance(), visitManager.getIslandSafeLevel(island.getOwnerUUID()), + island.getLevel(), island.getMessage(IslandMessage.Signature), island.getStatus()); + } + + if (!banManager.hasIsland(island.getOwnerUUID())) { + banManager.createIsland(island.getOwnerUUID()); + } + + Bukkit.getScheduler().runTask(plugin, () -> + Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper()))); } } + + public void loadIsland(File islandFile) { + VisitManager visitManager = plugin.getVisitManager(); + FileManager fileManager = plugin.getFileManager(); + BanManager banManager = plugin.getBanManager(); + + Config config = fileManager.getConfig(islandFile); + FileConfiguration configLoad = config.getFileConfiguration(); + + UUID islandOwnerUUID = FastUUID.parseUUID(configLoad.getString("Island.Owner", "")); + + if (config.getFileConfiguration().getString("Location") == null) { + deleteIslandData(islandOwnerUUID); + configLoad.set("Island.Owner", null); + + return; + } + + Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)); + islandStorage.put(islandOwnerUUID, island); + + for (IslandWorld worldList : IslandWorld.getIslandWorlds()) { + prepareIsland(island, worldList); + } + + if (!visitManager.hasIsland(island.getOwnerUUID())) { + visitManager.createIsland(island.getOwnerUUID(), + new IslandLocation[]{island.getIslandLocation(IslandWorld.Normal, IslandEnvironment.Island), island.getIslandLocation(IslandWorld.Nether, IslandEnvironment.Island), + island.getIslandLocation(IslandWorld.End, IslandEnvironment.Island)}, + island.getSize(), island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1, island.getBankBalance(), visitManager.getIslandSafeLevel(island.getOwnerUUID()), + island.getLevel(), island.getMessage(IslandMessage.Signature), island.getStatus()); + } + + if (!banManager.hasIsland(island.getOwnerUUID())) { + banManager.createIsland(island.getOwnerUUID()); + } + + Bukkit.getScheduler().runTask(plugin, () -> + Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper()))); + } /** * The old island position system was not good, it always create islands at x = 1200 and z starting at 0 and increasing by 1200
    @@ -801,14 +835,17 @@ public class IslandManager { File configFile = new File(plugin.getDataFolder().toString() + "/island-data"); if (!configFile.exists()) return; + + File[] files = configFile.listFiles(); + if(files == null) return; - for (File fileList : configFile.listFiles()) { - if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) { + for (File file : files) { + if (file != null && file.getName().contains(".yml") && file.getName().length() > 35) { try { - Config config = new FileManager.Config(fileManager, fileList); + Config config = new FileManager.Config(fileManager, file); FileConfiguration configLoad = config.getFileConfiguration(); - int size = 100; + int size = 10; if (configLoad.getString("Size") != null) { size = configLoad.getInt("Size"); } @@ -816,6 +853,7 @@ public class IslandManager { Location islandLocation = fileManager.getLocation(config, "Location.Normal.Island", false); if (LocationUtil.isLocationInLocationRadius(location, islandLocation, size)) { + loadIsland(file); return; } } catch (Exception e) { diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 3f452327..2f24cba1 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -169,27 +169,32 @@ public class Move implements Listener { } } - // Load the island they are now on if one exists - islandManager.loadIslandAtLocation(player.getLocation()); - Island loadedIsland = islandManager.getIslandAtLocation(player.getLocation()); - if (loadedIsland != null) { - if (player.hasPermission("fabledskyblock.bypass")) { - playerData.setIsland(loadedIsland.getOwnerUUID()); - return; - } - - if(loadedIsland.getStatus().equals(IslandStatus.OPEN) || - (loadedIsland.getStatus().equals(IslandStatus.WHITELISTED) && loadedIsland.isPlayerWhitelisted(player))){ - loadedIsland.getVisit().addVisitor(player.getUniqueId()); - return; - } - } - - LocationUtil.teleportPlayerToSpawn(player); - - messageManager.sendMessage(player, - plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); - soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + Location playerLoc = player.getLocation(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + // Load the island they are now on if one exists + islandManager.loadIslandAtLocation(playerLoc); + Bukkit.getScheduler().runTask(plugin, () -> { + Island loadedIsland = islandManager.getIslandAtLocation(playerLoc); + if (loadedIsland != null) { + if (player.hasPermission("fabledskyblock.bypass")) { + playerData.setIsland(loadedIsland.getOwnerUUID()); + return; + } + + if(loadedIsland.getStatus().equals(IslandStatus.OPEN) || + (loadedIsland.getStatus().equals(IslandStatus.WHITELISTED) && loadedIsland.isPlayerWhitelisted(player))){ + loadedIsland.getVisit().addVisitor(player.getUniqueId()); + return; + } + } + + LocationUtil.teleportPlayerToSpawn(player); + + messageManager.sendMessage(player, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); + soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F); + }); + }); } } From ab8288e4c01e99605c6dcccd99cb5b89cdd75dac Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 30 Jul 2020 16:26:05 +0200 Subject: [PATCH 286/366] Nonnull notation --- src/main/java/com/songoda/skyblock/island/Island.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index c751e497..6c9cde9c 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -28,6 +28,7 @@ import org.bukkit.block.Biome; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import javax.annotation.Nonnull; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; @@ -52,7 +53,7 @@ public class Island { private int maxMembers; private boolean deleted = false; - public Island(OfflinePlayer player) { + public Island(@Nonnull OfflinePlayer player) { this.plugin = SkyBlock.getInstance(); FileManager fileManager = plugin.getFileManager(); From 0c53fbde5c43834d214a488c48cb42bc421adef5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 30 Jul 2020 16:27:25 +0200 Subject: [PATCH 287/366] UpdateAllIslands command --- .../skyblock/command/CommandManager.java | 3 +- .../admin/UpdateAllIslandsCommand.java | 98 +++++++++++++++++++ .../skyblock/island/IslandManager.java | 86 ++++++++++++++++ src/main/resources/language.yml | 15 +++ 4 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index 8e8b6f02..c541b7da 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -118,7 +118,8 @@ public class CommandManager implements CommandExecutor, TabCompleter { new StackableCommand(), new AdminBank(), new SetMaxMembers(), - new ChatSpyCommand() + new ChatSpyCommand(), + new UpdateAllIslandsCommand() ); } diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java new file mode 100644 index 00000000..7660612d --- /dev/null +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java @@ -0,0 +1,98 @@ +package com.songoda.skyblock.command.commands.admin; + +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.skyblock.command.SubCommand; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.sound.SoundManager; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; + +public class UpdateAllIslandsCommand extends SubCommand { + + @Override + public void onCommandByPlayer(Player player, String[] args) { + processCommand(player, args); + } + + @Override + public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { + processCommand(sender, args); + } + + public void processCommand(CommandSender sender, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); + SoundManager soundManager = plugin.getSoundManager(); + + FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (args.length < 1) { + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.NoArgs.Message")); + soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } else { + switch (args[0].toLowerCase()) { + case "setsize": + if (args.length >= 2) { + int size; + try { + size = Integer.parseInt(args[1]); + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Start.Message")); + islandManager.setAllIslandsSize(Math.abs(size), () -> + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Finished.Message"))); + } catch (NumberFormatException ignored) { + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Unexpected.Message")); + } + } else { + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.NotANumber.Message")); + } + return; + case "adjustsize": + if (args.length >= 2) { + int size; + try { + size = Integer.parseInt(args[1]); + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Start.Message")); + islandManager.adjustAllIslandsSize(size, () -> + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Finished.Message"))); + } catch (NumberFormatException ignored) { + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.NotANumber.Message")); + } + } else { + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Unexpected.Message")); + } + return; + default: + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Unexpected.Message")); + soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); + } + } + } + + @Override + public String getName() { + return "updateallIslands"; + } + + @Override + public String getInfoMessagePath() { + return "Command.Island.Admin.UpdateAllIslands.Info.Message"; + } + + @Override + public String[] getAliases() { + return new String[0]; + } + + @Override + public String[] getArguments() { + return new String[] {"SetSize", "AdjustSize"}; + } +} diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 0ac45ca5..c655fe2f 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -55,11 +55,15 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.util.*; +import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; import java.util.stream.Collectors; public class IslandManager { @@ -742,6 +746,88 @@ public class IslandManager { } } + public void adjustAllIslandsSize(@Nonnull int diff, @Nullable Runnable callback) { + FileManager fileManager = plugin.getFileManager(); + File islandConfigDir = new File(plugin.getDataFolder().toString() + "/island-data"); + + if (!islandConfigDir.exists()) return; + + File[] files = islandConfigDir.listFiles(); + if(files == null) return; + + for (File file : files) { + if (file != null && file.getName().contains(".yml") && file.getName().length() > 35) { + try { + Config config = new FileManager.Config(fileManager, file); + FileConfiguration islandConfigLoad = config.getFileConfiguration(); + + UUID islandOwnerUUID = FastUUID.parseUUID(islandConfigLoad.getString("Island.Owner", "")); + + Island island = getIslandByUUID(islandOwnerUUID); + + if(island != null) { + island.setSize(island.getSize() + diff); + island.save(); + } else { + loadIsland(file); + island = getIslandByUUID(islandOwnerUUID); + + island.setSize(island.getSize() + diff); + island.save(); + unloadIsland(island, null); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + if(callback != null) { + callback.run(); + } + } + + public void setAllIslandsSize(@Nonnull int size, @Nullable Runnable callback) { + FileManager fileManager = plugin.getFileManager(); + File islandConfigDir = new File(plugin.getDataFolder().toString() + "/island-data"); + + if (!islandConfigDir.exists()) return; + + File[] files = islandConfigDir.listFiles(); + if(files == null) return; + + for (File file : files) { + if (file != null && file.getName().contains(".yml") && file.getName().length() > 35) { + try { + Config config = new FileManager.Config(fileManager, file); + FileConfiguration islandConfigLoad = config.getFileConfiguration(); + + UUID islandOwnerUUID = FastUUID.parseUUID(islandConfigLoad.getString("Island.Owner", "")); + + Island island = getIslandByUUID(islandOwnerUUID); + + if(island != null) { + island.setSize(size); + island.save(); + } else { + loadIsland(file); + island = getIslandByUUID(islandOwnerUUID); + + island.setSize(size); + island.save(); + unloadIsland(island, null); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + if(callback != null) { + callback.run(); + } + } + public void loadIsland(File islandFile) { VisitManager visitManager = plugin.getVisitManager(); FileManager fileManager = plugin.getFileManager(); diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index eee4d2c3..67f62100 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -189,6 +189,19 @@ Command: Permission: Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to unban players from the Island.' Admin: + UpdateAllIslands: + Unexpected: + Message: '&bSkyBlock &8| &cError&8: &eUnexpected values' + NoArgs: + Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin UpdateAllIslands ' + Start: + Message: '&bSkyBlock &8| &aInfo&8: &eIslands update started. It could take some time.' + Finished: + Message: '&bSkyBlock &8| &aInfo&8: &eIslands update finished.' + NotANumber: + Message: '&bSkyBlock &8| &cError&8: &eThe provided value is not valid.' + Info: + Message: '&f&oEdit all the islands in one time.' Bank: Short01: Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank []' @@ -206,6 +219,8 @@ Command: Message: 'Succesfully removed %ammount% from %player%''s island' SuccesDeposit: Message: 'Succesfully added %ammount% to %player%''s island' + Unexpected: + Message: '&bSkyBlock &8| &cError&8: &eUnexpected values' ChatSpy: Info: Message: '&f&oToggle island chat spy.' From 57fde643df8460b58e321c580f400b35a5abf4eb Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 30 Jul 2020 20:24:56 +0200 Subject: [PATCH 288/366] Simplified IslandManager --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index c655fe2f..5b684365 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1651,7 +1651,9 @@ public class IslandManager { settings.put("Damage", true); for (String settingList : settings.keySet()) { - if (configLoad.getBoolean("Island.Settings." + settingList + ".Enable") && island.hasPermission(IslandRole.Owner, plugin.getPermissionManager().getPermission(settingList)) == settings.get(settingList)) { + if (configLoad.getBoolean("Island.Settings." + settingList + ".Enable") && + island.hasPermission(IslandRole.Owner, plugin.getPermissionManager().getPermission(settingList)) == + settings.get(settingList)) { safeLevel++; } } From f8323af0b7cdd8baeaa70a6c6fd8c1117a9a9e25 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 30 Jul 2020 21:28:36 +0200 Subject: [PATCH 289/366] Allow edit island command alias --- .../skyblock/command/CommandManager.java | 47 ++++++++++--------- src/main/resources/config.yml | 5 ++ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index c541b7da..dd016d76 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -130,8 +130,11 @@ public class CommandManager implements CommandExecutor, TabCompleter { SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); - Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); + Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration languageConfigLoad = languageConfig.getFileConfiguration(); + + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration mainConfig = config.getFileConfiguration(); Player player = null; @@ -143,22 +146,21 @@ public class CommandManager implements CommandExecutor, TabCompleter { if (player == null) { sendConsoleHelpCommands(sender); } else { + String commandToExecute; if (plugin.getIslandManager().getIsland(player) == null) { - Bukkit.getServer().getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(sender, "island create")); + commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", "island create"); } else { - boolean canUseControlPanel = player.hasPermission("fabledskyblock.*") - || player.hasPermission("fabledskyblock.island.*") - || player.hasPermission("fabledskyblock.island.controlpanel"); - - if (!canUseControlPanel) { - messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Island.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - return true; - } - - ControlPanel.getInstance().open(player); - soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); + commandToExecute = mainConfig.getString("Command.Island.Aliases.IslandOwned", "island controlpanel"); } + + if(commandToExecute.startsWith("/")) { + commandToExecute = commandToExecute.substring(1); + } + + String finalCommandToExecute = commandToExecute; + Bukkit.getServer().getScheduler().runTask(plugin, () -> + Bukkit.getServer().dispatchCommand(sender, + finalCommandToExecute)); } return true; @@ -176,15 +178,14 @@ public class CommandManager implements CommandExecutor, TabCompleter { || player.hasPermission("fabledskyblock.island.help"); if (!canUseHelp) { - messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Island.Message")); + messageManager.sendMessage(player, languageConfigLoad.getString("Command.PermissionDenied.Island.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return true; } int page = -1; - if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) - .getFileConfiguration().getBoolean("Command.Help.List")) { + if (!mainConfig.getBoolean("Command.Help.List")) { page = 1; if (args.length == 2) { @@ -192,7 +193,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { page = Integer.valueOf(args[1]); } else { messageManager.sendMessage(player, - configLoad.getString("Command.Island.Help.Integer.Message")); + languageConfigLoad.getString("Command.Island.Help.Integer.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return true; @@ -214,7 +215,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { || player.hasPermission("fabledskyblock.admin.help"); if (!canUseHelp) { - messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Admin.Message")); + messageManager.sendMessage(player, languageConfigLoad.getString("Command.PermissionDenied.Admin.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return true; } @@ -230,7 +231,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { page = Integer.valueOf(args[2]); } else { messageManager.sendMessage(player, - configLoad.getString("Command.Island.Help.Integer.Message")); + languageConfigLoad.getString("Command.Island.Help.Integer.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); @@ -253,13 +254,13 @@ public class CommandManager implements CommandExecutor, TabCompleter { } if (subCommand == null) { - messageManager.sendMessage(sender, configLoad.getString("Command.Island.Argument.Unrecognised.Message")); + messageManager.sendMessage(sender, languageConfigLoad.getString("Command.Island.Argument.Unrecognised.Message")); soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); return true; } if (!subCommand.hasPermission(sender, isAdmin)) { - messageManager.sendMessage(sender, configLoad.getString("Command.PermissionDenied." + (isAdmin ? "Admin" : "Island") + ".Message")); + messageManager.sendMessage(sender, languageConfigLoad.getString("Command.PermissionDenied." + (isAdmin ? "Admin" : "Island") + ".Message")); soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); return true; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 243ef243..515023bb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -5,6 +5,11 @@ Command: # Shows all aliases of the commands. Aliases: Enable: true + Island: + # What command should be executed on /is or /island + Aliases: + IslandOwned: "island controlpanel" + NoIsland: "island create" Sound: # When disabled all sounds will be disabled. Enable: true From d0ece124fa3f739478a0c7162ad6068a3b87bfcc Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 30 Jul 2020 22:05:51 +0200 Subject: [PATCH 290/366] Fix updateallislands command --- .../admin/UpdateAllIslandsCommand.java | 2 +- .../skyblock/island/IslandManager.java | 25 ++++++------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java index 7660612d..6c8b1fb7 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/UpdateAllIslandsCommand.java @@ -78,7 +78,7 @@ public class UpdateAllIslandsCommand extends SubCommand { @Override public String getName() { - return "updateallIslands"; + return "updateallislands"; } @Override diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 5b684365..4b9347c1 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -60,10 +60,8 @@ import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Consumer; import java.util.stream.Collectors; public class IslandManager { @@ -758,19 +756,16 @@ public class IslandManager { for (File file : files) { if (file != null && file.getName().contains(".yml") && file.getName().length() > 35) { try { - Config config = new FileManager.Config(fileManager, file); - FileConfiguration islandConfigLoad = config.getFileConfiguration(); - - UUID islandOwnerUUID = FastUUID.parseUUID(islandConfigLoad.getString("Island.Owner", "")); + UUID islandOwnerUUID = FastUUID.parseUUID(file.getName().split("\\.")[0]); - Island island = getIslandByUUID(islandOwnerUUID); + Island island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID)); if(island != null) { island.setSize(island.getSize() + diff); island.save(); } else { loadIsland(file); - island = getIslandByUUID(islandOwnerUUID); + island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID)); island.setSize(island.getSize() + diff); island.save(); @@ -788,7 +783,6 @@ public class IslandManager { } public void setAllIslandsSize(@Nonnull int size, @Nullable Runnable callback) { - FileManager fileManager = plugin.getFileManager(); File islandConfigDir = new File(plugin.getDataFolder().toString() + "/island-data"); if (!islandConfigDir.exists()) return; @@ -799,19 +793,16 @@ public class IslandManager { for (File file : files) { if (file != null && file.getName().contains(".yml") && file.getName().length() > 35) { try { - Config config = new FileManager.Config(fileManager, file); - FileConfiguration islandConfigLoad = config.getFileConfiguration(); + UUID islandOwnerUUID = FastUUID.parseUUID(file.getName().split("\\.")[0]); - UUID islandOwnerUUID = FastUUID.parseUUID(islandConfigLoad.getString("Island.Owner", "")); - - Island island = getIslandByUUID(islandOwnerUUID); + Island island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID)); if(island != null) { island.setSize(size); island.save(); } else { loadIsland(file); - island = getIslandByUUID(islandOwnerUUID); + island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID)); island.setSize(size); island.save(); @@ -835,8 +826,8 @@ public class IslandManager { Config config = fileManager.getConfig(islandFile); FileConfiguration configLoad = config.getFileConfiguration(); - - UUID islandOwnerUUID = FastUUID.parseUUID(configLoad.getString("Island.Owner", "")); + + UUID islandOwnerUUID = FastUUID.parseUUID(islandFile.getName().split("\\.")[0]); if (config.getFileConfiguration().getString("Location") == null) { deleteIslandData(islandOwnerUUID); From 4c160f0627d945e59863b5826e0b7abaef4c849a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 30 Jul 2020 22:58:09 +0200 Subject: [PATCH 291/366] Initial work to GuiCoop --- .../com/songoda/skyblock/gui/wip/GuiCoop.java | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java new file mode 100644 index 00000000..602456fb --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java @@ -0,0 +1,146 @@ +package com.songoda.skyblock.gui.wip; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandCoop; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.permission.PermissionManager; +import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.utils.item.SkullUtil; +import com.songoda.skyblock.utils.player.OfflinePlayer; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.io.File; +import java.util.Map; +import java.util.UUID; + +public class GuiCoop extends Gui { + private final SkyBlock plugin; + private final Island island; + private final FileConfiguration languageLoad; + + public GuiCoop(SkyBlock plugin, Island island, Gui returnGui) { + super(returnGui); + this.plugin = plugin; + this.island = island; + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + setDefaultItem(null); + setTitle(TextUtils.formatText("Coop")); + paint(); + } + + public void paint() { // TODO Item to add ban + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + SoundManager soundManager = plugin.getSoundManager(); + + if (inventory != null) + inventory.clear(); + setActionForRange(0, 0, 1, 8, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); + event.player.closeInventory(); + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); + event.player.closeInventory(); + }); + + for(int i=9; i<18; i++){ + setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + } + + Map coopPlayers = island.getCoopPlayers(); + + if(coopPlayers.size() == 0){ + ItemStack empty = CompatibleMaterial.BARRIER.getItem(); + ItemMeta emptyMeta = empty.getItemMeta(); + emptyMeta.setDisplayName(languageLoad.getString("Menu.Coop.Item.Nothing.Displayname")); + empty.setItemMeta(emptyMeta); + setButton(31, empty, (event) -> + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F)); + } else { + this.pages = (int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d)); + + if (page != 1) + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))), + (event) -> { + page--; + paint(); + }); + + if (page != pages) + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); + + UUID[] coopUUIDs = (UUID[]) coopPlayers.keySet().toArray(); + + for (int i = 9; i < ((getRows()-2)*9)+18; i++) { + int current = ((page - 1) * 36) - 18; + if (current + i >= coopPlayers.size()) { + setItem(i, null); + continue; + } + UUID uuid = coopUUIDs[current + i]; + if (uuid == null) continue; + + String targetPlayerName; + String[] targetPlayerTexture; + + Player targetPlayer = Bukkit.getServer().getPlayer(uuid); + + if (targetPlayer == null) { + OfflinePlayer offlinePlayer = new OfflinePlayer(uuid); + targetPlayerName = offlinePlayer.getName(); + targetPlayerTexture = offlinePlayer.getTexture(); + } else { + targetPlayerName = targetPlayer.getName(); + + if (playerDataManager.hasPlayerData(targetPlayer)) { + targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture(); + } else { + targetPlayerTexture = new String[]{null, null}; + } + } + + ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]); + ItemMeta im = is.getItemMeta(); + if(im != null){ + im.setDisplayName(languageLoad.getString("Menu.Bans.Item.Ban.Displayname") + .replace("%player", targetPlayerName == null ? "" : targetPlayerName)); + im.setLore(languageLoad.getStringList("Menu.Bans.Item.Ban.Lore")); + is.setItemMeta(im); + } + + setButton(i, is, e -> { + String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); // TODO Check if it actually works + Bukkit.getServer().dispatchCommand(e.player, "island coop " + playerName); // TODO Command or APIs? + }); + } + } + } +} From 72f468d191692fe1b60e0de59a7ba20964c49d5b Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 31 Jul 2020 23:13:27 +0200 Subject: [PATCH 292/366] Removed unused assign --- src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java b/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java index 8ce7a12f..5bd97ffd 100644 --- a/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java @@ -49,7 +49,7 @@ public final class SkullUtil { GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null); gameProfile.getProperties().put("textures", new Property("textures", value, signature)); - Field profileField = null; + Field profileField; try { profileField = sm.getClass().getDeclaredField("profile"); From d1fdc9217ad9c55629467bb484ab55e3cff3ab0d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 31 Jul 2020 23:20:47 +0200 Subject: [PATCH 293/366] Allow disabling SafeLocationCheck --- .../skyblock/island/IslandManager.java | 2 +- .../com/songoda/skyblock/listeners/Move.java | 4 +- .../songoda/skyblock/listeners/Portal.java | 2 +- .../listening/PortalPermission.java | 2 +- .../skyblock/utils/world/LocationUtil.java | 37 ++++++++++--------- src/main/resources/config.yml | 2 + 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 4b9347c1..b68bfe60 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1240,7 +1240,7 @@ public class IslandManager { } Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor); if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - Location safeLoc = LocationUtil.getSafeLocation(loc); + Location safeLoc = LocationUtil.getSafeLocation(plugin, loc); if(safeLoc != null){ loc = safeLoc; } diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index 2f24cba1..a025a08a 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -203,7 +203,7 @@ public class Move implements Listener { 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)) { - Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main)); + Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(world, IslandEnvironment.Main)); if(safeLoc != null){ loc = safeLoc; } @@ -213,7 +213,7 @@ public class Move implements Listener { } } else { if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor)); + Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(world, IslandEnvironment.Visitor)); if(safeLoc != null){ loc = safeLoc; } diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 03e3208a..26ccac6a 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -163,7 +163,7 @@ public class Portal implements Listener { IslandWorld toWorldF = toWorld; Bukkit.getScheduler().runTaskLater(plugin, () -> { Location loc = island.getLocation(toWorldF, spawnEnvironment); - Location tempSafeLoc = LocationUtil.getSafeLocation(loc); + Location tempSafeLoc = LocationUtil.getSafeLocation(plugin, loc); Location safeLoc = null; if(tempSafeLoc != null) { safeLoc = tempSafeLoc; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index 7b4e2be1..e7dd02be 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -71,7 +71,7 @@ public class PortalPermission extends ListeningPermission { Island island = islandManager.getIslandAtLocation(from); Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ - Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); + Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); if(safeLoc != null) { to = safeLoc; } 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 821be37b..0213b050 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -45,26 +45,29 @@ public final class LocationUtil { } } - public static @Nullable Location getSafeLocation(@Nonnull Location loc){ - boolean found = false; + public static @Nullable Location getSafeLocation(SkyBlock plugin, @Nonnull Location loc){ Location locChecked = null; - if(loc.getWorld() != null){ - 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); + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { + boolean found = false; + if(loc.getWorld() != null){ + 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) { - locChecked = locChecked.add(0d,1d,0d); - } else { - locChecked = null; + 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; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 515023bb..8defda5e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -359,6 +359,8 @@ Island: # Enable or disable Fall damage FallDamage: true RemoveWater: true + # Check if location is safe before teleporting + SafetyCheck: true Limits: # Should slime split bypass limits.yml AllowSlimeSplit: true From e8c95c98949c0d7de194071a2fb13c71c8d44188 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 31 Jul 2020 23:30:08 +0200 Subject: [PATCH 294/366] Consider waterlogged blocks in 1.13 --- .../java/com/songoda/skyblock/utils/world/LocationUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 0213b050..7694012a 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -78,7 +78,8 @@ public final class LocationUtil { for(locWorking.setY(locWorking.getBlockY()); locWorking.getBlockY()>=0; locWorking.setY(locWorking.getBlockY()-1)){ if(!locWorking.getBlock().isEmpty()){ if(locWorking.getBlock().getType().equals(CompatibleMaterial.WATER.getMaterial()) || - (NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ + (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && + locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){ loc = locWorking; } break; From 5d77789036e8fa1a218682f999f5e3c147d11895 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 31 Jul 2020 23:45:40 +0200 Subject: [PATCH 295/366] Optimized entity limitation (0ddlyoko) --- .../limit/LimitationInstanceHandler.java | 26 ++++++++++++++----- ...tyLimitaton.java => EntityLimitation.java} | 21 +++++++++------ .../songoda/skyblock/listeners/Entity.java | 4 +-- 3 files changed, 34 insertions(+), 17 deletions(-) rename src/main/java/com/songoda/skyblock/limit/impl/{EntityLimitaton.java => EntityLimitation.java} (70%) diff --git a/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java b/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java index bea798ec..d28e3d50 100644 --- a/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java +++ b/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java @@ -2,7 +2,7 @@ package com.songoda.skyblock.limit; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.limit.impl.BlockLimitation; -import com.songoda.skyblock.limit.impl.EntityLimitaton; +import com.songoda.skyblock.limit.impl.EntityLimitation; import org.bukkit.configuration.Configuration; import java.io.File; @@ -12,14 +12,23 @@ import java.util.Map; public final class LimitationInstanceHandler { private final Map, Limitation> instances; - + + // If true, load all chunks on player's island to count entities. + // If false, do not load all chunks and only count entites on loaded chunks on player's island. + private boolean loadChunks; + + public LimitationInstanceHandler() { this.instances = new HashMap<>(); - registerInstance(new EntityLimitaton()); + registerInstance(new EntityLimitation(this)); registerInstance(new BlockLimitation()); reloadAll(); } - + + public boolean isLoadChunks() { + return loadChunks; + } + public T getInstance(Class type) { return type.cast(instances.get(type)); } @@ -29,9 +38,12 @@ public final class LimitationInstanceHandler { } public void reloadAll() { - final SkyBlock instance = SkyBlock.getInstance(); - final Configuration config = instance.getFileManager().getConfig(new File(instance.getDataFolder(), "limits.yml")).getFileConfiguration(); - + final SkyBlock plugin = SkyBlock.getInstance(); + final Configuration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "limits.yml")).getFileConfiguration(); + + loadChunks = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Limits.LoadChunks"); + for (Limitation limit : instances.values()) { limit.reload(config.getConfigurationSection(limit.getSectionName())); } diff --git a/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitaton.java b/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitation.java similarity index 70% rename from src/main/java/com/songoda/skyblock/limit/impl/EntityLimitaton.java rename to src/main/java/com/songoda/skyblock/limit/impl/EntityLimitation.java index 42e05ecb..967d98a2 100644 --- a/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitaton.java +++ b/src/main/java/com/songoda/skyblock/limit/impl/EntityLimitation.java @@ -4,16 +4,20 @@ import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.limit.EnumLimitation; +import com.songoda.skyblock.limit.LimitationInstanceHandler; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -public final class EntityLimitaton extends EnumLimitation { - - public EntityLimitaton() { +public final class EntityLimitation extends EnumLimitation { + + private final LimitationInstanceHandler limitationInstanceHandler; + + public EntityLimitation(LimitationInstanceHandler limitationInstanceHandler) { super(EntityType.class); + this.limitationInstanceHandler = limitationInstanceHandler; } public long getEntityCount(Island island, IslandWorld islandWorld, EntityType type) { @@ -35,12 +39,13 @@ public final class EntityLimitaton extends EnumLimitation { for (int x = minX; x < maxX + 16; x += 16) { for (int z = minZ; z < maxZ + 16; z += 16) { - final Chunk chunk = world.getChunkAt(x >> 4, z >> 4); - - for (Entity ent : chunk.getEntities()) { - if (ent.getType() == type) count++; + if (limitationInstanceHandler.isLoadChunks() || world.isChunkLoaded(x >> 4, z >> 4)) { + final Chunk chunk = world.getChunkAt(x >> 4, z >> 4); + + for (Entity ent : chunk.getEntities()) { + if (ent.getType() == type) count++; + } } - } } return count; diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index b998a582..6cf86878 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -6,7 +6,7 @@ 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; +import com.songoda.skyblock.limit.impl.EntityLimitation; import com.songoda.skyblock.stackable.Stackable; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.upgrade.Upgrade; @@ -569,7 +569,7 @@ public class Entity implements Listener { if (island == null) return; - EntityLimitaton limits = plugin.getLimitationHandler().getInstance(EntityLimitaton.class); + EntityLimitation limits = plugin.getLimitationHandler().getInstance(EntityLimitation.class); EntityType type = entity.getType(); if (limits.isBeingTracked(type)) { From f84d074be523eb31b23738ed9a910fa09b2c6385 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 31 Jul 2020 23:45:58 +0200 Subject: [PATCH 296/366] Fixed max eight in block scanner (0ddlyoko) --- .../java/com/songoda/skyblock/blockscanner/BlockScanner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index 054fa1e1..9ca2e44c 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -117,7 +117,7 @@ public final class BlockScanner extends BukkitRunnable { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { - for (int y = scanY; y < 256; y++) { + for (int y = scanY; y < shot.getHighestBlockYAt(x, z); y++) { final CompatibleMaterial type = CompatibleMaterial.getBlockMaterial(VERSION > 12 From 495e433c433fda5cb21eea7e1c3dddece7607816 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 31 Jul 2020 23:46:36 +0200 Subject: [PATCH 297/366] LoadChunks value in config --- src/main/resources/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 8defda5e..f0f61846 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -364,6 +364,9 @@ Island: Limits: # Should slime split bypass limits.yml AllowSlimeSplit: true + # If true, load all chunks on player's island to count entities. + # If false, do not load all chunks and only count entites on loaded chunks on player's island. + LoadChunks: true Nether: # Allow placing water in the Nether AllowNetherWater: false From 7ee069fee5b5f0ec6b058599362715b2a151a3f3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 00:51:21 +0200 Subject: [PATCH 298/366] Fix Sponges increasing level --- .../com/songoda/skyblock/listeners/Block.java | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index ecad2d0f..2d97a90b 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -336,6 +336,28 @@ public class Block implements Listener { && event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return; islandLevelManager.updateLevel(island, blockLoc); + + // Sponge level dupe fix + if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13) && + block.getType().equals(CompatibleMaterial.SPONGE.getBlockMaterial())) { + Bukkit.getScheduler().runTask(plugin, () -> { + if(blockLoc.getBlock().getType().equals(CompatibleMaterial.WET_SPONGE.getBlockMaterial())) { + IslandLevel level = island.getLevel(); + CompatibleMaterial material = CompatibleMaterial.SPONGE; + if (level.hasMaterial(material.name())) { + long materialAmount = level.getMaterialAmount(material.name()); + + if (materialAmount - 1 <= 0) { + level.removeMaterial(material.name()); + } else { + level.setMaterialAmount(material.name(), materialAmount - 1); + } + + islandLevelManager.updateLevel(island, blockLoc); + } + } + }); + } } @EventHandler @@ -792,7 +814,48 @@ public class Block implements Listener { return false; } - @EventHandler + @EventHandler(ignoreCancelled = true) + public void onSponge(SpongeAbsorbEvent event) { + IslandLevelManager islandLevelManager = plugin.getLevellingManager(); + IslandManager islandManager = plugin.getIslandManager(); + StackableManager stackableManager = plugin.getStackableManager(); + WorldManager worldManager = plugin.getWorldManager(); + + org.bukkit.block.Block block = event.getBlock(); + + if (worldManager.isIslandWorld(block.getWorld())) { + Location blockLocation = block.getLocation(); + + Island island = islandManager.getIslandAtLocation(blockLocation); + if (island != null) { + if (plugin.getPermissionManager().processPermission(event, island) && !event.isCancelled()) { + if (stackableManager == null || !stackableManager.isStacked(blockLocation)) { + IslandLevel level = island.getLevel(); + + CompatibleMaterial material = CompatibleMaterial.SPONGE; + if (level.hasMaterial(material.name())) { + long materialAmount = level.getMaterialAmount(material.name()); + + if (materialAmount - 1 <= 0) { + level.removeMaterial(material.name()); + } else { + level.setMaterialAmount(material.name(), materialAmount - 1); + } + + Bukkit.getScheduler().runTask(plugin, () -> islandLevelManager.updateLevel(island, blockLocation)); + } + } else { + event.setCancelled(true); + } + } + } else { + event.setCancelled(true); + } + } + + } + + @EventHandler(ignoreCancelled = true) public void onBlockBurn(BlockBurnEvent event) { org.bukkit.block.Block block = event.getBlock(); WorldManager worldManager = plugin.getWorldManager(); From 056ff3dae541a47e8608f652809ef90efd6a9839 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 17:20:50 +0200 Subject: [PATCH 299/366] New coop gui --- .../command/commands/island/CoopCommand.java | 6 +- .../songoda/skyblock/gui/coop/GuiCoop.java | 186 ++++++++++++++++++ .../skyblock/gui/coop/GuiCoopChoose.java | 72 +++++++ .../com/songoda/skyblock/gui/wip/GuiCoop.java | 146 -------------- 4 files changed, 261 insertions(+), 149 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java create mode 100644 src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java delete mode 100644 src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java index 400cfc37..f9d894cb 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java @@ -4,8 +4,8 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.command.SubCommand; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; +import com.songoda.skyblock.gui.coop.GuiCoop; import com.songoda.skyblock.island.*; -import com.songoda.skyblock.menus.Coop; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.sound.SoundManager; @@ -125,8 +125,8 @@ public class CoopCommand extends SubCommand { return; } - - Coop.getInstance().open(player); + + plugin.getGuiManager().showGUI(player, new GuiCoop(plugin, island, null)); soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F); } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Permission.Message")); diff --git a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java new file mode 100644 index 00000000..e51ce0dd --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java @@ -0,0 +1,186 @@ +package com.songoda.skyblock.gui.coop; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.AnvilGui; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandCoop; +import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.message.MessageManager; +import com.songoda.skyblock.permission.PermissionManager; +import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.sound.SoundManager; +import com.songoda.skyblock.utils.item.SkullUtil; +import com.songoda.skyblock.utils.player.OfflinePlayer; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.io.File; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class GuiCoop extends Gui { + private final SkyBlock plugin; + private final Island island; + private final FileConfiguration languageLoad; + + public GuiCoop(SkyBlock plugin, Island island, Gui returnGui) { + super(returnGui); + this.plugin = plugin; + this.island = island; + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + setDefaultItem(null); + setTitle(TextUtils.formatText(languageLoad.getString("Menu.Coop.Title"))); + paint(); + } + + public void paint() { + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + SoundManager soundManager = plugin.getSoundManager(); + PermissionManager permissionManager = plugin.getPermissionManager(); + MessageManager messageManager = plugin.getMessageManager(); + + Map coopPlayers = island.getCoopPlayers(); + + if (inventory != null) { + inventory.clear(); + } + setActionForRange(0, 0, 1, 8, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); + event.player.closeInventory(); + }); + + List addButtonLore = languageLoad.getStringList("Menu.Coop.Item.Information.Lore"); + Collections.replaceAll(addButtonLore, "%coops", "" + coopPlayers.size()); + + setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, // Add new + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Information.Displayname")), + TextUtils.formatText(addButtonLore)), + (event) -> { + if ((island.hasRole(IslandRole.Operator, event.player.getUniqueId()) + && permissionManager.hasPermission(island, "CoopPlayers", IslandRole.Operator)) + || island.hasRole(IslandRole.Owner, event.player.getUniqueId())) { + + AnvilGui gui = new AnvilGui(event.player, this); + gui.setAction((e -> { + String playerName = gui.getInputText().trim(); + guiManager.showGUI(event.player, new GuiCoopChoose(plugin, parent, island, playerName)); + })); + gui.setTitle(TextUtils.formatText( + languageLoad.getString("Menu.Coop.Item.Word.Normal") + + " / " + languageLoad.getString("Menu.Coop.Item.Word.Temp"))); + guiManager.showGUI(event.player, gui); + } else { + messageManager.sendMessage(event.player, + languageLoad.getString("Command.Island.Coop.Permission.Message")); + soundManager.playSound(event.player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + } + }); + + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); + event.player.closeInventory(); + }); + + for(int i=9; i<18; i++){ + setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + } + + if(coopPlayers.size() == 0){ + ItemStack empty = CompatibleMaterial.BARRIER.getItem(); + ItemMeta emptyMeta = empty.getItemMeta(); + emptyMeta.setDisplayName(languageLoad.getString("Menu.Coop.Item.Nothing.Displayname")); + empty.setItemMeta(emptyMeta); + setButton(31, empty, (event) -> + soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F)); + } else { + //this.pages = (int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d)); + + /*if (page != 1) { + setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Previous.Displayname"))), + (event) -> { + page--; + paint(); + }); + + + } + + if (page != pages) { + setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Next.Displayname"))), + (event) -> { + page++; + paint(); + }); + }*/ + + setPages((int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d))); + setPrevPage(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Previous.Displayname")))); + setNextPage(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Next.Displayname")))); + + UUID[] coopUUIDs = (UUID[]) coopPlayers.keySet().toArray(); + + for (int i = 9; i < ((getRows()-2)*9)+18; i++) { + int current = ((page - 1) * 36) - 18; + if (current + i < coopPlayers.size()) { + UUID uuid = coopUUIDs[current + i]; + IslandCoop type = (IslandCoop) coopPlayers.values().toArray()[current + i]; + if (uuid != null) { + String targetPlayerName; + String[] targetPlayerTexture; + + Player targetPlayer = Bukkit.getServer().getPlayer(uuid); + + if (targetPlayer == null) { + OfflinePlayer offlinePlayer = new OfflinePlayer(uuid); + targetPlayerName = offlinePlayer.getName(); + targetPlayerTexture = offlinePlayer.getTexture(); + } else { + targetPlayerName = targetPlayer.getName(); + + if (playerDataManager.hasPlayerData(targetPlayer)) { + targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture(); + } else { + targetPlayerTexture = new String[]{null, null}; + } + } + + ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]); + ItemMeta im = is.getItemMeta(); + if (im != null) { + im.setDisplayName(languageLoad.getString("Menu.Coop.Item.Coop.Displayname") + .replace("%player", targetPlayerName == null ? "" : targetPlayerName) + .replace("%type", type == IslandCoop.TEMP ? + languageLoad.getString("Menu.Coop.Item.Word.Temp") : + languageLoad.getString("Menu.Coop.Item.Word.Normal"))); + im.setLore(languageLoad.getStringList("Menu.Coop.Item.Coop.Lore")); + is.setItemMeta(im); + } + + setButton(i, is, e -> Bukkit.getServer().dispatchCommand(e.player, "island coop " + targetPlayerName)); + } + } else { + setItem(i, null); + } + } + } + } +} diff --git a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java new file mode 100644 index 00000000..f5529508 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java @@ -0,0 +1,72 @@ +package com.songoda.skyblock.gui.coop; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; +import com.songoda.core.gui.Gui; +import com.songoda.core.gui.GuiType; +import com.songoda.core.gui.GuiUtils; +import com.songoda.core.utils.TextUtils; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.sound.SoundManager; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; + +import java.io.File; + +public class GuiCoopChoose extends Gui { + + private final SkyBlock plugin; + private final FileConfiguration languageLoad; + private final Gui returnGui; + private final String targetPlayer; + + public GuiCoopChoose(SkyBlock plugin, Gui returnGui, Island island, String targetPlayer) { + super(GuiType.HOPPER); + this.plugin = plugin; + this.returnGui = returnGui; + this.targetPlayer = targetPlayer; + this.languageLoad = plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setTitle(TextUtils.formatText( + languageLoad.getString("Menu.Coop.Item.Word.Normal") + " / " + languageLoad.getString("Menu.Coop.Item.Word.Temp"))); + paint(); + } + + public void paint() { + SoundManager soundManager = plugin.getSoundManager(); + + if (inventory != null) + inventory.clear(); + + setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); + setActionForRange(0, 4, null); + + setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); + guiManager.showGUI(event.player, returnGui); + }); + setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { + soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); + guiManager.showGUI(event.player, returnGui); + }); + + setButton(1, GuiUtils.createButtonItem(CompatibleMaterial.OBSIDIAN, // Normal + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Word.Normal"))), + (event) -> { + Bukkit.getServer().dispatchCommand(event.player, + "island coop " + targetPlayer + " " + languageLoad.getString("Menu.Coop.Item.Word.Normal")); + guiManager.showGUI(event.player, returnGui); + }); + setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.GLASS, // Temp + TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Word.Temp"))), + (event) -> { + Bukkit.getServer().dispatchCommand(event.player, + "island coop " + targetPlayer + " " + languageLoad.getString("Menu.Coop.Item.Word.Temp")); + guiManager.showGUI(event.player, returnGui); + }); + } +} diff --git a/src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java b/src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java deleted file mode 100644 index 602456fb..00000000 --- a/src/main/java/com/songoda/skyblock/gui/wip/GuiCoop.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.songoda.skyblock.gui.wip; - -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.core.gui.Gui; -import com.songoda.core.gui.GuiUtils; -import com.songoda.core.utils.TextUtils; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandCoop; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.permission.PermissionManager; -import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.item.SkullUtil; -import com.songoda.skyblock.utils.player.OfflinePlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.io.File; -import java.util.Map; -import java.util.UUID; - -public class GuiCoop extends Gui { - private final SkyBlock plugin; - private final Island island; - private final FileConfiguration languageLoad; - - public GuiCoop(SkyBlock plugin, Island island, Gui returnGui) { - super(returnGui); - this.plugin = plugin; - this.island = island; - this.languageLoad = plugin.getFileManager() - .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); - setDefaultItem(null); - setTitle(TextUtils.formatText("Coop")); - paint(); - } - - public void paint() { // TODO Item to add ban - PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); - MessageManager messageManager = plugin.getMessageManager(); - IslandManager islandManager = plugin.getIslandManager(); - PermissionManager permissionManager = plugin.getPermissionManager(); - SoundManager soundManager = plugin.getSoundManager(); - - if (inventory != null) - inventory.clear(); - setActionForRange(0, 0, 1, 8, null); - - setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { - soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); - event.player.closeInventory(); - }); - - setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit - TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { - soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); - event.player.closeInventory(); - }); - - for(int i=9; i<18; i++){ - setItem(i, CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); - } - - Map coopPlayers = island.getCoopPlayers(); - - if(coopPlayers.size() == 0){ - ItemStack empty = CompatibleMaterial.BARRIER.getItem(); - ItemMeta emptyMeta = empty.getItemMeta(); - emptyMeta.setDisplayName(languageLoad.getString("Menu.Coop.Item.Nothing.Displayname")); - empty.setItemMeta(emptyMeta); - setButton(31, empty, (event) -> - soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F)); - } else { - this.pages = (int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d)); - - if (page != 1) - setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))), - (event) -> { - page--; - paint(); - }); - - if (page != pages) - setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))), - (event) -> { - page++; - paint(); - }); - - UUID[] coopUUIDs = (UUID[]) coopPlayers.keySet().toArray(); - - for (int i = 9; i < ((getRows()-2)*9)+18; i++) { - int current = ((page - 1) * 36) - 18; - if (current + i >= coopPlayers.size()) { - setItem(i, null); - continue; - } - UUID uuid = coopUUIDs[current + i]; - if (uuid == null) continue; - - String targetPlayerName; - String[] targetPlayerTexture; - - Player targetPlayer = Bukkit.getServer().getPlayer(uuid); - - if (targetPlayer == null) { - OfflinePlayer offlinePlayer = new OfflinePlayer(uuid); - targetPlayerName = offlinePlayer.getName(); - targetPlayerTexture = offlinePlayer.getTexture(); - } else { - targetPlayerName = targetPlayer.getName(); - - if (playerDataManager.hasPlayerData(targetPlayer)) { - targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture(); - } else { - targetPlayerTexture = new String[]{null, null}; - } - } - - ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]); - ItemMeta im = is.getItemMeta(); - if(im != null){ - im.setDisplayName(languageLoad.getString("Menu.Bans.Item.Ban.Displayname") - .replace("%player", targetPlayerName == null ? "" : targetPlayerName)); - im.setLore(languageLoad.getStringList("Menu.Bans.Item.Ban.Lore")); - is.setItemMeta(im); - } - - setButton(i, is, e -> { - String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); // TODO Check if it actually works - Bukkit.getServer().dispatchCommand(e.player, "island coop " + playerName); // TODO Command or APIs? - }); - } - } - } -} From 7763516fd3b541c19a528018e930e74eca90fadb Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 17:21:16 +0200 Subject: [PATCH 300/366] clone location before passing in method --- .../java/com/songoda/skyblock/utils/world/LocationUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7694012a..f94a89d6 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -36,7 +36,7 @@ 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); + Location tempLoc = LocationUtil.getDefinitiveLocation(loc.clone()); if(tempLoc.getBlock().getType().equals(Material.WATER)){ tempLoc.getBlock().setType(Material.AIR); } else if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ From dbdce40bc657025df33aec592aaafc4530fe8e4c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 17:21:24 +0200 Subject: [PATCH 301/366] Update SongodaCore --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 104dfc47..aae8cdae 100644 --- a/pom.xml +++ b/pom.xml @@ -229,7 +229,7 @@ com.songoda SongodaCore - 2.3.42 + LATEST compile From e45296251cd6ef52573095b50f24f7b79b036f8b Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 18:04:36 +0200 Subject: [PATCH 302/366] Fixed new gui Coop --- .../songoda/skyblock/gui/coop/GuiCoop.java | 38 +++++++++---------- .../skyblock/gui/coop/GuiCoopChoose.java | 20 +++++----- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java index e51ce0dd..b7e28fa8 100644 --- a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java +++ b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java @@ -34,7 +34,7 @@ public class GuiCoop extends Gui { private final FileConfiguration languageLoad; public GuiCoop(SkyBlock plugin, Island island, Gui returnGui) { - super(returnGui); + super(6, returnGui); this.plugin = plugin; this.island = island; this.languageLoad = plugin.getFileManager() @@ -77,7 +77,7 @@ public class GuiCoop extends Gui { AnvilGui gui = new AnvilGui(event.player, this); gui.setAction((e -> { String playerName = gui.getInputText().trim(); - guiManager.showGUI(event.player, new GuiCoopChoose(plugin, parent, island, playerName)); + guiManager.showGUI(event.player, new GuiCoopChoose(plugin, island, e.gui.getParent(), playerName)); })); gui.setTitle(TextUtils.formatText( languageLoad.getString("Menu.Coop.Item.Word.Normal") + @@ -103,22 +103,20 @@ public class GuiCoop extends Gui { if(coopPlayers.size() == 0){ ItemStack empty = CompatibleMaterial.BARRIER.getItem(); ItemMeta emptyMeta = empty.getItemMeta(); - emptyMeta.setDisplayName(languageLoad.getString("Menu.Coop.Item.Nothing.Displayname")); + emptyMeta.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Nothing.Displayname"))); empty.setItemMeta(emptyMeta); setButton(31, empty, (event) -> soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F)); } else { - //this.pages = (int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d)); + this.pages = (int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d)); - /*if (page != 1) { + if (page != 1) { setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Previous.Displayname"))), (event) -> { page--; paint(); }); - - } if (page != pages) { @@ -128,18 +126,13 @@ public class GuiCoop extends Gui { page++; paint(); }); - }*/ - - setPages((int) Math.max(1, Math.ceil((double) coopPlayers.size() / 36d))); - setPrevPage(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Previous.Displayname")))); - setNextPage(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, - TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Next.Displayname")))); + } - UUID[] coopUUIDs = (UUID[]) coopPlayers.keySet().toArray(); + UUID[] coopUUIDs = new UUID[coopPlayers.size()]; + coopPlayers.keySet().toArray(coopUUIDs); - for (int i = 9; i < ((getRows()-2)*9)+18; i++) { - int current = ((page - 1) * 36) - 18; + for (int i = 18; i < (((getRows()-2)*9)+18); i++) { + int current = ((page-1) * 36) - 18; if (current + i < coopPlayers.size()) { UUID uuid = coopUUIDs[current + i]; IslandCoop type = (IslandCoop) coopPlayers.values().toArray()[current + i]; @@ -166,16 +159,19 @@ public class GuiCoop extends Gui { ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]); ItemMeta im = is.getItemMeta(); if (im != null) { - im.setDisplayName(languageLoad.getString("Menu.Coop.Item.Coop.Displayname") + im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Coop.Displayname") .replace("%player", targetPlayerName == null ? "" : targetPlayerName) .replace("%type", type == IslandCoop.TEMP ? languageLoad.getString("Menu.Coop.Item.Word.Temp") : - languageLoad.getString("Menu.Coop.Item.Word.Normal"))); - im.setLore(languageLoad.getStringList("Menu.Coop.Item.Coop.Lore")); + languageLoad.getString("Menu.Coop.Item.Word.Normal")))); + im.setLore(TextUtils.formatText(languageLoad.getStringList("Menu.Coop.Item.Coop.Lore"))); is.setItemMeta(im); } - setButton(i, is, e -> Bukkit.getServer().dispatchCommand(e.player, "island coop " + targetPlayerName)); + setButton(i, is, e -> { + Bukkit.getServer().dispatchCommand(e.player, "island coop " + targetPlayerName); + paint(); + }); } } else { setItem(i, null); diff --git a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java index f5529508..0b86c846 100644 --- a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java +++ b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java @@ -20,12 +20,14 @@ public class GuiCoopChoose extends Gui { private final FileConfiguration languageLoad; private final Gui returnGui; private final String targetPlayer; + private final Island island; - public GuiCoopChoose(SkyBlock plugin, Gui returnGui, Island island, String targetPlayer) { - super(GuiType.HOPPER); + public GuiCoopChoose(SkyBlock plugin, Island island, Gui returnGui, String targetPlayer) { + super(1, returnGui); this.plugin = plugin; this.returnGui = returnGui; this.targetPlayer = targetPlayer; + this.island = island; this.languageLoad = plugin.getFileManager() .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration(); setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem()); @@ -48,25 +50,25 @@ public class GuiCoopChoose extends Gui { soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); - setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit + setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Exit.Displayname"))), (event) -> { soundManager.playSound(event.player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1f, 1f); guiManager.showGUI(event.player, returnGui); }); - setButton(1, GuiUtils.createButtonItem(CompatibleMaterial.OBSIDIAN, // Normal - TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Word.Normal"))), + setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.OBSIDIAN, // Normal + TextUtils.formatText("&r" + languageLoad.getString("Menu.Coop.Item.Word.Normal"))), (event) -> { Bukkit.getServer().dispatchCommand(event.player, "island coop " + targetPlayer + " " + languageLoad.getString("Menu.Coop.Item.Word.Normal")); - guiManager.showGUI(event.player, returnGui); + guiManager.showGUI(event.player, new GuiCoop(plugin, island, null)); }); - setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.GLASS, // Temp - TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Word.Temp"))), + setButton(5, GuiUtils.createButtonItem(CompatibleMaterial.GLASS, // Temp + TextUtils.formatText("&r" + languageLoad.getString("Menu.Coop.Item.Word.Temp"))), (event) -> { Bukkit.getServer().dispatchCommand(event.player, "island coop " + targetPlayer + " " + languageLoad.getString("Menu.Coop.Item.Word.Temp")); - guiManager.showGUI(event.player, returnGui); + guiManager.showGUI(event.player, new GuiCoop(plugin, island, null)); }); } } From 3fabd75aab52f37f39e961849932ad6f761f35b5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 18:18:59 +0200 Subject: [PATCH 303/366] Try to fix npe in gui Bank Selector --- .../java/com/songoda/skyblock/gui/bank/GuiBankSelector.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java index 34961d65..617c0017 100644 --- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java +++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java @@ -141,7 +141,11 @@ public class GuiBankSelector extends Gui { double amount; try { - amount = Double.parseDouble(gui.getInputText().trim()); + if(gui.getInputText() != null) { + amount = Double.parseDouble(gui.getInputText().trim()); + } else { + amount = 0; + } } catch (NumberFormatException e1) { messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message")); soundManager.playSound(event.player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f); From 00423eb5e46353dc817632ebb82b329d53bb471e Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 18:32:18 +0200 Subject: [PATCH 304/366] Try to fix a npe in IslandManager --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index b68bfe60..f6bbe0f3 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1222,7 +1222,9 @@ public class IslandManager { for (Player all : Bukkit.getOnlinePlayers()) { PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(all); - if (targetPlayerData.getOwner() != null && targetPlayerData.getOwner().equals(island.getOwnerUUID())) { + if (targetPlayerData != null && + targetPlayerData.getOwner() != null && + targetPlayerData.getOwner().equals(island.getOwnerUUID())) { Scoreboard scoreboard = scoreboardManager.getScoreboard(all); if (islandMembers == 1) { From 975c7c756b8d294b60182648b1069cf0b6080c79 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 18:38:34 +0200 Subject: [PATCH 305/366] Added whitelist message and moved a closed message --- .../java/com/songoda/skyblock/island/IslandManager.java | 6 +++--- .../com/songoda/skyblock/playerdata/PlayerDataManager.java | 4 ++-- src/main/resources/language.yml | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index f6bbe0f3..ec249548 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1222,7 +1222,7 @@ public class IslandManager { for (Player all : Bukkit.getOnlinePlayers()) { PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(all); - if (targetPlayerData != null && + if (targetPlayerData != null && targetPlayerData.getOwner() != null && targetPlayerData.getOwner().equals(island.getOwnerUUID())) { Scoreboard scoreboard = scoreboardManager.getScoreboard(all); @@ -1295,7 +1295,7 @@ public class IslandManager { if (!island.isCoopPlayer(visitor)) { Player targetPlayer = Bukkit.getServer().getPlayer(visitor); LocationUtil.teleportPlayerToSpawn(targetPlayer); - messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", islandOwnerPlayerName)); + messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Closed.Message").replace("%player", islandOwnerPlayerName)); } } } @@ -1322,7 +1322,7 @@ public class IslandManager { if (!island.isCoopPlayer(visitor) && !island.isPlayerWhitelisted(visitor)) { Player targetPlayer = Bukkit.getServer().getPlayer(visitor); LocationUtil.teleportPlayerToSpawn(targetPlayer); - messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Whitelisted.Island.Message").replace("%player", islandOwnerPlayerName)); // TODO + messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Whitelisted.Message").replace("%player", islandOwnerPlayerName)); // TODO } } } diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index 507269b9..e8ce4783 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -217,7 +217,7 @@ public class PlayerDataManager { return; } else { if (messageManager != null) - messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName)); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Message").replace("%player", targetPlayerName)); } } @@ -278,7 +278,7 @@ public class PlayerDataManager { } else { islandManager.unloadIsland(island, Bukkit.getServer().getOfflinePlayer(visitIslandList)); if (messageManager != null) - messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName)); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Message").replace("%player", targetPlayerName)); } } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 67f62100..e85b5a83 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -987,8 +987,9 @@ Command: Invalid: Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island visit []' Closed: - Island: - Message: '&bSkyBlock &8| &aInfo&8: &eThe island you were at closed.' + Message: '&bSkyBlock &8| &aInfo&8: &eThe island you were at is now closed.' + Whitelisted: + Message: '&bSkyBlock &8| &aInfo&8: &eThe island you were at is now whitelisted.' Help: Page: Message: '&bSkyBlock &8| &cError&8: &eThere are not that many pages.' From 996d47e2036680f0da1fc159c3bd7fc4f53409c5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 19:03:00 +0200 Subject: [PATCH 306/366] Allow double values in levelling system --- .../command/commands/island/ValueCommand.java | 4 +- .../levelling/IslandLevelManager.java | 15 ++--- .../skyblock/levelling/LevellingMaterial.java | 8 +-- .../com/songoda/skyblock/menus/Levelling.java | 4 +- .../skyblock/menus/admin/Levelling.java | 64 ++++++++++--------- .../placeholder/PlaceholderManager.java | 2 +- 6 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java index d4d026c0..ecda0037 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java @@ -36,8 +36,8 @@ public class ValueCommand extends SubCommand { CompatibleMaterial materials = CompatibleMaterial.getMaterial(player.getItemInHand().getType().name()); if (materials != null && levellingManager.hasWorth(materials)) { - long worth = levellingManager.getWorth(materials); - double level = (double) worth / (double) fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Levelling.Division"); + double worth = levellingManager.getWorth(materials); + double level = worth / (double) fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Levelling.Division"); messageManager.sendMessage(player, configLoad.getString("Command.Island.Value.Value.Message").replace("%material", WordUtils.capitalizeFully(materials.name().toLowerCase().replace("_", " "))) diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java index 695621b8..2899e42d 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java @@ -14,7 +14,6 @@ import com.songoda.skyblock.levelling.calculator.impl.UltimateStackerCalculator; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.stackable.StackableManager; import com.songoda.skyblock.utils.version.CompatibleSpawners; -import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; @@ -32,7 +31,7 @@ import java.util.Map.Entry; public final class IslandLevelManager { private final Map inScan; - private final Map worth; + private final Map worth; private final Map cachedPairs; private final SkyBlock plugin; @@ -103,11 +102,11 @@ public final class IslandLevelManager { if (material == null) continue; - worth.put(material, current.getLong("Points")); + worth.put(material, current.getDouble("Points")); } } - public void addWorth(CompatibleMaterial material, long points) { + public void addWorth(CompatibleMaterial material, double points) { worth.put(material, points); } @@ -119,19 +118,19 @@ public final class IslandLevelManager { final List materials = new ArrayList<>(worth.size()); - for (Entry entry : worth.entrySet()) { + for (Entry entry : worth.entrySet()) { materials.add(new LevellingMaterial(entry.getKey(), entry.getValue())); } return materials; } - public Map getWorths() { + public Map getWorths() { return worth; } - public long getWorth(CompatibleMaterial material) { - return worth.getOrDefault(material, 0L); + public double getWorth(CompatibleMaterial material) { + return worth.getOrDefault(material, 0d); } public boolean hasWorth(CompatibleMaterial material) { diff --git a/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java b/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java index bf0936d3..693f1c03 100644 --- a/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java +++ b/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java @@ -8,9 +8,9 @@ import org.bukkit.inventory.ItemStack; public final class LevellingMaterial { private CompatibleMaterial materials; - private long points; + private double points; - public LevellingMaterial(CompatibleMaterial materials, long points) { + public LevellingMaterial(CompatibleMaterial materials, double points) { this.materials = materials; this.points = points; } @@ -19,11 +19,11 @@ public final class LevellingMaterial { return materials; } - public long getPoints() { + public double getPoints() { return points; } - public void setPoints(long points) { + public void setPoints(double points) { this.points = points; } diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index 2d268243..b0c8722d 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -252,7 +252,7 @@ public class Levelling { if (mainConfig.getFileConfiguration().getString("Materials." + material + ".Points") == null) break; - int pointsMultiplier = mainConfig.getFileConfiguration().getInt("Materials." + material + ".Points"); + double pointsMultiplier = mainConfig.getFileConfiguration().getDouble("Materials." + material + ".Points"); if (!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") && pointsMultiplier == 0) return; @@ -265,7 +265,7 @@ public class Levelling { if (materialLimit == -1) materialAmountCounted = materialAmount; - long pointsEarned = materialAmountCounted * pointsMultiplier; + double pointsEarned = materialAmountCounted * pointsMultiplier; String name = plugin.getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(materials); diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java index a43445b6..22397636 100644 --- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java @@ -216,35 +216,37 @@ public class Levelling implements Listener { messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Permission.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - } else if (event1.getName().matches("[0-9]+")) { - int pointDivision = Integer.valueOf(event1.getName()); - - messageManager.sendMessage(player, - configLoad.getString("Island.Admin.Levelling.Division.Message") - .replace("%division", NumberUtil.formatNumberByDecimal(pointDivision))); - soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { - Config config12 = fileManager - .getConfig(new File(plugin.getDataFolder(), "config.yml")); - FileConfiguration configLoad12 = config12.getFileConfiguration(); - - configLoad12.set("Island.Levelling.Division", pointDivision); - - try { - configLoad12.save(config12.getFile()); - } catch (IOException e) { - e.printStackTrace(); - } - }); - - player.closeInventory(); - - Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); } else { - messageManager.sendMessage(player, - configLoad.getString("Island.Admin.Levelling.Numerical.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + try { + double pointDivision = Double.parseDouble(event1.getName()); + + messageManager.sendMessage(player, + configLoad.getString("Island.Admin.Levelling.Division.Message") + .replace("%division", NumberUtil.formatNumberByDecimal(pointDivision))); + soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F); + + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { + Config config12 = fileManager + .getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad12 = config12.getFileConfiguration(); + + configLoad12.set("Island.Levelling.Division", pointDivision); + + try { + configLoad12.save(config12.getFile()); + } catch (IOException e) { + e.printStackTrace(); + } + }); + + player.closeInventory(); + + Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); + } catch (NumberFormatException ignored) { + messageManager.sendMessage(player, + configLoad.getString("Island.Admin.Levelling.Numerical.Message")); + soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); + } } event1.setWillClose(true); @@ -315,8 +317,8 @@ public class Levelling implements Listener { configLoad.getString("Island.Admin.Levelling.Permission.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } else if (levellingManager.hasWorth(materials)) { - if (event1.getName().matches("[0-9]+")) { - int materialPoints = Integer.valueOf(event1.getName()); + try { + double materialPoints = Double.parseDouble(event1.getName()); materialList.setPoints(materialPoints); messageManager.sendMessage(player, configLoad @@ -349,7 +351,7 @@ public class Levelling implements Listener { e.printStackTrace(); } }); - } else { + } catch (NumberFormatException ignored) { messageManager.sendMessage(player, configLoad .getString("Island.Admin.Levelling.Numerical.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java index b0405a70..7091d8a5 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java @@ -387,7 +387,7 @@ public class PlaceholderManager { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid.Message")); } else { - long blockValue = levellingManager.getWorth(materials); + double blockValue = levellingManager.getWorth(materials); return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty.Message") .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockValue))); From e4331db836eefa6e4a0d3c8aa9e2e716640a499f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 19:46:34 +0200 Subject: [PATCH 307/366] Removed comment --- src/main/java/com/songoda/skyblock/listeners/Portal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index 26ccac6a..f946320e 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -117,7 +117,7 @@ public class Portal implements Listener { if (tick == null) return; - PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat + PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // Check permissions. boolean perms = !plugin.getPermissionManager().processPermission(playerEnterPortalEvent, player, island); From 37759f598c7eaf48530c1eda165f1647d75bdcec Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 19:46:46 +0200 Subject: [PATCH 308/366] Improved fishing permission --- .../permission/permissions/listening/FishingPermission.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java index efea4ec7..d76b5be8 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java @@ -25,8 +25,8 @@ public class FishingPermission extends ListeningPermission { @PermissionHandler(priority = PermissionPriority.LAST) public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) { org.bukkit.entity.Projectile projectile = event.getEntity(); - Player shooter = (Player) projectile.getShooter(); - if (projectile instanceof FishHook) { + if (projectile instanceof FishHook && projectile.getShooter() instanceof Player) { + Player shooter = (Player) projectile.getShooter(); cancelAndMessage(event, shooter, plugin, messageManager); event.setStopped(true); } From 57994742a2fab7cc39bfd5abda620a7c5d7c462b Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 20:06:31 +0200 Subject: [PATCH 309/366] Reworked Projectile permissions --- .../skyblock/listeners/Projectile.java | 18 ++++------ .../permission/ListeningPermission.java | 3 +- .../events/ProjectileLaunchByPlayerEvent.java | 36 ------------------- .../listening/FishingPermission.java | 5 ++- .../listening/ProjectilePermission.java | 8 +++-- 5 files changed, 15 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java diff --git a/src/main/java/com/songoda/skyblock/listeners/Projectile.java b/src/main/java/com/songoda/skyblock/listeners/Projectile.java index 8790fadd..5a49be0d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Projectile.java +++ b/src/main/java/com/songoda/skyblock/listeners/Projectile.java @@ -1,7 +1,6 @@ package com.songoda.skyblock.listeners; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -20,16 +19,13 @@ public class Projectile implements Listener { public void onProjectileLaunch(ProjectileLaunchEvent event) { org.bukkit.entity.Projectile projectile = event.getEntity(); ProjectileSource shooter = projectile.getShooter(); - if (!(shooter instanceof Player)) - return; - - Player player = (Player) shooter; - - if (!plugin.getWorldManager().isIslandWorld(player.getWorld())) - return; - - // Check permissions. - plugin.getPermissionManager().processPermission(new ProjectileLaunchByPlayerEvent(event.getEntity()), player, player.getLocation()); + if (shooter instanceof Player) { + Player player = (Player) shooter; + + if (plugin.getWorldManager().isIslandWorld(player.getWorld())) { + plugin.getPermissionManager().processPermission(event, player, player.getLocation()); + } + } } } diff --git a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java index 656672d8..f07087e9 100644 --- a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java @@ -5,7 +5,6 @@ import com.songoda.core.compatibility.CompatibleSound; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent; -import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.block.BlockBreakEvent; @@ -79,7 +78,7 @@ public abstract class ListeningPermission extends BasicPermission { public void onTeleport(PlayerTeleportEvent event) {} - public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) {} + public void onProjectileLaunch(ProjectileLaunchEvent event) {} public void onBlockIgnite(BlockIgniteEvent event) {} diff --git a/src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java b/src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java deleted file mode 100644 index b6912d63..00000000 --- a/src/main/java/com/songoda/skyblock/permission/event/events/ProjectileLaunchByPlayerEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.songoda.skyblock.permission.event.events; - -import com.songoda.skyblock.permission.event.Stoppable; -import org.bukkit.entity.Entity; -import org.bukkit.event.Cancellable; -import org.bukkit.event.entity.ProjectileLaunchEvent; - -public class ProjectileLaunchByPlayerEvent extends ProjectileLaunchEvent implements Cancellable, Stoppable { - - private boolean isCancelled = false; - private boolean isStopped = false; - - public ProjectileLaunchByPlayerEvent(Entity what) { - super(what); - } - - @Override - public boolean isCancelled() { - return isCancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - isCancelled = cancelled; - } - - @Override - public boolean isStopped() { - return isStopped; - } - - @Override - public void setStopped(boolean stopped) { - isStopped = stopped; - } -} diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java index d76b5be8..44eaf835 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/FishingPermission.java @@ -7,9 +7,9 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionPriority; import com.songoda.skyblock.permission.PermissionType; -import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent; import org.bukkit.entity.FishHook; import org.bukkit.entity.Player; +import org.bukkit.event.entity.ProjectileLaunchEvent; public class FishingPermission extends ListeningPermission { @@ -23,12 +23,11 @@ public class FishingPermission extends ListeningPermission { } @PermissionHandler(priority = PermissionPriority.LAST) - public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) { + public void onProjectileLaunch(ProjectileLaunchEvent event) { org.bukkit.entity.Projectile projectile = event.getEntity(); if (projectile instanceof FishHook && projectile.getShooter() instanceof Player) { Player shooter = (Player) projectile.getShooter(); cancelAndMessage(event, shooter, plugin, messageManager); - event.setStopped(true); } } } diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java index 84545b19..8e31c466 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProjectilePermission.java @@ -7,9 +7,9 @@ import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionPriority; import com.songoda.skyblock.permission.PermissionType; -import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerInteractEvent; public class ProjectilePermission extends ListeningPermission { @@ -34,7 +34,9 @@ public class ProjectilePermission extends ListeningPermission { } @PermissionHandler(priority = PermissionPriority.LAST) - public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) { - event.setCancelled(true); + public void onProjectileLaunch(ProjectileLaunchEvent event) { + if(event.getEntity().getShooter() instanceof Player) { + cancelAndMessage(event, (Player) event.getEntity().getShooter(), plugin, messageManager); + } } } From dd3f89221f129deca5f61c960b19ac4b8053b1d1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 22:41:50 +0200 Subject: [PATCH 310/366] Added toBlockLocation util --- .../com/songoda/skyblock/utils/world/LocationUtil.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 f94a89d6..d4fe07d4 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -381,4 +381,12 @@ public final class LocationUtil { centerLoc.setZ((double)loc.getBlockZ() + 0.5D); return centerLoc; } + + public static Location toBlockLocation(Location loc) { + Location blockLoc = loc.clone(); + blockLoc.setX(loc.getBlockX()); + blockLoc.setY(loc.getBlockY()); + blockLoc.setZ(loc.getBlockZ()); + return blockLoc; + } } From 68d3624d61d7bfeb1b1dc1c7c7d743d80b662b8a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 22:42:12 +0200 Subject: [PATCH 311/366] Fix generator delay when using Vault --- .../java/com/songoda/skyblock/listeners/Block.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index 2d97a90b..ab9afc86 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -40,9 +40,11 @@ import java.util.*; public class Block implements Listener { private final SkyBlock plugin; + private final Set generatorWaitingLocs; public Block(SkyBlock plugin) { this.plugin = plugin; + this.generatorWaitingLocs = new HashSet<>(); } @EventHandler(priority = EventPriority.LOW) @@ -427,6 +429,11 @@ public class Block implements Listener { } // Generators + if(this.generatorWaitingLocs.contains(LocationUtil.toBlockLocation(block.getLocation().clone()))) { + event.setCancelled(true); + return; + } + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_12)) { CompatibleMaterial material = CompatibleMaterial.getMaterial(block); if (material != CompatibleMaterial.WATER @@ -482,11 +489,13 @@ public class Block implements Listener { OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); event.setCancelled(true); org.bukkit.World finalWorld = event.getBlock().getWorld(); + this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone())); Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { Bukkit.getScheduler().runTask(plugin, () -> { + this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone())); if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ BlockState genState = generatorManager.generateBlock(generator, block); block.setType(genState.getType()); @@ -759,11 +768,13 @@ public class Block implements Listener { OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); event.setCancelled(true); org.bukkit.World finalWorld = event.getBlock().getWorld(); + this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone())); Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { Bukkit.getScheduler().runTask(plugin, () -> { + this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone())); if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ BlockState genState = generatorManager.generateBlock(generator, block); block.setType(genState.getType()); From c1978f26a89f8ec5753475aebde767e730ea07e5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 1 Aug 2020 22:46:03 +0200 Subject: [PATCH 312/366] 2.3.6-DEV3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aae8cdae..14623d79 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.6-DEV2 + 2.3.6-DEV3 jar UTF-8 From 0cdbe1032fbd0c257427aeef0d6011a8b3451ac0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 2 Aug 2020 13:08:39 +0200 Subject: [PATCH 313/366] Show warning when running on pre 1.8 --- src/main/java/com/songoda/skyblock/SkyBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 7ea7e09f..c7633179 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -114,7 +114,7 @@ public class SkyBlock extends SongodaPlugin { @Override public void onPluginEnable() { - if(ServerVersion.isServerVersionAbove(ServerVersion.V1_16)) { + if(ServerVersion.isServerVersionAbove(ServerVersion.V1_16) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) { this.getLogger().warning("This Minecraft version is not officially supported."); } From 379e40b6d563221e4306fdbd4cd72ed74ee23ff2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 01:45:19 +0200 Subject: [PATCH 314/366] Initial work to Scoreboard manager and Placeholder manager --- .../java/com/songoda/skyblock/SkyBlock.java | 6 +- .../command/commands/admin/ReloadCommand.java | 2 +- .../commands/island/AcceptCommand.java | 44 +- .../command/commands/island/KickCommand.java | 19 +- .../command/commands/island/LeaveCommand.java | 30 +- .../commands/island/ScoreboardCommand.java | 6 +- .../songoda/skyblock/config/FileManager.java | 51 +- .../skyblock/island/IslandManager.java | 96 ++-- .../com/songoda/skyblock/listeners/Chat.java | 13 - .../com/songoda/skyblock/listeners/Join.java | 136 +++--- .../com/songoda/skyblock/listeners/Quit.java | 222 ++++----- .../skyblock/placeholder/EZPlaceholder.java | 143 ------ .../skyblock/placeholder/MVdWPlaceholder.java | 147 ------ .../placeholder/PlaceholderManager.java | 455 +----------------- .../placeholder/PlaceholderProcessor.java | 417 ++++++++++++++++ .../{wip => }/hook/PlaceholderAPI.java | 9 +- .../skyblock/placeholder/wip/Placeholder.java | 20 - .../placeholder/wip/PlaceholderManager.java | 16 - .../placeholder/wip/PlaceholderProcessor.java | 13 - .../placeholder/wip/hook/MVdWPlaceholder.java | 4 - .../playerdata/PlayerDataManager.java | 22 +- .../songoda/skyblock/scoreboard/Board.java | 118 +++++ .../songoda/skyblock/scoreboard/Driver.java | 92 ++++ .../songoda/skyblock/scoreboard/Holder.java | 48 ++ .../com/songoda/skyblock/scoreboard/Row.java | 54 +++ .../skyblock/scoreboard/Scoreboard.java | 224 --------- .../skyblock/scoreboard/ScoreboardLine.java | 20 + .../scoreboard/ScoreboardManager.java | 346 ++++--------- .../skyblock/scoreboard/ScoreboardType.java | 21 + .../skyblock/scoreboard/wip/Board.java | 4 - .../skyblock/scoreboard/wip/Driver.java | 16 - .../skyblock/scoreboard/wip/Manager.java | 24 - .../songoda/skyblock/scoreboard/wip/Row.java | 4 - src/main/resources/language.yml | 242 ---------- src/main/resources/placeholders.yml | 165 +++++++ src/main/resources/scoreboard.yml | 339 +++++++++++++ 36 files changed, 1696 insertions(+), 1892 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java delete mode 100644 src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java create mode 100644 src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java rename src/main/java/com/songoda/skyblock/placeholder/{wip => }/hook/PlaceholderAPI.java (73%) delete mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java delete mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java delete mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java delete mode 100644 src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/Board.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/Driver.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/Holder.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/Row.java delete mode 100644 src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java create mode 100644 src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java delete mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java delete mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java delete mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java delete mode 100644 src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java create mode 100644 src/main/resources/placeholders.yml create mode 100644 src/main/resources/scoreboard.yml diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index c7633179..9a2fc3ae 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -253,6 +253,10 @@ public class SkyBlock extends SongodaPlugin { this.userCacheManager.onDisable(); } + if (this.scoreboardManager != null) { + this.scoreboardManager.disable(); + } + if (this.islandManager != null) { this.islandManager.onDisable(); } @@ -291,7 +295,6 @@ public class SkyBlock extends SongodaPlugin { private CoreProtectAPI loadCoreProtect() { Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect"); - if (plugin != null) { // Check before loading classes if (plugin instanceof CoreProtect) { // Check that CoreProtect is loaded CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI(); @@ -303,7 +306,6 @@ public class SkyBlock extends SongodaPlugin { } } return null; - } @Override diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java index b04042a2..782ad1c8 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java @@ -68,7 +68,7 @@ public class ReloadCommand extends SubCommand { plugin.setScoreboardManager(new ScoreboardManager(plugin)); } } else { - plugin.getScoreboardManager().reloadScoreboards(false); + plugin.getScoreboardManager().reload(); } if (plugin.getGeneratorManager() == null) { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java index f8f26401..baf485de 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java @@ -13,7 +13,6 @@ import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.scoreboard.Scoreboard; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import org.bukkit.Bukkit; @@ -126,39 +125,25 @@ public class AcceptCommand extends SubCommand { plugin.getVisitManager().getIsland(invite.getOwnerUUID()) .removeVoter(player.getUniqueId()); - for (Player all : Bukkit.getOnlinePlayers()) { - if (!all.getUniqueId().equals(player.getUniqueId())) { - if (playerDataManager.hasPlayerData(all)) { - playerData = playerDataManager.getPlayerData(all); + for (Player loopPlayer : Bukkit.getOnlinePlayers()) { + if (!loopPlayer.getUniqueId().equals(player.getUniqueId())) { + if (playerDataManager.hasPlayerData(loopPlayer)) { + playerData = playerDataManager.getPlayerData(loopPlayer); if (playerData.getOwner() != null && playerData.getOwner().equals(island.getOwnerUUID())) { - all.sendMessage(ChatColor.translateAlternateColorCodes('&', + loopPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad .getString( "Command.Island.Accept.Accepted.Broadcast.Message") .replace("%player", player.getName()))); - soundManager.playSound(all, CompatibleSound.ENTITY_FIREWORK_ROCKET_BLAST.getSound(), 1.0F, + soundManager.playSound(loopPlayer, CompatibleSound.ENTITY_FIREWORK_ROCKET_BLAST.getSound(), 1.0F, 1.0F); if (scoreboardManager != null) { if (island.getRole(IslandRole.Member).size() == 1 && island.getRole(IslandRole.Operator).size() == 0) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - scoreboard.setDisplayName( - ChatColor.translateAlternateColorCodes('&', configLoad - .getString("Scoreboard.Island.Team.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(configLoad.getStringList( - "Scoreboard.Island.Team.Empty.Displaylines")); - } else { - scoreboard.setDisplayList(configLoad.getStringList( - "Scoreboard.Island.Team.Occupied.Displaylines")); - } - - - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } } } @@ -167,20 +152,7 @@ public class AcceptCommand extends SubCommand { } if (scoreboardManager != null) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(player); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Scoreboard.Island.Team.Displayname", ""))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList( - configLoad.getStringList("Scoreboard.Island.Team.Empty.Displaylines")); - } else { - scoreboard.setDisplayList( - configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); - } - - - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(player); } } } else { 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 97feb6af..8a3735cf 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 @@ -14,7 +14,6 @@ import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.permission.PermissionManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.scoreboard.Scoreboard; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; @@ -148,11 +147,7 @@ public class KickCommand extends SubCommand { } if (scoreboardManager != null) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer); - scoreboard.setDisplayName( - ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname"))); - scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines")); - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(targetPlayer); } playerData = playerDataManager.getPlayerData(targetPlayer); @@ -190,17 +185,7 @@ public class KickCommand extends SubCommand { if (scoreboardManager != null) { if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(player); - scoreboard.setDisplayName( - ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); - } else { - scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); - } - - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(player); } } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java index e1d5453b..98d6de8b 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java @@ -11,7 +11,6 @@ import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.scoreboard.Scoreboard; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.world.LocationUtil; @@ -93,28 +92,22 @@ public class LeaveCommand extends SubCommand { // TODO Check if player has been teleported islandManager.unloadIsland(island, null); - for (Player all : Bukkit.getOnlinePlayers()) { - if (!all.getUniqueId().equals(player.getUniqueId())) { - if (island.hasRole(IslandRole.Member, all.getUniqueId()) - || island.hasRole(IslandRole.Operator, all.getUniqueId()) - || island.hasRole(IslandRole.Owner, all.getUniqueId())) { - all.sendMessage(ChatColor.translateAlternateColorCodes('&', + for (Player loopPlayer : Bukkit.getOnlinePlayers()) { + if (!loopPlayer.getUniqueId().equals(player.getUniqueId())) { + if (island.hasRole(IslandRole.Member, loopPlayer.getUniqueId()) + || island.hasRole(IslandRole.Operator, loopPlayer.getUniqueId()) + || island.hasRole(IslandRole.Owner, loopPlayer.getUniqueId())) { + loopPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration() .getString("Command.Island.Leave.Left.Broadcast.Message") .replace("%player", player.getName()))); - soundManager.playSound(all, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 5.0F, 5.0F); + soundManager.playSound(loopPlayer, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 5.0F, 5.0F); if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { if (scoreboardManager != null) { if (islandManager.getVisitorsAtIsland(island).size() != 0) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', - languageConfig.getFileConfiguration() - .getString("Scoreboard.Island.Solo.Displayname"))); - scoreboard.setDisplayList(languageConfig.getFileConfiguration() - .getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } } @@ -129,12 +122,7 @@ public class LeaveCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 5.0F, 5.0F); if (scoreboardManager != null) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(player); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', - languageConfig.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname"))); - scoreboard.setDisplayList( - languageConfig.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines")); - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(player); } } } diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java index 5cceb97b..3107cb34 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java @@ -37,13 +37,13 @@ public class ScoreboardCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); }else if (playerData.isScoreboard()) { playerData.setScoreboard(false); - scoreboardManager.removePlayer(player); - + scoreboardManager.addDisabledPlayer(player); + messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Disabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F); } else { playerData.setScoreboard(true); - scoreboardManager.addPlayer(player); + scoreboardManager.removeDisabledPlayer(player); messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Enabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java index fe76ed74..3abd9501 100644 --- a/src/main/java/com/songoda/skyblock/config/FileManager.java +++ b/src/main/java/com/songoda/skyblock/config/FileManager.java @@ -11,6 +11,12 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.*; import java.nio.charset.StandardCharsets; +import java.nio.file.CopyOption; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -20,11 +26,13 @@ import java.util.logging.Level; public class FileManager { private final SkyBlock plugin; - private Map loadedConfigs = new HashMap<>(); + private final Map loadedConfigs = new HashMap<>(); public FileManager(SkyBlock plugin) { this.plugin = plugin; + backupIfNeeded(); + loadConfigs(); } @@ -56,6 +64,8 @@ public class FileManager { configFiles.put("upgrades.yml", new File(plugin.getDataFolder(), "upgrades.yml")); configFiles.put("biomes.yml", new File(plugin.getDataFolder(), "biomes.yml")); // configFiles.put("menus.yml", new File(skyblock.getDataFolder(), "menus.yml")); + configFiles.put("scoreboard.yml", new File(plugin.getDataFolder(), "scoreboard.yml")); + configFiles.put("placeholders.yml", new File(plugin.getDataFolder(), "placeholders.yml")); configFiles.put("generators.yml", new File(plugin.getDataFolder(), "generators.yml")); configFiles.put("stackables.yml", new File(plugin.getDataFolder(), "stackables.yml")); configFiles.put("structures.yml", new File(plugin.getDataFolder(), "structures.yml")); @@ -89,10 +99,15 @@ public class FileManager { } if (configFile.exists()) { - if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("worlds.yml") || fileName.equals("biomes.yml")) { + if (fileName.equals("config.yml") || + fileName.equals("language.yml") || + fileName.equals("worlds.yml") || + fileName.equals("biomes.yml") || + fileName.equals("scoreboard.yml") || + fileName.equals("placeholders.yml")) { FileChecker fileChecker; - if (fileName.equals("config.yml") || fileName.equals("biomes.yml")) { + if (fileName.equals("config.yml") || fileName.equals("biomes.yml") || fileName.equals("scoreboard.yml")) { fileChecker = new FileChecker(plugin, this, fileName, true); } else { fileChecker = new FileChecker(plugin, this, fileName, false); @@ -161,6 +176,35 @@ public class FileManager { ex.printStackTrace(); } } + + public void backupIfNeeded() { + File languageFile = new File(plugin.getDataFolder().toString() + "language.yml"); + File scoreboardFile = new File(plugin.getDataFolder().toString() + "scoreboard.yml"); + File placeholderFile = new File(plugin.getDataFolder().toString() + "placeholders.yml"); + if(languageFile.exists() && (!scoreboardFile.exists() || !placeholderFile.exists())) { + File backupDir = new File(plugin.getDataFolder().toString() + "/backup"); + if(!backupDir.exists()) { + backupDir.mkdir(); + } + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy-HH:mm:ss"); + LocalDateTime now = LocalDateTime.now(); + + + Path oldLanguagePath = languageFile.toPath(); + Path newLanguagePath = new File(plugin.getDataFolder().toString() + "/backup/language" + dtf.format(now) + ".yml").toPath(); + + CopyOption[] options = new CopyOption[]{ + StandardCopyOption.REPLACE_EXISTING, + StandardCopyOption.COPY_ATTRIBUTES + }; + + try { + Files.copy(oldLanguagePath, newLanguagePath, options); + } catch (IOException e) { + e.printStackTrace(); + } + } + } public Location getLocation(Config config, String path, boolean direction) { @@ -199,7 +243,6 @@ public class FileManager { } public Config getConfig(File configPath) { - Config cached = loadedConfigs.get(configPath.getPath()); if (cached != null) return cached; diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index ec249548..65926109 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -24,7 +24,6 @@ import com.songoda.skyblock.island.removal.ChunkDeleteSplitter; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.scoreboard.Scoreboard; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.structure.Structure; @@ -264,12 +263,7 @@ public class IslandManager { data.setOwner(player.getUniqueId()); if (scoreboardManager != null) { - Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); - - Scoreboard scoreboard = scoreboardManager.getScoreboard(player); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); - scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(player); } Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { @@ -578,57 +572,52 @@ public class IslandManager { boolean cooldownCreationEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable"); boolean cooldownDeletionEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable"); - config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); - configLoad = config.getFileConfiguration(); - - for (Player all : Bukkit.getOnlinePlayers()) { - if ((island.hasRole(IslandRole.Member, all.getUniqueId()) || island.hasRole(IslandRole.Operator, all.getUniqueId()) || island.hasRole(IslandRole.Owner, all.getUniqueId())) && playerDataManager.hasPlayerData(all)) { - PlayerData playerData = playerDataManager.getPlayerData(all); + for (Player player : Bukkit.getOnlinePlayers()) { + if ((island.hasRole(IslandRole.Member, player.getUniqueId()) || + island.hasRole(IslandRole.Operator, player.getUniqueId()) || + island.hasRole(IslandRole.Owner, player.getUniqueId())) && + playerDataManager.hasPlayerData(player)) { + PlayerData playerData = playerDataManager.getPlayerData(player); playerData.setOwner(null); playerData.setMemberSince(null); playerData.setChat(false); playerData.save(); if (scoreboardManager != null) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Tutorial.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Tutorial.Displaylines")); - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(player); } - if (isPlayerAtIsland(island, all)) { - LocationUtil.teleportPlayerToSpawn(all); + if (isPlayerAtIsland(island, player)) { + LocationUtil.teleportPlayerToSpawn(player); } // TODO - Find a way to delete also offline players - if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Deletion.ClearInventory", false)){ - all.getInventory().clear(); + if (configLoad.getBoolean("Island.Deletion.ClearInventory", false)){ + player.getInventory().clear(); } - if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Deletion.ClearEnderChest", false)){ - all.getEnderChest().clear(); + if (configLoad.getBoolean("Island.Deletion.ClearEnderChest", false)){ + player.getEnderChest().clear(); } if (cooldownCreationEnabled) { - if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) { - plugin.getCooldownManager().createPlayer(CooldownType.Creation, all); + if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) { + plugin.getCooldownManager().createPlayer(CooldownType.Creation, player); } } if (cooldownDeletionEnabled) { - if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) { - plugin.getCooldownManager().createPlayer(CooldownType.Deletion, all); + if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) { + plugin.getCooldownManager().createPlayer(CooldownType.Deletion, player); } } } InviteManager inviteManager = plugin.getInviteManager(); - if (inviteManager.hasInvite(all.getUniqueId())) { - Invite invite = inviteManager.getInvite(all.getUniqueId()); + if (inviteManager.hasInvite(player.getUniqueId())) { + Invite invite = inviteManager.getInvite(player.getUniqueId()); if (invite.getOwnerUUID().equals(island.getOwnerUUID())) { - inviteManager.removeInvite(all.getUniqueId()); + inviteManager.removeInvite(player.getUniqueId()); } } } @@ -952,31 +941,20 @@ public class IslandManager { island.save(); - int islandMembers = island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1, islandVisitors = getVisitorsAtIsland(island).size(); + int islandVisitors = getVisitorsAtIsland(island).size(); boolean unloadIsland = true; - for (Player all : Bukkit.getOnlinePlayers()) { - if (all == null || (player != null && player.getUniqueId().equals(all.getUniqueId()))) { + for (Player loopPlayer : Bukkit.getOnlinePlayers()) { + if (loopPlayer == null || (player != null && player.getUniqueId().equals(loopPlayer.getUniqueId()))) { continue; } - if (island.hasRole(IslandRole.Member, all.getUniqueId()) || island.hasRole(IslandRole.Operator, all.getUniqueId()) || island.hasRole(IslandRole.Owner, all.getUniqueId()) - || island.getCoopType(all.getUniqueId()) == IslandCoop.NORMAL) { + if (island.hasRole(IslandRole.Member, loopPlayer.getUniqueId()) || + island.hasRole(IslandRole.Operator, loopPlayer.getUniqueId()) || + island.hasRole(IslandRole.Owner, loopPlayer.getUniqueId()) || + island.getCoopType(loopPlayer.getUniqueId()) == IslandCoop.NORMAL) { if (scoreboardManager != null) { - try { - if (islandMembers == 1 && islandVisitors == 0) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Solo.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); - scoreboard.run(); - } else if (islandVisitors == 0) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Empty.Displaylines")); - - scoreboard.run(); - } - } catch (Exception ignored) {} + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } unloadIsland = false; @@ -1219,23 +1197,13 @@ public class IslandManager { int islandVisitors = getVisitorsAtIsland(island).size(), islandMembers = island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1; if (islandVisitors == 0) { - for (Player all : Bukkit.getOnlinePlayers()) { - PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(all); + for (Player loopPlayer : Bukkit.getOnlinePlayers()) { + PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(loopPlayer); if (targetPlayerData != null && targetPlayerData.getOwner() != null && targetPlayerData.getOwner().equals(island.getOwnerUUID())) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - - if (islandMembers == 1) { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Solo.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); - } else { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); - } - - scoreboard.run(); + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java index 0e2bbd36..9cb2e19b 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Chat.java +++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java @@ -47,19 +47,6 @@ public class Chat implements Listener { island = plugin.getIslandManager().getIsland(player); } - String messageFormat = event.getFormat(); - - for (String placeholderList : placeholderManager.getPlaceholders()) { - String placeholder = "{" + placeholderList + "}"; - - if (messageFormat.contains(placeholder)) { - messageFormat = messageFormat.replace(placeholder, - placeholderManager.getPlaceholder(player, placeholderList)); - } - } - - event.setFormat(messageFormat); - if (playerData.isChat() && island != null) { event.setCancelled(true); diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index 66ffa190..f716dbd9 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -37,87 +37,85 @@ public class Join implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - Player player = event.getPlayer(); + Player player = event.getPlayer(); - ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); - PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); - UserCacheManager userCacheManager = plugin.getUserCacheManager(); - CooldownManager cooldownManager = plugin.getCooldownManager(); - IslandManager islandManager = plugin.getIslandManager(); - FileManager fileManager = plugin.getFileManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + UserCacheManager userCacheManager = plugin.getUserCacheManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + IslandManager islandManager = plugin.getIslandManager(); + FileManager fileManager = plugin.getFileManager(); - userCacheManager.addUser(player.getUniqueId(), player.getName()); - userCacheManager.saveAsync(); + userCacheManager.addUser(player.getUniqueId(), player.getName()); + userCacheManager.saveAsync(); + + try { + islandManager.loadIsland(player); + Island island = islandManager.getIsland(player); + boolean teleportedToIsland = false; + + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (configLoad.getBoolean("Island.Join.Spawn")) { + LocationUtil.teleportPlayerToSpawn(player); + } else if (configLoad.getBoolean("Island.Join.Island") && island != null) { + Bukkit.getScheduler().runTask(plugin, () -> { + PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); + player.setFallDistance(0.0F); + }); + teleportedToIsland = true; + } + + if (!teleportedToIsland) { + islandManager.loadPlayer(player); + } + } catch (Exception e) { + e.printStackTrace(); + } + + playerDataManager.loadPlayerData(player); + + if (playerDataManager.hasPlayerData(player)) { + String[] playerTexture; try { - islandManager.loadIsland(player); - Island island = islandManager.getIsland(player); - boolean teleportedToIsland = false; - - Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Join.Spawn")) { - LocationUtil.teleportPlayerToSpawn(player); - } else if (configLoad.getBoolean("Island.Join.Island") && island != null) { - Bukkit.getScheduler().runTask(plugin, () -> { - PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); - player.setFallDistance(0.0F); - }); - teleportedToIsland = true; - } - - if (!teleportedToIsland) { - islandManager.loadPlayer(player); - } + Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player); + Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile"); + GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer); + Property property = gameProfile.getProperties().get("textures").iterator().next(); + playerTexture = new String[]{property.getSignature(), property.getValue()}; } catch (Exception e) { - e.printStackTrace(); + playerTexture = new String[]{ + "K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=", + "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19"}; } + PlayerData playerData = playerDataManager.getPlayerData(player); + playerData.setTexture(playerTexture[0], playerTexture[1]); + Bukkit.getScheduler().runTaskAsynchronously(plugin, playerData::save); + } else { + playerDataManager.createPlayerData(player); playerDataManager.loadPlayerData(player); + } - if (playerDataManager.hasPlayerData(player)) { - String[] playerTexture; + playerDataManager.storeIsland(player); - try { - Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player); - Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile"); - GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer); - Property property = gameProfile.getProperties().get("textures").iterator().next(); - playerTexture = new String[]{property.getSignature(), property.getValue()}; - } catch (Exception e) { - playerTexture = new String[]{ - "K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=", - "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19"}; - } + 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)); - PlayerData playerData = playerDataManager.getPlayerData(player); - playerData.setTexture(playerTexture[0], playerTexture[1]); - Bukkit.getScheduler().runTaskAsynchronously(plugin, playerData::save); - } else { - playerDataManager.createPlayerData(player); - playerDataManager.loadPlayerData(player); - } + if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) { + scoreboardManager.updatePlayerScoreboardType(player); + } - playerDataManager.storeIsland(player); + Island island = islandManager.getIslandPlayerAt(player); + if (island != null) { + islandManager.updateBorder(island); + islandManager.updateFlight(player); + } - 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 && playerDataManager.getPlayerData(player).isScoreboard()) { - scoreboardManager.addPlayer(player); - } - - Island island = islandManager.getIslandPlayerAt(player); - if (island != null) { - islandManager.updateBorder(island); - islandManager.updateFlight(player); - } - - // Load Challenge - SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId()); - }); + // Load Challenge + SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId()); } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Quit.java b/src/main/java/com/songoda/skyblock/listeners/Quit.java index bde39add..afc40f31 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Quit.java +++ b/src/main/java/com/songoda/skyblock/listeners/Quit.java @@ -14,6 +14,7 @@ import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.scoreboard.ScoreboardManager; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -37,132 +38,131 @@ public class Quit implements Listener { @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - Player player = event.getPlayer(); + Player player = event.getPlayer(); - PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); - CooldownManager cooldownManager = plugin.getCooldownManager(); - MessageManager messageManager = plugin.getMessageManager(); - InviteManager inviteManager = plugin.getInviteManager(); - IslandManager islandManager = plugin.getIslandManager(); - PlayerManager challengePlayerManager = plugin.getFabledChallenge().getPlayerManager(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + CooldownManager cooldownManager = plugin.getCooldownManager(); + MessageManager messageManager = plugin.getMessageManager(); + InviteManager inviteManager = plugin.getInviteManager(); + IslandManager islandManager = plugin.getIslandManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + PlayerManager challengePlayerManager = plugin.getFabledChallenge().getPlayerManager(); - PlayerData playerData = playerDataManager.getPlayerData(player); + PlayerData playerData = playerDataManager.getPlayerData(player); - try { - playerData.setLastOnline(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date())); - } catch (Exception ignored) { - } + try { + playerData.setLastOnline(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date())); + } catch (Exception ignored) {} - Island island = islandManager.getIsland(player); + Island island = islandManager.getIsland(player); - if (island != null) { - Set islandMembersOnline = islandManager.getMembersOnline(island); + if (island != null) { + Set islandMembersOnline = islandManager.getMembersOnline(island); - if (islandMembersOnline.size() == 1) { - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); - cooldownManager.setCooldownPlayer(CooldownType.Levelling, offlinePlayer); - cooldownManager.removeCooldownPlayer(CooldownType.Levelling, offlinePlayer); + if (islandMembersOnline.size() == 1) { + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); + cooldownManager.setCooldownPlayer(CooldownType.Levelling, offlinePlayer); + cooldownManager.removeCooldownPlayer(CooldownType.Levelling, offlinePlayer); - cooldownManager.setCooldownPlayer(CooldownType.Ownership, offlinePlayer); - cooldownManager.removeCooldownPlayer(CooldownType.Ownership, offlinePlayer); - } else if (islandMembersOnline.size() == 2) { - for (UUID islandMembersOnlineList : islandMembersOnline) { - if (!islandMembersOnlineList.equals(player.getUniqueId())) { - Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); - PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer); + cooldownManager.setCooldownPlayer(CooldownType.Ownership, offlinePlayer); + cooldownManager.removeCooldownPlayer(CooldownType.Ownership, offlinePlayer); + } else if (islandMembersOnline.size() == 2) { + for (UUID islandMembersOnlineList : islandMembersOnline) { + if (!islandMembersOnlineList.equals(player.getUniqueId())) { + Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); + PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer); - if (targetPlayerData.isChat()) { - targetPlayerData.setChat(false); - messageManager.sendMessage(targetPlayer, - plugin.getFileManager() - .getConfig(new File(plugin.getDataFolder(), "language.yml")) - .getFileConfiguration().getString("Island.Chat.Untoggled.Message")); - } + if (targetPlayerData.isChat()) { + targetPlayerData.setChat(false); + messageManager.sendMessage(targetPlayer, + plugin.getFileManager() + .getConfig(new File(plugin.getDataFolder(), "language.yml")) + .getFileConfiguration().getString("Island.Chat.Untoggled.Message")); } } } + } + final Island is = island; + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> islandManager.unloadIsland(is, player)); + } + + cooldownManager.setCooldownPlayer(CooldownType.Biome, player); + cooldownManager.removeCooldownPlayer(CooldownType.Biome, player); + + 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 && plugin.getFileManager().getConfig(new File(plugin.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 (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() + .getBoolean("Island.Coop.Unload") || islandList.getCoopType(player.getUniqueId()) == IslandCoop.TEMP) { + islandList.removeCoopPlayer(player.getUniqueId()); + } + } + + if (playerData != null && playerData.getIsland() != null && islandManager.containsIsland(playerData.getIsland())) { + island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland())); + + if (!island.hasRole(IslandRole.Member, player.getUniqueId()) + && !island.hasRole(IslandRole.Operator, player.getUniqueId()) + && !island.hasRole(IslandRole.Owner, player.getUniqueId())) { final Island is = island; - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> islandManager.unloadIsland(is, player)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> islandManager.unloadIsland(is, null)); + } + } + + if (inviteManager.hasInvite(player.getUniqueId())) { + Invite invite = inviteManager.getInvite(player.getUniqueId()); + Player targetPlayer = Bukkit.getServer().getPlayer(invite.getOwnerUUID()); + + if (targetPlayer != null) { + messageManager.sendMessage(targetPlayer, + plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) + .getFileConfiguration() + .getString("Command.Island.Invite.Invited.Sender.Disconnected.Message") + .replace("%player", player.getName())); + plugin.getSoundManager().playSound(targetPlayer, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); } - cooldownManager.setCooldownPlayer(CooldownType.Biome, player); - cooldownManager.removeCooldownPlayer(CooldownType.Biome, player); - - 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 && plugin.getFileManager().getConfig(new File(plugin.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 (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration() - .getBoolean("Island.Coop.Unload") || islandList.getCoopType(player.getUniqueId()) == IslandCoop.TEMP) { - islandList.removeCoopPlayer(player.getUniqueId()); - } - } - - if (playerData != null && playerData.getIsland() != null && islandManager.containsIsland(playerData.getIsland())) { - island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland())); - - if (!island.hasRole(IslandRole.Member, player.getUniqueId()) - && !island.hasRole(IslandRole.Operator, player.getUniqueId()) - && !island.hasRole(IslandRole.Owner, player.getUniqueId())) { - final Island is = island; - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> islandManager.unloadIsland(is, null)); - } - } - - if (inviteManager.hasInvite(player.getUniqueId())) { - Invite invite = inviteManager.getInvite(player.getUniqueId()); - Player targetPlayer = Bukkit.getServer().getPlayer(invite.getOwnerUUID()); - - if (targetPlayer != null) { - messageManager.sendMessage(targetPlayer, - plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) - .getFileConfiguration() - .getString("Command.Island.Invite.Invited.Sender.Disconnected.Message") - .replace("%player", player.getName())); - plugin.getSoundManager().playSound(targetPlayer, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); - } - - inviteManager.removeInvite(player.getUniqueId()); - } - }); + inviteManager.removeInvite(player.getUniqueId()); + } + scoreboardManager.unregisterPlayer(player); // Unload Challenge SkyBlock.getInstance().getFabledChallenge().getPlayerManager().unloadPlayer(event.getPlayer().getUniqueId()); } diff --git a/src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java b/src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java deleted file mode 100644 index 16655c31..00000000 --- a/src/main/java/com/songoda/skyblock/placeholder/EZPlaceholder.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.songoda.skyblock.placeholder; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.island.IslandLevel; -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.visit.Visit; -import me.clip.placeholderapi.expansion.PlaceholderExpansion; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - -import java.io.File; -import java.util.List; - -public class EZPlaceholder extends PlaceholderExpansion { - - private final SkyBlock plugin; - - public EZPlaceholder(SkyBlock plugin) { - this.plugin = plugin; - } - - public String getIdentifier() { - return "fabledskyblock"; - } - - public String getPlugin() { - return null; - } - - public String getAuthor() { - return plugin.getDescription().getAuthors().get(0); - } - - public String getVersion() { - return plugin.getDescription().getVersion(); - } - - public boolean persist() { - return true; - } - - public String onPlaceholderRequest(Player player, String identifier) { - PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); - - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - List leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level); - List leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank); - List leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes); - - - if (identifier.equalsIgnoreCase("islands")) { - return "" + plugin.getVisitManager().getIslands().size(); - } else { - for (int i = 0; i < 10; i++) { - if (identifier.equalsIgnoreCase("leaderboard_votes_" + (i + 1))) { - if (i < leaderboardVotesPlayers.size()) { - Leaderboard leaderboard = leaderboardVotesPlayers.get(i); - Visit visit = leaderboard.getVisit(); - - Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); - String islandOwnerName; - - if (targetPlayer == null) { - islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); - } else { - islandOwnerName = targetPlayer.getName(); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Non-empty.Message") - .replace("%position", "" + (i + 1)).replace("%player", islandOwnerName) - .replace("%votes", NumberUtil.formatNumberByDecimal(visit.getVoters().size()))); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty.Message")); - } else if (identifier.equalsIgnoreCase("leaderboard_bank_" + (i + 1))) { - if (i < leaderboardBankPlayers.size()) { - Leaderboard leaderboard = leaderboardBankPlayers.get(i); - Visit visit = leaderboard.getVisit(); - - Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); - String islandOwnerName; - - if (targetPlayer == null) { - islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); - } else { - islandOwnerName = targetPlayer.getName(); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty.Message") - .replace("%position", "" + (i + 1)).replace("%player", islandOwnerName) - .replace("%balance", NumberUtil.formatNumberByDecimal(visit.getBankBalance()))); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty.Message")); - } else if (identifier.equalsIgnoreCase("leaderboard_level_" + (i + 1))) { - if (i < leaderboardLevelPlayers.size()) { - Leaderboard leaderboard = leaderboardLevelPlayers.get(i); - Visit visit = leaderboard.getVisit(); - IslandLevel level = visit.getLevel(); - - Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); - String islandOwnerName; - - if (targetPlayer == null) { - islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); - } else { - islandOwnerName = targetPlayer.getName(); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Non-empty.Message") - .replace("%position", "" + (i + 1)).replace("%player", islandOwnerName) - .replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel())) - .replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Empty.Message")); - } - } - } - - if (player == null) { - return ""; - } - - return placeholderManager.getPlaceholder(player, "fabledskyblock_" + identifier); - } - -} diff --git a/src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java b/src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java deleted file mode 100644 index 133e03e3..00000000 --- a/src/main/java/com/songoda/skyblock/placeholder/MVdWPlaceholder.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.songoda.skyblock.placeholder; - -import be.maximvdw.placeholderapi.PlaceholderAPI; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.island.IslandLevel; -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.visit.Visit; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - -import java.io.File; -import java.util.List; -import java.util.logging.Level; - -public class MVdWPlaceholder { - - private final SkyBlock plugin; - - public MVdWPlaceholder(SkyBlock plugin) { - this.plugin = plugin; - } - - public void register() { - PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); - - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - List leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level); - List leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank); - List leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes); - - PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_islands", event -> "" + plugin.getVisitManager().getIslands().size()); - - for (int i = 0; i < 10; i++) { - PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_leaderboard_votes_" + (i + 1), - event -> { - int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_votes_", "")); - - if (index < leaderboardVotesPlayers.size()) { - Leaderboard leaderboard = leaderboardVotesPlayers.get(index); - Visit visit = leaderboard.getVisit(); - - Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); - String islandOwnerName; - - if (targetPlayer == null) { - islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); - } else { - islandOwnerName = targetPlayer.getName(); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Non-empty.Message") - .replace("%position", "" + (index + 1)) - .replace("%player", islandOwnerName) - .replace("%votes", NumberUtil.formatNumberByDecimal(visit.getVoters().size()))); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty.Message")); - }); - - PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_leaderboard_bank_" + (i + 1), - event -> { - int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_bank_", "")); - - if (index < leaderboardBankPlayers.size()) { - Leaderboard leaderboard = leaderboardBankPlayers.get(index); - Visit visit = leaderboard.getVisit(); - - Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); - String islandOwnerName; - - if (targetPlayer == null) { - islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); - } else { - islandOwnerName = targetPlayer.getName(); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty.Message") - .replace("%position", "" + (index + 1)) - .replace("%player", islandOwnerName) - .replace("%balance", NumberUtil.formatNumberByDecimal(visit.getBankBalance()))); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty.Message")); - }); - - PlaceholderAPI.registerPlaceholder(plugin, "fabledskyblock_leaderboard_level_" + (i + 1), - event -> { - int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_level_", "")); - - if (index < leaderboardLevelPlayers.size()) { - Leaderboard leaderboard = leaderboardLevelPlayers.get(index); - Visit visit = leaderboard.getVisit(); - IslandLevel level = visit.getLevel(); - - Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); - String islandOwnerName; - - if (targetPlayer == null) { - islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); - } else { - islandOwnerName = targetPlayer.getName(); - } - - return ChatColor.translateAlternateColorCodes('&', configLoad - .getString("Placeholder.fabledskyblock_leaderboard_level.Non-empty.Message") - .replace("%position", "" + (index + 1)).replace("%player", islandOwnerName) - .replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel())) - .replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))); - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Empty.Message")); - }); - } - - for (String placeholderList : placeholderManager.getPlaceholders()) { - PlaceholderAPI.registerPlaceholder(plugin, placeholderList, event -> { - try { - Player player = event.getPlayer(); - - if (player == null) { - return null; - } - - return placeholderManager.getPlaceholder(player, event.getPlaceholder()); - } catch (Exception ex) { - Bukkit.getLogger().log(Level.WARNING, "[FabledSkyBlock] Exception while retrieving placeholder {}:", event.getPlaceholder()); - Bukkit.getLogger().log(Level.WARNING, "", ex); - return event.getPlaceholder(); - } - }); - } - } -} diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java index 7091d8a5..b9e65053 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java @@ -1,452 +1,41 @@ package com.songoda.skyblock.placeholder; -import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.invite.Invite; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.island.IslandStatus; -import com.songoda.skyblock.leaderboard.Leaderboard; -import com.songoda.skyblock.leaderboard.LeaderboardManager; -import com.songoda.skyblock.levelling.IslandLevelManager; -import com.songoda.skyblock.upgrade.Upgrade; -import com.songoda.skyblock.upgrade.Upgrade.Type; -import com.songoda.skyblock.utils.NumberUtil; -import com.songoda.skyblock.visit.VisitManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; +import com.songoda.skyblock.manager.Manager; +import com.songoda.skyblock.placeholder.hook.PlaceholderAPI; import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -public class PlaceholderManager { - - private final SkyBlock plugin; - - private boolean PlaceholderAPI = false; - private boolean MVdWPlaceholderAPI = false; - +public class PlaceholderManager extends Manager { + + private boolean PlaceholderAPIEnabled = false; + public PlaceholderManager(SkyBlock plugin) { - this.plugin = plugin; - + super(plugin); + PluginManager pluginManager = plugin.getServer().getPluginManager(); - + if (pluginManager.getPlugin("PlaceholderAPI") != null) { - PlaceholderAPI = true; - } - - if (pluginManager.getPlugin("MVdWPlaceholderAPI") != null) { - MVdWPlaceholderAPI = true; + PlaceholderAPIEnabled = true; } } - + public void registerPlaceholders() { - if (PlaceholderAPI) { - new EZPlaceholder(plugin).register(); - } - - if (MVdWPlaceholderAPI) { - new MVdWPlaceholder(plugin).register(); + if (PlaceholderAPIEnabled) { + new PlaceholderAPI(plugin).register(); } } - + public boolean isPlaceholderAPIEnabled() { - return PlaceholderAPI; + return PlaceholderAPIEnabled; } - - public boolean isMVdWPlaceholderAPIEnabled() { - return MVdWPlaceholderAPI; - } - - public String getPlaceholder(Player player, String placeholder) { - IslandManager islandManager = plugin.getIslandManager(); - VisitManager visitManager = plugin.getVisitManager(); - IslandLevelManager levellingManager = plugin.getLevellingManager(); - - Island island = islandManager.getIsland(player); - - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (placeholder.equalsIgnoreCase("fabledskyblock_island_exists")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_exists.Not-exists.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_exists.Exists.Message")); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_isopen")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_isopen.Empty.Message")); - } else { - if (island.getStatus().equals(IslandStatus.OPEN)) { // TODO Update to Status - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_isopen.Open.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_isopen.Closed.Message")); - } - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_size")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_size.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_size.Non-empty.Message") - .replace("%placeholder", "" + island.getSize())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_radius")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_radius.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_radius.Non-empty.Message") - .replace("%placeholder", "" + island.getRadius())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_level")) { - return island == null || island.getLevel() == null ? "0": Long.toString(island.getLevel().getLevel()); - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_level_formatted")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_formatted.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_formatted.Non-empty.Message").replace( - "%placeholder", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel()))); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_points")) { - return island == null ? "0": Long.toString(island.getLevel().getPoints()); - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_votes")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_votes.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_votes.Non-empty.Message") - .replace("%placeholder", "" + visitManager.getIslands().get(player.getUniqueId()).getVoters().size())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_role")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_role.Empty.Message")); - } else { - for (IslandRole roleList : IslandRole.values()) { - if (island.hasRole(roleList, player.getUniqueId())) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_role.Non-empty.Message") - .replace("%placeholder", plugin.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList))); - } - } - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_owner")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_owner.Empty.Message")); - } else { - UUID islandOwnerUUID = island.getOwnerUUID(); - Player targetPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID); - - if (targetPlayer == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_owner.Non-empty.Other.Message").replace( - "%placeholder", Bukkit.getServer().getOfflinePlayer(islandOwnerUUID).getName())); - } else { - if (targetPlayer.getName().equals(player.getName())) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_owner.Non-empty.Yourself.Message") - .replace("%placeholder", targetPlayer.getName())); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_owner.Non-empty.Other.Message") - .replace("%placeholder", targetPlayer.getName())); - } - } - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_biome")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_biome.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_biome.Non-empty.Message") - .replace("%placeholder", island.getBiomeName())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_time")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_time.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_time.Non-empty.Message") - .replace("%placeholder", "" + island.getTime())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_weather")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_weather.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_weather.Non-empty.Message") - .replace("%placeholder", "" + island.getWeatherName())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_bans")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_bans.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_bans.Non-empty.Message") - .replace("%placeholder", "" + island.getBan().getBans().size())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_members_total")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_members_total.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_members_total.Non-empty.Message") - .replace("%placeholder", "" + (island.getRole(IslandRole.Member).size() - + island.getRole(IslandRole.Operator).size() + 1))); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_members")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_members.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty.Message") - .replace("%placeholder", "" + island.getRole(IslandRole.Member).size())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_maxmembers")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_maxmembers.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_maxmembers.Non-empty.Message") - .replace("%placeholder", "" + island.getMaxMembers())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_operators")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_operators.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_operators.Non-empty.Message") - .replace("%placeholder", "" + island.getRole(IslandRole.Operator).size())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_coops")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_coops.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_coops.Non-empty.Message") - .replace("%placeholder", "" + islandManager.getCoopPlayersAtIsland(island).size())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_coops_total")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_coops_total.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_coops_total.Non-empty.Message") - .replace("%placeholder", "" + island.getCoopPlayers().size())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_visitors")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_visitors.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_visitors.Non-empty.Message") - .replace("%placeholder", "" + islandManager.getVisitorsAtIsland(island).size())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_invites")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_invites.Empty.Message")); - } else { - Map invites = plugin.getInviteManager().getInvites(); - int invitedPlayers = 0; - - for (int i = 0; i < invites.size(); i++) { - UUID uuid = (UUID) invites.keySet().toArray()[i]; - Invite invite = invites.get(uuid); - - if (invite.getOwnerUUID().equals(island.getOwnerUUID())) { - invitedPlayers++; - } - } - - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_invites.Non-empty.Message") - .replace("%placeholder", "" + invitedPlayers)); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_bank_balance")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_bank_balance.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_bank_balance.Non-empty.Message")) - .replace("%placeholder", "" + NumberUtil.formatNumberByDecimal(island.getBankBalance())); - } - } else if (placeholder.equalsIgnoreCase("fabledskyblock_island_bank_balance_formatted")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_bank_balance_formatted.Empty.Message")); - } else { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_bank_balance_formatted.Non-empty.Message")) - .replace("%placeholder", "" + NumberUtil.formatNumberBySuffix((long) island.getBankBalance())); - } - } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty.Message")); - } else { - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); - int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level); - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty.Message") - .replace("%placeholder", "" + rank)); - } - } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_bank_rank")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty.Message")); - } else { - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); - int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank); - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty.Message") - .replace("%placeholder", "" + rank)); - } - } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty.Message")); - } else { - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); - int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes); - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty.Message") - .replace("%placeholder", "" + rank)); - } - } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Empty.Message")); - } else { - String materialName = placeholder.replace("fabledskyblock_island_level_block_count_", "").toUpperCase(); - CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); - if (materials == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Invalid.Message")); - } else { - long blockCount = island.getLevel().getMaterialAmount(materials.name()); - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Non-empty.Message") - .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockCount))); - } - } - } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_points_")) { - if (island == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Empty.Message")); - } else { - String materialName = placeholder.replace("fabledskyblock_island_level_block_points_", "").toUpperCase(); - CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); - if (materials == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Invalid.Message")); - } else { - long blockPoints = island.getLevel().getMaterialPoints(materials.name()); - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Non-empty.Message") - .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockPoints))); - } - } - } else if (placeholder.toLowerCase().startsWith("fabledskyblock_level_block_value_")) { - String materialName = placeholder.replace("fabledskyblock_level_block_value_", "").toUpperCase(); - CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); - if (materials == null) { - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid.Message")); - } else { - double blockValue = levellingManager.getWorth(materials); - return ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty.Message") - .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockValue))); - } - } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_has_upgrade_")) { - Type type; - - final String lower = placeholder.replace("fabledskyblock_island_has_upgrade_", "").toLowerCase(); - - if (lower.isEmpty()) return ""; - - final String toParse = lower.substring(0, 1).toUpperCase() + lower.substring(1); - - try { - type = Upgrade.Type.valueOf(toParse); - } catch (IllegalArgumentException ignored) { - type = null; - } - - if (type == null) return "Invalid type '" + toParse + "'"; - - return Boolean.toString(island.hasUpgrade(type)); + + public String parsePlaceholders(Player player, String message) { + String retValue = ""; + + if(PlaceholderAPIEnabled) { + retValue = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message); } - - return ""; - } - - public List getPlaceholders() { - List placeholders = new ArrayList<>(25); - placeholders.add("fabledskyblock_island_exists"); - placeholders.add("fabledskyblock_island_isopen"); - placeholders.add("fabledskyblock_island_size"); - placeholders.add("fabledskyblock_island_radius"); - placeholders.add("fabledskyblock_island_level"); - placeholders.add("fabledskyblock_island_level_formatted"); - placeholders.add("fabledskyblock_island_points"); - placeholders.add("fabledskyblock_island_votes"); - placeholders.add("fabledskyblock_island_role"); - placeholders.add("fabledskyblock_island_owner"); - placeholders.add("fabledskyblock_island_biome"); - placeholders.add("fabledskyblock_island_time"); - placeholders.add("fabledskyblock_island_weather"); - placeholders.add("fabledskyblock_island_bans"); - placeholders.add("fabledskyblock_island_members_total"); - placeholders.add("fabledskyblock_island_members"); - placeholders.add("fabledskyblock_island_maxmembers"); - placeholders.add("fabledskyblock_island_operators"); - placeholders.add("fabledskyblock_island_coops"); - placeholders.add("fabledskyblock_island_coops_total"); - placeholders.add("fabledskyblock_island_visitors"); - placeholders.add("fabledskyblock_island_invites"); - placeholders.add("fabledskyblock_island_bank_balance"); - placeholders.add("fabledskyblock_island_leaderboard_level_rank"); - placeholders.add("fabledskyblock_island_leaderboard_bank_rank"); - placeholders.add("fabledskyblock_island_leaderboard_votes_rank"); - //placeholders.add("fabledskyblock_island_level_block_count_"); - //placeholders.add("fabledskyblock_island_level_block_points_"); - //placeholders.add("fabledskyblock_level_block_value_"); - - return placeholders; + return retValue; } } diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java new file mode 100644 index 00000000..6ffb3e1f --- /dev/null +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java @@ -0,0 +1,417 @@ +package com.songoda.skyblock.placeholder; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; +import com.songoda.skyblock.invite.Invite; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.island.IslandStatus; +import com.songoda.skyblock.leaderboard.Leaderboard; +import com.songoda.skyblock.leaderboard.LeaderboardManager; +import com.songoda.skyblock.levelling.IslandLevelManager; +import com.songoda.skyblock.upgrade.Upgrade; +import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.skyblock.visit.VisitManager; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; +import java.util.Map; +import java.util.UUID; + +public class PlaceholderProcessor { + + public String processPlaceholder(Player player, String placeholder) { + SkyBlock plugin = SkyBlock.getInstance(); + IslandManager islandManager = plugin.getIslandManager(); + VisitManager visitManager = plugin.getVisitManager(); + IslandLevelManager levellingManager = plugin.getLevellingManager(); + + FileManager fileManager = plugin.getFileManager(); + FileConfiguration placeholdersLoad = fileManager.getConfig( + new File(plugin.getDataFolder(), "placeholders.yml")).getFileConfiguration(); + + if(placeholdersLoad == null) { + Bukkit.broadcastMessage("ABC"); + return "Error"; + } + + Island island = islandManager.getIsland(player); + + String returnValue = null; + + if(player == null || placeholder == null) { + return ""; + } + + switch (placeholder.toLowerCase()) { + case "fabledskyblock_island_exists": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Not-exists.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Exists.Message")); + } + break; + case "fabledskyblock_island_isopen": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Empty.Message")); + } else { + if (island.getStatus().equals(IslandStatus.OPEN)) { // TODO Update to Status + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Open.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Closed.Message")); + } + } + break; + case "fabledskyblock_island_size": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Non-empty.Message") + .replace("%placeholder", "" + island.getSize())); + } + break; + case "fabledskyblock_island_radius": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Non-empty.Message") + .replace("%placeholder", "" + island.getRadius())); + } + break; + case "fabledskyblock_island_level": + returnValue = island == null || island.getLevel() == null ? "0" : Long.toString(island.getLevel().getLevel()); + break; + case "fabledskyblock_island_level_formatted": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Non-empty.Message").replace( + "%placeholder", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel()))); + } + break; + case "fabledskyblock_island_points": + returnValue = island == null ? "0" : Long.toString(island.getLevel().getPoints()); + break; + case "fabledskyblock_island_votes": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Non-empty.Message") + .replace("%placeholder", "" + visitManager.getIslands().get(player.getUniqueId()).getVoters().size())); + } + break; + case "fabledskyblock_island_role": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Empty.Message")); + } else { + for (IslandRole roleList : IslandRole.values()) { + if (island.hasRole(roleList, player.getUniqueId())) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Non-empty.Message") + .replace("%placeholder", plugin.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList))); + } + } + } + break; + case "fabledskyblock_island_owner": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Empty.Message")); + } else { + UUID islandOwnerUUID = island.getOwnerUUID(); + Player targetPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID); + + if (targetPlayer == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other.Message").replace( + "%placeholder", Bukkit.getServer().getOfflinePlayer(islandOwnerUUID).getName())); + } else { + if (targetPlayer.getName().equals(player.getName())) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Yourself.Message") + .replace("%placeholder", targetPlayer.getName())); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other.Message") + .replace("%placeholder", targetPlayer.getName())); + } + } + } + break; + case "fabledskyblock_island_biome": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Non-empty.Message") + .replace("%placeholder", island.getBiomeName())); + } + break; + case "fabledskyblock_island_time": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Non-empty.Message") + .replace("%placeholder", "" + island.getTime())); + } + break; + case "fabledskyblock_island_weather": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Non-empty.Message") + .replace("%placeholder", "" + island.getWeatherName())); + } + break; + case "fabledskyblock_island_bans": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Non-empty.Message") + .replace("%placeholder", "" + island.getBan().getBans().size())); + } + break; + case "fabledskyblock_island_members_total": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Non-empty.Message") + .replace("%placeholder", "" + (island.getRole(IslandRole.Member).size() + + island.getRole(IslandRole.Operator).size() + 1))); + } + break; + case "fabledskyblock_island_members": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_members.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty.Message") + .replace("%placeholder", "" + island.getRole(IslandRole.Member).size())); + } + break; + case "fabledskyblock_island_maxmembers": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Non-empty.Message") + .replace("%placeholder", "" + island.getMaxMembers())); + } + break; + case "fabledskyblock_island_operators": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Non-empty.Message") + .replace("%placeholder", "" + island.getRole(IslandRole.Operator).size())); + } + break; + case "fabledskyblock_island_coops": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Non-empty.Message") + .replace("%placeholder", "" + islandManager.getCoopPlayersAtIsland(island).size())); + } + break; + case "fabledskyblock_island_coops_total": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Non-empty.Message") + .replace("%placeholder", "" + island.getCoopPlayers().size())); + } + break; + case "fabledskyblock_island_visitors": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Non-empty.Message") + .replace("%placeholder", "" + islandManager.getVisitorsAtIsland(island).size())); + } + break; + case "fabledskyblock_island_invites": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Empty.Message")); + } else { + Map invites = plugin.getInviteManager().getInvites(); + int invitedPlayers = 0; + + for (int i = 0; i < invites.size(); i++) { + UUID uuid = (UUID) invites.keySet().toArray()[i]; + Invite invite = invites.get(uuid); + + if (invite.getOwnerUUID().equals(island.getOwnerUUID())) { + invitedPlayers++; + } + } + + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Non-empty.Message") + .replace("%placeholder", "" + invitedPlayers)); + } + break; + case "fabledskyblock_island_bank_balance": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Non-empty.Message")) + .replace("%placeholder", "" + NumberUtil.formatNumberByDecimal(island.getBankBalance())); + } + break; + case "fabledskyblock_island_bank_balance_formatted": + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Empty.Message")); + } else { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Non-empty.Message")) + .replace("%placeholder", "" + NumberUtil.formatNumberBySuffix((long) island.getBankBalance())); + } + break; + } + + if(returnValue == null) { + if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) { + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty.Message")); + } else { + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); + int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level); + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty.Message") + .replace("%placeholder", "" + rank)); + } + } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_bank_rank")) { + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty.Message")); + } else { + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); + int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank); + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty.Message") + .replace("%placeholder", "" + rank)); + } + } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) { + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty.Message")); + } else { + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); + int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes); + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty.Message") + .replace("%placeholder", "" + rank)); + } + } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) { + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Empty.Message")); + } else { + String materialName = placeholder.replace("fabledskyblock_island_level_block_count_", "").toUpperCase(); + CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); + if (materials == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Invalid.Message")); + } else { + long blockCount = island.getLevel().getMaterialAmount(materials.name()); + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Non-empty.Message") + .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockCount))); + } + } + } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_points_")) { + if (island == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Empty.Message")); + } else { + String materialName = placeholder.replace("fabledskyblock_island_level_block_points_", "").toUpperCase(); + CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); + if (materials == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Invalid.Message")); + } else { + long blockPoints = island.getLevel().getMaterialPoints(materials.name()); + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Non-empty.Message") + .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockPoints))); + } + } + } else if (placeholder.toLowerCase().startsWith("fabledskyblock_level_block_value_")) { + String materialName = placeholder.replace("fabledskyblock_level_block_value_", "").toUpperCase(); + CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); + if (materials == null) { + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid.Message")); + } else { + double blockValue = levellingManager.getWorth(materials); + returnValue = ChatColor.translateAlternateColorCodes('&', + placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty.Message") + .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockValue))); + } + } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_has_upgrade_")) { + Upgrade.Type type; + + final String lower = placeholder.replace("fabledskyblock_island_has_upgrade_", "").toLowerCase(); + + if (!lower.isEmpty()) { + final String toParse = lower.substring(0, 1).toUpperCase() + lower.substring(1); + + try { + type = Upgrade.Type.valueOf(toParse); + returnValue = Boolean.toString(island.hasUpgrade(type)); + } catch (IllegalArgumentException ignored) { + returnValue = "Invalid type '" + toParse + "'"; + } + } else { + returnValue = ""; + } + } + } + + return returnValue; + } +} diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/hook/PlaceholderAPI.java b/src/main/java/com/songoda/skyblock/placeholder/hook/PlaceholderAPI.java similarity index 73% rename from src/main/java/com/songoda/skyblock/placeholder/wip/hook/PlaceholderAPI.java rename to src/main/java/com/songoda/skyblock/placeholder/hook/PlaceholderAPI.java index f11fb13b..cddb05f3 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/wip/hook/PlaceholderAPI.java +++ b/src/main/java/com/songoda/skyblock/placeholder/hook/PlaceholderAPI.java @@ -1,22 +1,25 @@ -package com.songoda.skyblock.placeholder.wip.hook; +package com.songoda.skyblock.placeholder.hook; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.placeholder.wip.PlaceholderProcessor; +import com.songoda.skyblock.placeholder.PlaceholderProcessor; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; public class PlaceholderAPI extends PlaceholderExpansion { private final SkyBlock plugin; + private final PlaceholderProcessor placeholderProcessor; public PlaceholderAPI(SkyBlock plugin) { this.plugin = plugin; + this.placeholderProcessor = new PlaceholderProcessor(); } public String getIdentifier() { return "fabledskyblock"; } + @Deprecated public String getPlugin() { return null; } @@ -35,6 +38,6 @@ public class PlaceholderAPI extends PlaceholderExpansion { public String onPlaceholderRequest(Player player, String identifier) { - return PlaceholderProcessor.processPlaceholder(player, "fabledskyblock_" + identifier); + return placeholderProcessor.processPlaceholder(player, "fabledskyblock_" + identifier); } } diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java b/src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java deleted file mode 100644 index 6debe567..00000000 --- a/src/main/java/com/songoda/skyblock/placeholder/wip/Placeholder.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.songoda.skyblock.placeholder.wip; - -public class Placeholder { - - private final String placeholder; - private final String result; - - public Placeholder(String placeholder, String result) { - this.placeholder = placeholder; - this.result = result; - } - - public String getPlaceholder() { - return placeholder; - } - - public String getResult() { - return result; - } -} \ No newline at end of file diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java deleted file mode 100644 index b3c6ec20..00000000 --- a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderManager.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.songoda.skyblock.placeholder.wip; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.manager.Manager; -import org.bukkit.entity.Player; - -public class PlaceholderManager extends Manager { - - public PlaceholderManager(SkyBlock plugin) { - super(plugin); - } - - public String parsePlaceholders(Player player, String message) { - return ""; - } -} diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java deleted file mode 100644 index dda79fd7..00000000 --- a/src/main/java/com/songoda/skyblock/placeholder/wip/PlaceholderProcessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.songoda.skyblock.placeholder.wip; - -import org.bukkit.entity.Player; - -public class PlaceholderProcessor { - - public static String processPlaceholder(Player player, String placeholder) { - if(player == null || placeholder == null) { - return ""; - } - return "To be implemented"; - } -} diff --git a/src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java b/src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java deleted file mode 100644 index 24ef95db..00000000 --- a/src/main/java/com/songoda/skyblock/placeholder/wip/hook/MVdWPlaceholder.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.songoda.skyblock.placeholder.wip.hook; - -public class MVdWPlaceholder { -} diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index e8ce4783..d1e43d31 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -8,7 +8,6 @@ import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.island.*; import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.scoreboard.Scoreboard; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.utils.world.LocationUtil; @@ -193,23 +192,12 @@ public class PlayerDataManager { ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); if (scoreboardManager != null) { - for (Player all : Bukkit.getOnlinePlayers()) { - PlayerData targetPlayerData = getPlayerData(all); + for (Player loopPlayer : Bukkit.getOnlinePlayers()) { + PlayerData targetPlayerData = getPlayerData(loopPlayer); - if (targetPlayerData.getOwner() != null && targetPlayerData.getOwner().equals(island.getOwnerUUID())) { - Scoreboard scoreboard = scoreboardManager.getScoreboard(all); - - if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1) == 1) { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Solo.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); - } else { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname"))); - scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); - - - } - - scoreboard.run(); + if (targetPlayerData.getOwner() != null && + targetPlayerData.getOwner().equals(island.getOwnerUUID())) { + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/Board.java new file mode 100644 index 00000000..bb50c5a9 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/Board.java @@ -0,0 +1,118 @@ +package com.songoda.skyblock.scoreboard; + +import com.songoda.core.compatibility.ServerVersion; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.placeholder.PlaceholderManager; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; + +import java.util.HashMap; + +class Board { + + private final Player player; + private final SkyBlock plugin; + public Scoreboard board; + private final Objective objective; + + private final HashMap cache = new HashMap<>(); + + public Board(SkyBlock plugin, Player player, int lineCount) { + this.player = player; + this.plugin = plugin; + this.board = this.plugin.getServer().getScoreboardManager().getNewScoreboard(); + this.objective = this.board.registerNewObjective("sb1", "sb2"); + this.objective.setDisplaySlot(DisplaySlot.SIDEBAR); + this.objective.setDisplayName("..."); + + for(int i = 0; i < lineCount;i++) { + Team t = this.board.registerNewTeam(i + ""); + t.addEntry(ChatColor.values()[i] + ""); + + this.objective.getScore(ChatColor.values()[i] + "").setScore(lineCount - i); + } + + //this.player.setScoreboard(this.board); + } + + public void setTitle(String string) { + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); + + if(string == null) string = ""; + string = placeholderManager.parsePlaceholders(player, string); + + if (!cache.containsKey(-1) || !cache.get(-1).equals(string)) { + cache.remove(-1); + cache.put(-1, string); + objective.setDisplayName(string); + } + } + + public void setLine(int line, String string) { + Team t = board.getTeam(String.valueOf(line)); + if(string == null) string = ""; + + if ((!cache.containsKey(line) || !cache.get(line).equals(string)) && t != null) { + cache.remove(line); + cache.put(line, string); + + ScoreboardLine parts; + + if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) { + parts = convertIntoPieces(string, 16); + } else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ + parts = convertIntoPieces(string, 64); + } else { + parts = convertIntoPieces(string, 8); + } + + t.setPrefix(parts.getPrefix()); + t.setSuffix(parts.getSuffix()); + } + } + + private ScoreboardLine convertIntoPieces(String line, int allowed_line_size) { + String prefixLine = line.substring(0, Math.min(line.length(), allowed_line_size)); + String suffixLine = ""; + if(line.length() > allowed_line_size) { + suffixLine = line.substring(allowed_line_size); + } + + if (prefixLine.endsWith(String.valueOf(ChatColor.COLOR_CHAR))) { + prefixLine = ChatColor.translateAlternateColorCodes( + ChatColor.COLOR_CHAR, prefixLine.substring(0, prefixLine.length() - 1)); + suffixLine = ChatColor.translateAlternateColorCodes( + ChatColor.COLOR_CHAR, ChatColor.COLOR_CHAR + suffixLine); + } else { + String lastColorCodes; + + if (prefixLine.contains(String.valueOf(ChatColor.COLOR_CHAR))) { + String[] colorCodes = prefixLine.split(String.valueOf(ChatColor.COLOR_CHAR)); + String lastColorCodeText = colorCodes[colorCodes.length - 1]; + lastColorCodes = ChatColor.COLOR_CHAR + + lastColorCodeText.substring(0, Math.min(lastColorCodeText.length(), 1)); + + if ((colorCodes.length >= 2) && + (lastColorCodes.equals(String.valueOf(ChatColor.BOLD)) || + lastColorCodes.equals(String.valueOf(ChatColor.STRIKETHROUGH)) || + lastColorCodes.equals(String.valueOf(ChatColor.UNDERLINE)) || + lastColorCodes.equals(String.valueOf(ChatColor.ITALIC)) || + lastColorCodes.equals(String.valueOf(ChatColor.MAGIC)))) { + lastColorCodeText = colorCodes[colorCodes.length - 2]; + lastColorCodes = ChatColor.COLOR_CHAR + + lastColorCodeText.substring(0, Math.min(lastColorCodeText.length(), 1)) + lastColorCodes; + } + } else { + lastColorCodes = ChatColor.WHITE.toString(); + } + + prefixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, prefixLine); + suffixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, lastColorCodes + suffixLine); + } + return new ScoreboardLine(prefixLine, suffixLine); + } +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java new file mode 100644 index 00000000..7742f8bc --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java @@ -0,0 +1,92 @@ +package com.songoda.skyblock.scoreboard; + +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; +import org.bukkit.Bukkit; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +class Driver extends BukkitRunnable { + + private final SkyBlock plugin; + + private final Row title; + private final List rows; + private final List holders; + private final ScoreboardType boardType; + + public Driver(SkyBlock plugin, ScoreboardType boardType) { + this.plugin = plugin; + FileManager fileManager = plugin.getFileManager(); + FileConfiguration scoreboardLoad = fileManager.getConfig( + new File(plugin.getDataFolder(), "scoreboard.yml")).getFileConfiguration(); + + rows = new ArrayList<>(); + holders = new ArrayList<>(); + this.boardType = boardType; + + ConfigurationSection config = scoreboardLoad.getConfigurationSection(boardType.getConfigSection()); + + if(config != null) { + List lines = config.getStringList("Title.Content"); + int interval = config.getInt("Title.Interval"); + title = new Row(lines, interval); + + for(int i = 1; i<16; i++) { + List rowLines = config.getStringList("Rows." + i + ".Content"); + if(!rowLines.isEmpty()) { + Row row = new Row(rowLines, config.getInt("Interval")); + rows.add(row); + } + } + } else { + title = new Row(new ArrayList<>(), 0); + } + } + + public List getRows() { + return rows; + } + + public Row getTitle() { + return title; + } + + public void registerHolder(Holder holder) { + holders.add(holder); + } + + public void unregisterHolder(Holder holder) { + holders.remove(holder); + } + + public void unregisterHolder(Player player) { + for(Holder holder : holders) + if(holder.player.equals(player)) { + holders.remove(holder); + break; + } + } + + @Override + public void run() { + title.update(); + for(Row row : rows) { + row.update(); + } + + for(Holder holder : holders) { + holder.update(); + } + } + + public ScoreboardType getBoardType() { + return boardType; + } +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java new file mode 100644 index 00000000..a06df835 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java @@ -0,0 +1,48 @@ +package com.songoda.skyblock.scoreboard; + +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.placeholder.PlaceholderManager; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +class Holder { + + private final SkyBlock plugin; + + private final Driver driver; + public final Player player; + + private final Board board; + + public Holder(SkyBlock plugin, Driver driver, Player player) { + this.plugin = plugin; + this.driver = driver; + this.player = player; + + board = new Board(plugin, player, driver.getRows().size()); + update(); + } + + public void update() { + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + + if(scoreboardManager != null) { + if (!scoreboardManager.isPlayerDisabled(player)) { + board.setTitle(driver.getTitle().getLine()); + + int count = 0; + for(Row row : driver.getRows()) { + String line = placeholderManager.parsePlaceholders(player, row.getLine()); + board.setLine(count, line); + count++; + } + + this.player.setScoreboard(board.board); + } else { + this.player.setScoreboard(plugin.getServer().getScoreboardManager().getNewScoreboard()); + } + } + } + +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Row.java b/src/main/java/com/songoda/skyblock/scoreboard/Row.java new file mode 100644 index 00000000..a9e7803e --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/Row.java @@ -0,0 +1,54 @@ +package com.songoda.skyblock.scoreboard; + +import com.songoda.core.utils.TextUtils; + +import java.util.List; + +class Row { + + private final int interval; + private final List lines; + private String line; + private int current; + private int count; + + public boolean static_line; + + public Row(List lines, int interval) { + this.lines = lines; + this.interval = interval; + this.current = 1; + this.count = 0; + + if(interval < 0) { + static_line = true; + } else { + static_line = false; + } + + if(lines.isEmpty()) { + line = ""; + } else { + line = TextUtils.formatText(lines.get(0)); + } + } + + public void update() { + if (!static_line && !lines.isEmpty()) { + if (count >= interval) { + count = 0; + current++; + if (current >= lines.size()) + current = 0; + line = TextUtils.formatText(lines.get(current)); + } else { + count++; + } + } + } + + public String getLine() { + return this.line; + } + +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java b/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java deleted file mode 100644 index 134d2588..00000000 --- a/src/main/java/com/songoda/skyblock/scoreboard/Scoreboard.java +++ /dev/null @@ -1,224 +0,0 @@ -package com.songoda.skyblock.scoreboard; - -import com.songoda.core.compatibility.ServerVersion; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandLevel; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.localization.type.Localization; -import com.songoda.skyblock.placeholder.PlaceholderManager; -import com.songoda.skyblock.utils.NumberUtil; -import com.songoda.skyblock.utils.version.NMSUtil; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Team; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class Scoreboard { - - private final SkyBlock plugin; - private final Player player; - - private String displayName; - private List displayList; - - private BukkitTask scheduler; - - public Scoreboard(SkyBlock plugin, Player player) { - this.plugin = plugin; - this.player = player; - displayList = new ArrayList<>(); - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public void setDisplayList(List displayList) { - this.displayList = displayList; - } - - public void run() { - if (scheduler != null) scheduler.cancel(); - - new BukkitRunnable() { - @Override - public void run() { - final org.bukkit.scoreboard.Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - - new BukkitRunnable() { - @Override - @SuppressWarnings("deprecation") - public void run() { - String ranStr = UUID.randomUUID().toString().split("-")[0]; - Objective obj; - - if (scoreboard.getObjective(player.getName()) != null) { - obj = scoreboard.getObjective(player.getName()); - } else { - obj = scoreboard.registerNewObjective(player.getName(), "dummy"); - } - - obj.setDisplaySlot(DisplaySlot.SIDEBAR); - - String formattedDisplayName = ChatColor.translateAlternateColorCodes('&', replaceDisplayName(displayName)); - int max; - if(ServerVersion.isServerVersion(ServerVersion.V1_8)) { - max = 16; - } else { - max = 32; - } - if (formattedDisplayName.length() > max) { - obj.setDisplayName(ChatColor.RED + "Too long..."); - } else { - obj.setDisplayName(formattedDisplayName); - } - - for (int i = 0; i < ChatColor.values().length; i++) { - if (i == displayList.size()) { - break; - } - - ChatColor chatColor = ChatColor.values()[i]; - Team team = scoreboard.registerNewTeam(ranStr + i); - team.addEntry(chatColor.toString()); - obj.getScore(chatColor.toString()).setScore(i); - } - - scheduler = new BukkitRunnable() { - int i1 = displayList.size(); - - @Override - public void run() { - if (!player.isOnline()) cancel(); - - try { - String formattedDisplayName = ChatColor.translateAlternateColorCodes('&', replaceDisplayName(displayName)); - - if (formattedDisplayName.length() > max) { - obj.setDisplayName(ChatColor.RED + "Too long..."); - } else { - obj.setDisplayName(formattedDisplayName); - } - - for (String displayLine : displayList) { - i1--; - - displayLine = replaceDisplayLine(displayLine); - - if (displayLine.length() > 32) { - displayLine = "&cLine too long..."; - } - - if (displayLine.length() >= 16) { - String prefixLine = displayLine.substring(0, Math.min(displayLine.length(), 16)); - String suffixLine = displayLine.substring(16); - - if (prefixLine.endsWith("&")) { - prefixLine = ChatColor.translateAlternateColorCodes('&', prefixLine.substring(0, prefixLine.length() - 1)); - suffixLine = ChatColor.translateAlternateColorCodes('&', "&" + suffixLine); - } else { - String lastColorCodes; - - if (prefixLine.contains("&")) { - String[] colorCodes = prefixLine.split("&"); - String lastColorCodeText = colorCodes[colorCodes.length - 1]; - lastColorCodes = "&" + lastColorCodeText.substring(0, Math.min(lastColorCodeText.length(), 1)); - - if ((colorCodes.length >= 2) && (lastColorCodes.equals("&l") || lastColorCodes.equals("&m") || lastColorCodes.equals("&n") || lastColorCodes.equals("&o"))) { - lastColorCodeText = colorCodes[colorCodes.length - 2]; - lastColorCodes = "&" + lastColorCodeText.substring(0, Math.min(lastColorCodeText.length(), 1)) + lastColorCodes; - } - } else { - lastColorCodes = "&f"; - } - - prefixLine = ChatColor.translateAlternateColorCodes('&', prefixLine); - suffixLine = ChatColor.translateAlternateColorCodes('&', lastColorCodes + suffixLine); - } - - scoreboard.getTeam(ranStr + i1).setPrefix(prefixLine); - scoreboard.getTeam(ranStr + i1).setSuffix(suffixLine); - } else { - scoreboard.getTeam(ranStr + i1).setPrefix(ChatColor.translateAlternateColorCodes('&', displayLine)); - } - } - - i1 = displayList.size(); - } catch (Exception e) { - cancel(); - } - } - }.runTaskTimerAsynchronously(plugin, 0L, 20L); - - player.setScoreboard(scoreboard); - } - }.runTaskAsynchronously(plugin); - } - }.runTask(plugin); - } - - private String replaceDisplayName(String displayName) { - displayName = displayName.replace("%players_online", "" + Bukkit.getServer().getOnlinePlayers().size()).replace("%players_max", "" + Bukkit.getServer().getMaxPlayers()); - - return displayName; - } - - private String replaceDisplayLine(String displayLine) { - SkyBlock plugin = SkyBlock.getInstance(); - - IslandManager islandManager = plugin.getIslandManager(); - - displayLine = displayLine.replace("%players_online", String.valueOf(Bukkit.getServer().getOnlinePlayers().size())); - displayLine = displayLine.replace("%players_max", String.valueOf(Bukkit.getServer().getMaxPlayers())); - - Island island = islandManager.getIsland(player); - - if (island != null) { - IslandLevel level = island.getLevel(); - - if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { - displayLine = displayLine.replace("%island_level", "" + NumberUtil.formatNumberByDecimal(level.getLevel())).replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null") - .replace("%island_visitors", "" + islandManager.getVisitorsAtIsland(island).size()).replace("%island_size", "" + island.getSize()).replace("%island_radius", "" + island.getRadius()); - } else { - int islandMembers = 1 + island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size(); - String islandRole = ""; - - - Localization locale = plugin.getLocalizationManager().getLocalizationFor(IslandRole.class); - - if (island.hasRole(IslandRole.Owner, player.getUniqueId())) { - islandRole = locale.getLocale(IslandRole.Owner); - } else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) { - islandRole = locale.getLocale(IslandRole.Operator); - } else if (island.hasRole(IslandRole.Member, player.getUniqueId())) { - islandRole = locale.getLocale(IslandRole.Member);; - } - - displayLine = displayLine.replace("%island_points", "" + NumberUtil.formatNumberByDecimal(level.getPoints())).replace("%island_level", "" + NumberUtil.formatNumberByDecimal(level.getLevel())) - .replace("%island_members", "" + islandMembers).replace("%island_role", islandRole).replace("%island_visitors", "" + islandManager.getVisitorsAtIsland(island).size()) - .replace("%island_size", "" + island.getSize()).replace("%island_radius", "" + island.getRadius()); - } - } else { - displayLine = displayLine.replace("%island_points", ChatColor.RED + "0").replace("%island_level", ChatColor.RED + "0").replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null") - .replace("%island_size", ChatColor.RED + "0").replace("%island_radius", ChatColor.RED + "0"); - } - - PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); - - if (placeholderManager.isPlaceholderAPIEnabled()) { - displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine); - } - - return displayLine.replace(String.valueOf(ChatColor.COLOR_CHAR), "&"); // Returning unformatted line to avoid issues in next step - } -} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java new file mode 100644 index 00000000..758fa921 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java @@ -0,0 +1,20 @@ +package com.songoda.skyblock.scoreboard; + +class ScoreboardLine { + + private final String prefix; + private final String suffix; + + public ScoreboardLine(String prefix, String suffix) { + this.prefix = prefix; + this.suffix = suffix; + } + + public String getPrefix() { + return prefix; + } + + public String getSuffix() { + return suffix; + } +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 6b73bd82..92a7e36a 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -1,275 +1,139 @@ package com.songoda.skyblock.scoreboard; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.cooldown.CooldownManager; -import com.songoda.skyblock.cooldown.CooldownType; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; +import com.songoda.skyblock.manager.Manager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.visit.Visit; +import io.netty.util.internal.ConcurrentSet; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Team; -import org.bukkit.scoreboard.Team.Option; import java.io.File; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -public class ScoreboardManager { - - private final SkyBlock plugin; - private final Map scoreboardStorage = new ConcurrentHashMap<>(); - - private final PlayerDataManager playerDataManager; +public class ScoreboardManager extends Manager { - private final List teamNames = new ArrayList<>(); - private final List objectiveNames = new ArrayList<>(); + private final List drivers; + private final Set disabledPlayers; public ScoreboardManager(SkyBlock plugin) { - this.plugin = plugin; - this.playerDataManager = plugin.getPlayerDataManager(); - Bukkit.getScheduler().runTask(plugin, () -> reloadScoreboards(true)); - Bukkit.getScheduler().runTaskTimer(plugin, this::updateScoreboards, 20L, 40L); + super(plugin); + this.drivers = new ArrayList<>(); + this.disabledPlayers = new ConcurrentSet<>(); + + for(ScoreboardType type : ScoreboardType.values()) { + newDriver(type); + } + + updateOnlinePlayers(); } - private synchronized void updateScoreboards() { - final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); - final Set objectives = primary.getObjectives(); - final Set teams = primary.getTeams(); - - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - /* - * Unregister all teams or objectives that are no longer present in the main - * scoreboard. - */ - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard(); - - for (String name : objectiveNames) { - - if (primary.getObjective(name) != null) continue; - - final Objective objective = board.getObjective(name); - - if (objective != null) objective.unregister(); - } - - for (String name : teamNames) { - - if (primary.getTeam(name) != null) continue; - - final Team team = board.getTeam(name); - - if (team != null) team.unregister(); - } - } - } - - /* - * Update the objective/team names. - */ - - objectiveNames.clear(); - teamNames.clear(); - - for(Objective objective : objectives) { - if (primary.getObjective(objective.getName()) != null) { - objectiveNames.add(objective.getName()); - } - } - - for(Team team : teams) { - if (primary.getTeam(team.getName()) != null) { - teamNames.add(team.getName()); - } - } - - /* - * Update or add any missing information to the player's scoreboard. - */ - - for (UUID uuid : scoreboardStorage.keySet()) { - Player player = Bukkit.getPlayer(uuid); - if(player != null) { - PlayerData pd = playerDataManager.getPlayerData(player); - if(pd != null && pd.isScoreboard()){ - final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard(); - - for (Objective primaryObjective : objectives) { - - Objective obj = playerBoard.getObjective(primaryObjective.getName()); - - if (obj == null) - obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria()); - - obj.setDisplayName(primaryObjective.getDisplayName()); - obj.setDisplaySlot(primaryObjective.getDisplaySlot()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) obj.setRenderType(primaryObjective.getRenderType()); - } - - for (Team primaryTeam : teams) { - - Team obj = playerBoard.getTeam(primaryTeam.getName()); - - if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName()); - - obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire()); - obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles()); - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) obj.setColor(primaryTeam.getColor()); - obj.setDisplayName(primaryTeam.getDisplayName()); - obj.setNameTagVisibility(primaryTeam.getNameTagVisibility()); - obj.setPrefix(primaryTeam.getPrefix()); - obj.setSuffix(primaryTeam.getSuffix()); - - for (String primaryEntry : primaryTeam.getEntries()) { - obj.addEntry(primaryEntry); - } - - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { - for (Option option : Option.values()) { - obj.setOption(option, primaryTeam.getOption(option)); - } - } - } - } - } - } - }); + @Override + public void disable() { + clearDrivers(); } - public synchronized void reloadScoreboards(boolean createNew) { + @Override + public void reload() { + disable(); + updateOnlinePlayers(); + } - FileManager fileManager = plugin.getFileManager(); - - if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) - return; - - for (Player all : Bukkit.getOnlinePlayers()) { - - boolean store = false; - - Scoreboard scoreboard = null; - if (hasScoreboard(all)) - scoreboard = getScoreboard(all); - else { - if (createNew) { - scoreboard = new Scoreboard(plugin, all); - store = true; - } - } - - if (scoreboard == null) continue; - - IslandManager islandManager = plugin.getIslandManager(); - Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); - Island island = islandManager.getIsland(all); - - if (island == null) { - scoreboard.setDisplayName(color(language.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname"))); - scoreboard.setDisplayList(language.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines")); - } else { - if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { - scoreboard.setDisplayName(color(language.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(language.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); - } else { - scoreboard.setDisplayList(language.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); - } - } else { - scoreboard.setDisplayName(color(language.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(language.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines")); - } else { - scoreboard.setDisplayList(language.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); - } - } - } - - scoreboard.run(); - if (store) storeScoreboard(all, scoreboard); + public void updateOnlinePlayers() { + for(Player player : plugin.getServer().getOnlinePlayers()) { + updatePlayerScoreboardType(player); } } - private String color(String str) { - return str != null ? ChatColor.translateAlternateColorCodes('&', str) : null; - } - - public synchronized void storeScoreboard(Player player, Scoreboard scoreboard) { - scoreboardStorage.put(player.getUniqueId(), scoreboard); - } - - public synchronized Scoreboard getScoreboard(Player player) { - if (scoreboardStorage.containsKey(player.getUniqueId())) { - return scoreboardStorage.get(player.getUniqueId()); - } - - return null; - } - - public synchronized boolean hasScoreboard(Player player) { - return scoreboardStorage.containsKey(player.getUniqueId()); - } - - public synchronized Map getScoreboardStorage() { - return this.scoreboardStorage; - } - - public synchronized void addPlayer(Player player){ - CooldownManager cooldownManager = plugin.getCooldownManager(); - FileManager fileManager = plugin.getFileManager(); + public void updatePlayerScoreboardType(Player player) { + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); IslandManager islandManager = plugin.getIslandManager(); - - Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); - Scoreboard scoreboard = new Scoreboard(plugin, player); - Island island = islandManager.getIsland(player); - - if (island != null) { - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); - - cooldownManager.addCooldownPlayer(CooldownType.Levelling, cooldownManager.loadCooldownPlayer(CooldownType.Levelling, offlinePlayer)); - cooldownManager.addCooldownPlayer(CooldownType.Ownership, cooldownManager.loadCooldownPlayer(CooldownType.Ownership, offlinePlayer)); - - if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines")); + + PlayerData playerData = playerDataManager.getPlayerData(player); + Island island = islandManager.getIslandByPlayer(player); + + if(playerData.isScoreboard()) { + ScoreboardType type; + if(island != null) { + Visit islandVisit = island.getVisit(); + boolean hasVisitors = islandVisit.getVisitors().size() > 1; + boolean hasMembers = islandVisit.getMembers() > 1; + + if(hasMembers) { + if(hasVisitors) { + type = ScoreboardType.ISLAND_SOLO_VISITORS; + } else { + type = ScoreboardType.ISLAND_SOLO_EMPTY; + } } else { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines")); + if(hasVisitors) { + type = ScoreboardType.ISLAND_TEAM_VISITORS; + } else { + type = ScoreboardType.ISLAND_TEAM_EMPTY; + } } } else { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname"))); - - if (islandManager.getVisitorsAtIsland(island).size() == 0) { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines")); - } else { - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines")); - } - + type = ScoreboardType.NOISLAND; } - } else { - scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname"))); - scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines")); + + setPlayerScoreboard(player, type); + Bukkit.broadcastMessage(type.toString()); } - - scoreboard.run(); - this.storeScoreboard(player, scoreboard); + } + + public void unregisterPlayer(Player player) { + for(Driver driver : drivers) { + driver.unregisterHolder(player); + } + } + + public void addDisabledPlayer(Player player) { + disabledPlayers.add(player); + } + + public void removeDisabledPlayer(Player player) { + disabledPlayers.remove(player); + } + + public boolean isPlayerDisabled(Player player) { + return disabledPlayers.contains(player); } - public synchronized void removePlayer(Player player){ - player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); - this.scoreboardStorage.remove(player.getUniqueId()); + private void newDriver(ScoreboardType board) { + FileManager fileManager = plugin.getFileManager(); + FileConfiguration scoreboardLoad = fileManager.getConfig( + new File(plugin.getDataFolder(), "scoreboard.yml")).getFileConfiguration(); + + Driver driver = new Driver(plugin, board); + if(scoreboardLoad.getBoolean("Settings.Async", true)) { + driver.runTaskTimerAsynchronously(plugin, 1L, 1L); + } else { + driver.runTaskTimer(plugin, 1L, 1L); + } + drivers.add(driver); + Bukkit.broadcastMessage("G " + drivers.size()); } -} \ No newline at end of file + + public void clearDrivers() { + for(Driver driver : drivers) + driver.cancel(); + drivers.clear(); + } + + public void setPlayerScoreboard(Player player, ScoreboardType type) { + for(Driver driver : drivers) { + if(driver.getBoardType().equals(type)) { + Bukkit.broadcastMessage("F"); + driver.registerHolder(new Holder(plugin, driver, player)); + } else { + driver.unregisterHolder(player); + } + } + Bukkit.broadcastMessage(drivers.size() + ""); + } +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java new file mode 100644 index 00000000..5848ff7d --- /dev/null +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java @@ -0,0 +1,21 @@ +package com.songoda.skyblock.scoreboard; + +import javax.annotation.Nonnull; + +enum ScoreboardType { + NOISLAND("Scoreboards.NoIsland"), + ISLAND_SOLO_EMPTY("Scoreboards.Island.Solo.Empty"), + ISLAND_SOLO_VISITORS("Scoreboards.Island.Solo.Occupied"), + ISLAND_TEAM_EMPTY("Scoreboards.Island.Team.Empty"), + ISLAND_TEAM_VISITORS("Scoreboards.Island.Team.Occupied"); + + private final String configSection; + + ScoreboardType(@Nonnull String configSection) { + this.configSection = configSection; + } + + public @Nonnull String getConfigSection() { + return this.configSection; + } +} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java deleted file mode 100644 index 59a8c178..00000000 --- a/src/main/java/com/songoda/skyblock/scoreboard/wip/Board.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.songoda.skyblock.scoreboard.wip; - -public class Board { -} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java deleted file mode 100644 index bc52b8f8..00000000 --- a/src/main/java/com/songoda/skyblock/scoreboard/wip/Driver.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.songoda.skyblock.scoreboard.wip; - -import org.bukkit.scheduler.BukkitRunnable; - -public class Driver extends BukkitRunnable { - public Driver(String board) { - } - - @Override - public void run() { - - } - - public void setDefault(boolean isDefault) { - } -} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java deleted file mode 100644 index 91054545..00000000 --- a/src/main/java/com/songoda/skyblock/scoreboard/wip/Manager.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.songoda.skyblock.scoreboard.wip; - -import com.songoda.skyblock.SkyBlock; - -import java.util.Map; - -public class Manager { - - Map drivers; - - public void newDriver(String board, boolean isDefault) { - Driver driver = new Driver(board); - driver.runTaskTimerAsynchronously(SkyBlock.getInstance(), 1L, 1L); - drivers.put(board, driver); - driver.setDefault(isDefault); - } - - public void clearDrivers() - { - for(Driver driver : drivers.values()) - driver.cancel(); - drivers.clear(); - } -} diff --git a/src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java b/src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java deleted file mode 100644 index 1a430b8c..00000000 --- a/src/main/java/com/songoda/skyblock/scoreboard/wip/Row.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.songoda.skyblock.scoreboard.wip; - -public class Row { -} diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index e85b5a83..3ab56c7b 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1133,83 +1133,6 @@ Command: Message: '&bSkyBlock &8| &cError&8: &eYou don''t have permission to perform that command.' Island: Message: '&bSkyBlock &8| &cError&8: &eYou don''t have permission to perform that command.' -Scoreboard: - Tutorial: - Displaylines: - - '' - - '&bIsland&f:' - - '&cYou do not own an Island.' - - ' &8- &7/island create' - - '' - - '&bProfile&f:' - - ' &8- &7Rank&8: &fDefault' - - ' &8- &7Balance&8: &f$0' - - '' - - '&ewww.example.net' - Displayname: '&b&lSkyBlock' - Island: - Solo: - Empty: - Displaylines: - - '' - - '&bIsland&f:' - - ' &8- &7Level&8: &f%island_level' - - ' &8- &7Size&8: &f%island_size&7x&f%island_size' - - '' - - '&bProfile&f:' - - ' &8- &7Rank&8: &fDefault' - - ' &8- &7Balance&8: &f$0' - - '' - - '&ewww.example.net' - Occupied: - Displaylines: - - '' - - '&bIsland&f:' - - ' &8- &7Level&8: &f%island_level' - - ' &8- &7Visitors&8: &f%island_visitors' - - ' &8- &7Size&8: &f%island_size&7x&f%island_size' - - '' - - '&bProfile&f:' - - ' &8- &7Rank&8: &fDefault' - - ' &8- &7Balance&8: &f$0' - - '' - - '&ewww.example.net' - Displayname: '&b&lSkyBlock' - Team: - Word: - Owner: Owner - Operator: Operator - Member: Member - Empty: - Displaylines: - - '' - - '&bIsland&f:' - - ' &8- &7Role&8: &f%island_role' - - ' &8- &7Members&8: &f%island_members' - - ' &8- &7Level&8: &f%island_level' - - ' &8- &7Size&8: &f%island_size&7x&f%island_size' - - '' - - '&bProfile&f:' - - ' &8- &7Rank&8: &fDefault' - - ' &8- &7Balance&8: &f$0' - - '' - - '&ewww.example.net' - Occupied: - Displaylines: - - '' - - '&bIsland&f:' - - ' &8- &7Role&8: &f%island_role' - - ' &8- &7Members&8: &f%island_members' - - ' &8- &7Level&8: &f%island_level' - - ' &8- &7Visitors&8: &f%island_visitors' - - ' &8- &7Size&8: &f%island_size&7x&f%island_size' - - '' - - '&bProfile&f:' - - ' &8- &7Rank&8: &fDefault' - - ' &8- &7Balance&8: &f$0' - - '' - - '&ewww.example.net' - Displayname: '&b&lSkyBlock' Menu: Settings: Default: @@ -3454,171 +3377,6 @@ Menu: Exit: Displayname: '&cExit' Lore: '&7Exits the Menu' -Placeholder: - fabledskyblock_leaderboard_votes: - Empty: - Message: 'Unclaimed' - Non-empty: - Message: '[%position] %player [%votes]' - fabledskyblock_leaderboard_bank: - Empty: - Message: 'Unclaimed' - Non-empty: - Message: '[%position] %player [$%balance]' - fabledskyblock_island_exists: - Exists: - Message: 'true' - Not-exists: - Message: 'false' - fabledskyblock_island_members: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_coops: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_leaderboard_level: - Empty: - Message: 'Unclaimed' - Non-empty: - Message: '[%position] %player [%level]' - fabledskyblock_island_visitors: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_size: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_maxmembers: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_time: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_bank_balance_formatted: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_owner: - Non-empty: - Yourself: - Message: 'You' - Other: - Message: '%placeholder' - Empty: - Message: '&oNone' - fabledskyblock_island_leaderboard_bank_rank: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_bans: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_coops_total: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_invites: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_level_block_count: - Invalid: - Message: 'Invalid Type' - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_weather: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_role: - Empty: - Message: '&oNone' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_operators: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_bank_balance: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_biome: - Empty: - Message: '&oNone' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_level_formatted: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_members_total: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_level_block_points: - Empty: - Message: '0' - Invalid: - Message: 'Invalid Type' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_isopen: - Closed: - Message: 'false' - Open: - Message: 'true' - Empty: - Message: 'false' - fabledskyblock_island_votes: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_radius: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_leaderboard_votes_rank: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_level_block_value: - Invalid: - Message: 'Invalid Type' - Non-empty: - Message: '%placeholder' - fabledskyblock_island_leaderboard_level_rank: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' Island: Limit: Block: diff --git a/src/main/resources/placeholders.yml b/src/main/resources/placeholders.yml new file mode 100644 index 00000000..46d2d601 --- /dev/null +++ b/src/main/resources/placeholders.yml @@ -0,0 +1,165 @@ +Placeholders: + fabledskyblock_leaderboard_votes: + Empty: + Message: 'Unclaimed' + Non-empty: + Message: '[%position] %player [%votes]' + fabledskyblock_leaderboard_bank: + Empty: + Message: 'Unclaimed' + Non-empty: + Message: '[%position] %player [$%balance]' + fabledskyblock_island_exists: + Exists: + Message: 'true' + Not-exists: + Message: 'false' + fabledskyblock_island_members: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_coops: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_leaderboard_level: + Empty: + Message: 'Unclaimed' + Non-empty: + Message: '[%position] %player [%level]' + fabledskyblock_island_visitors: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_size: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_maxmembers: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_time: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_bank_balance_formatted: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_owner: + Non-empty: + Yourself: + Message: 'You' + Other: + Message: '%placeholder' + Empty: + Message: '&oNone' + fabledskyblock_island_leaderboard_bank_rank: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_bans: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_coops_total: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_invites: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_level_block_count: + Invalid: + Message: 'Invalid Type' + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_weather: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_role: + Empty: + Message: '&oNone' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_operators: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_bank_balance: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_biome: + Empty: + Message: '&oNone' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_level_formatted: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_members_total: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_island_level_block_points: + Empty: + Message: '0' + Invalid: + Message: 'Invalid Type' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_isopen: + Closed: + Message: 'false' + Open: + Message: 'true' + Empty: + Message: 'false' + fabledskyblock_island_votes: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_radius: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_leaderboard_votes_rank: + Non-empty: + Message: '%placeholder' + Empty: + Message: '0' + fabledskyblock_level_block_value: + Invalid: + Message: 'Invalid Type' + Non-empty: + Message: '%placeholder' + fabledskyblock_island_leaderboard_level_rank: + Empty: + Message: '0' + Non-empty: + Message: '%placeholder' \ No newline at end of file diff --git a/src/main/resources/scoreboard.yml b/src/main/resources/scoreboard.yml new file mode 100644 index 00000000..ca925c49 --- /dev/null +++ b/src/main/resources/scoreboard.yml @@ -0,0 +1,339 @@ +Settings: + Async: true +Scoreboards: + NoIsland: + Title: + Interval: 3 + Content: + - '&b&lSkyBlock' + - '&a&lS&b&lkyBlock' + - '&a&lSk&b&lyBlock' + - '&a&lSky&b&lBlock' + - '&a&lSkyB&b&llock' + - '&a&lSkyBl&b&lock' + - '&a&lSkyBlo&b&lck' + - '&a&lSkyBloc&b&lk' + - '&a&lSkyBlock' + - '&b&lS&a&lkyBlock' + - '&b&lSk&a&lyBlock' + - '&b&lSky&a&lBlock' + - '&b&lSkyB&a&llock' + - '&b&lSkyBl&a&lock' + - '&b&lSkyBlo&a&lck' + - '&b&lSkyBloc&a&lk' + Rows: + 1: + Interval: -1 + Content: + - '' + 2: + Interval: -1 + Content: + - '&bIsland&f:' + 3: + Interval: 5 + Content: + - '&cYou do not own an Island.' + 4: + Interval: 20 + Content: + - ' &8- &7/island create' + 5: + Interval: -1 + Content: + - '' + 6: + Interval: 5 + Content: + - '&bProfile&f:' + 7: + Interval: 20 + Content: + - ' &8- &7Rank&8: &fDefault' + '8': + Interval: 5 + Content: + - ' &8- &7Balance&8: &f$0' + '9': + Interval: -1 + Content: + - '' + 10: + Interval: -1 + Content: + - '&ewww.songoda.com' + Island: + Solo: + Empty: + Title: + Interval: 3 + Content: + - '&b&lSkyBlock' + - '&a&lS&b&lkyBlock' + - '&a&lSk&b&lyBlock' + - '&a&lSky&b&lBlock' + - '&a&lSkyB&b&llock' + - '&a&lSkyBl&b&lock' + - '&a&lSkyBlo&b&lck' + - '&a&lSkyBloc&b&lk' + - '&a&lSkyBlock' + - '&b&lS&a&lkyBlock' + - '&b&lSk&a&lyBlock' + - '&b&lSky&a&lBlock' + - '&b&lSkyB&a&llock' + - '&b&lSkyBl&a&lock' + - '&b&lSkyBlo&a&lck' + - '&b&lSkyBloc&a&lk' + Rows: + 1: + Interval: -1 + Content: + - '' + 2: + Interval: -1 + Content: + - '&bIsland&f:' + 3: + Interval: 5 + Content: + - ' &8- &7Level&8: &f%island_level%' + 4: + Interval: 20 + Content: + - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + 5: + Interval: -1 + Content: + - '' + 6: + Interval: 5 + Content: + - '&bProfile&f:' + 7: + Interval: 20 + Content: + - ' &8- &7Rank&8: &fDefault' + '8': + Interval: 5 + Content: + - ' &8- &7Balance&8: &f$0' + '9': + Interval: -1 + Content: + - '' + 10: + Interval: -1 + Content: + - '&ewww.songoda.com' + Occupied: + Title: + Interval: 3 + Content: + - '&b&lSkyBlock' + - '&a&lS&b&lkyBlock' + - '&a&lSk&b&lyBlock' + - '&a&lSky&b&lBlock' + - '&a&lSkyB&b&llock' + - '&a&lSkyBl&b&lock' + - '&a&lSkyBlo&b&lck' + - '&a&lSkyBloc&b&lk' + - '&a&lSkyBlock' + - '&b&lS&a&lkyBlock' + - '&b&lSk&a&lyBlock' + - '&b&lSky&a&lBlock' + - '&b&lSkyB&a&llock' + - '&b&lSkyBl&a&lock' + - '&b&lSkyBlo&a&lck' + - '&b&lSkyBloc&a&lk' + Rows: + 1: + Interval: -1 + Content: + - '' + 2: + Interval: -1 + Content: + - '&bIsland&f:' + 3: + Interval: 5 + Content: + - ' &8- &7Level&8: &f%island_level%' + 4: + Interval: 5 + Content: + - ' &8- &7Visitors&8: &f%island_visitors%' + 5: + Interval: 20 + Content: + - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + 6: + Interval: -1 + Content: + - '' + 7: + Interval: 5 + Content: + - '&bProfile&f:' + 8: + Interval: 20 + Content: + - ' &8- &7Rank&8: &fDefault' + '9': + Interval: 5 + Content: + - ' &8- &7Balance&8: &f$0' + '10': + Interval: -1 + Content: + - '' + 11: + Interval: -1 + Content: + - '&ewww.songoda.com' + Team: + Word: + Owner: 'Owner' + Operator: 'Operator' + Member: 'Member' + Empty: + Title: + Interval: 3 + Content: + - '&b&lSkyBlock' + - '&a&lS&b&lkyBlock' + - '&a&lSk&b&lyBlock' + - '&a&lSky&b&lBlock' + - '&a&lSkyB&b&llock' + - '&a&lSkyBl&b&lock' + - '&a&lSkyBlo&b&lck' + - '&a&lSkyBloc&b&lk' + - '&a&lSkyBlock' + - '&b&lS&a&lkyBlock' + - '&b&lSk&a&lyBlock' + - '&b&lSky&a&lBlock' + - '&b&lSkyB&a&llock' + - '&b&lSkyBl&a&lock' + - '&b&lSkyBlo&a&lck' + - '&b&lSkyBloc&a&lk' + Rows: + 1: + Interval: -1 + Content: + - '' + 2: + Interval: -1 + Content: + - '&bIsland&f:' + 3: + Interval: 20 + Content: + - ' &8- &7Role&8: &f%island_role%' + 4: + Interval: 20 + Content: + - ' &8- &7Members&8: &f%island_members%' + 5: + Interval: 5 + Content: + - ' &8- &7Level&8: &f%island_level%' + 6: + Interval: 20 + Content: + - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + 7: + Interval: -1 + Content: + - '' + 8: + Interval: 5 + Content: + - '&bProfile&f:' + 9: + Interval: 20 + Content: + - ' &8- &7Rank&8: &fDefault' + '10': + Interval: 5 + Content: + - ' &8- &7Balance&8: &f$0' + '11': + Interval: -1 + Content: + - '' + 12: + Interval: -1 + Content: + - '&ewww.songoda.com' + Occupied: + Title: + Interval: 3 + Content: + - '&b&lSkyBlock' + - '&a&lS&b&lkyBlock' + - '&a&lSk&b&lyBlock' + - '&a&lSky&b&lBlock' + - '&a&lSkyB&b&llock' + - '&a&lSkyBl&b&lock' + - '&a&lSkyBlo&b&lck' + - '&a&lSkyBloc&b&lk' + - '&a&lSkyBlock' + - '&b&lS&a&lkyBlock' + - '&b&lSk&a&lyBlock' + - '&b&lSky&a&lBlock' + - '&b&lSkyB&a&llock' + - '&b&lSkyBl&a&lock' + - '&b&lSkyBlo&a&lck' + - '&b&lSkyBloc&a&lk' + Rows: + 1: + Interval: -1 + Content: + - '' + 2: + Interval: -1 + Content: + - '&bIsland&f:' + 3: + Interval: 20 + Content: + - ' &8- &7Role&8: &f%island_role%' + 4: + Interval: 20 + Content: + - ' &8- &7Members&8: &f%island_members%' + 5: + Interval: 5 + Content: + - ' &8- &7Level&8: &f%island_level%' + 6: + Interval: 5 + Content: + - ' &8- &7Visitors&8: &f%island_visitors%' + 7: + Interval: 20 + Content: + - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + 8: + Interval: -1 + Content: + - '' + 9: + Interval: 5 + Content: + - '&bProfile&f:' + 10: + Interval: 20 + Content: + - ' &8- &7Rank&8: &fDefault' + '11': + Interval: 5 + Content: + - ' &8- &7Balance&8: &f$0' + '12': + Interval: -1 + Content: + - '' + 13: + Interval: -1 + Content: + - '&ewww.songoda.com' \ No newline at end of file From de965d030317535a8d911b61adaa3d7fdf75c684 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 11:51:09 +0200 Subject: [PATCH 315/366] Updated default placeholders in scoreboard --- src/main/resources/scoreboard.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/resources/scoreboard.yml b/src/main/resources/scoreboard.yml index ca925c49..e97546c6 100644 --- a/src/main/resources/scoreboard.yml +++ b/src/main/resources/scoreboard.yml @@ -96,11 +96,11 @@ Scoreboards: 3: Interval: 5 Content: - - ' &8- &7Level&8: &f%island_level%' + - ' &8- &7Level&8: &f%fabledskyblock_island_level_formatted%' 4: Interval: 20 Content: - - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + - ' &8- &7Size&8: &f%fabledskyblock_island_size%&7x&f%fabledskyblock_island_size%' 5: Interval: -1 Content: @@ -157,15 +157,15 @@ Scoreboards: 3: Interval: 5 Content: - - ' &8- &7Level&8: &f%island_level%' + - ' &8- &7Level&8: &f%fabledskyblock_island_level_formatted%' 4: Interval: 5 Content: - - ' &8- &7Visitors&8: &f%island_visitors%' + - ' &8- &7Visitors&8: &f%fabledskyblock_island_visitors%' 5: Interval: 20 Content: - - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + - ' &8- &7Size&8: &f%fabledskyblock_island_size%&7x&f%fabledskyblock_island_size%' 6: Interval: -1 Content: @@ -227,19 +227,19 @@ Scoreboards: 3: Interval: 20 Content: - - ' &8- &7Role&8: &f%island_role%' + - ' &8- &7Role&8: &f%fabledskyblock_island_role%' 4: Interval: 20 Content: - - ' &8- &7Members&8: &f%island_members%' + - ' &8- &7Members&8: &f%fabledskyblock_island_members%' 5: Interval: 5 Content: - - ' &8- &7Level&8: &f%island_level%' + - ' &8- &7Level&8: &f%fabledskyblock_island_level_formatted%' 6: Interval: 20 Content: - - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + - ' &8- &7Size&8: &f%fabledskyblock_island_size%&7x&f%fabledskyblock_island_size%' 7: Interval: -1 Content: @@ -296,23 +296,23 @@ Scoreboards: 3: Interval: 20 Content: - - ' &8- &7Role&8: &f%island_role%' + - ' &8- &7Role&8: &f%fabledskyblock_island_role%' 4: Interval: 20 Content: - - ' &8- &7Members&8: &f%island_members%' + - ' &8- &7Members&8: &f%fabledskyblock_island_members%' 5: Interval: 5 Content: - - ' &8- &7Level&8: &f%island_level%' + - ' &8- &7Level&8: &f%fabledskyblock_island_level_formatted%' 6: Interval: 5 Content: - - ' &8- &7Visitors&8: &f%island_visitors%' + - ' &8- &7Visitors&8: &f%fabledskyblock_island_visitors%' 7: Interval: 20 Content: - - ' &8- &7Size&8: &f%island_size%&7x&f%island_size%' + - ' &8- &7Size&8: &f%fabledskyblock_island_size%&7x&f%fabledskyblock_island_size%' 8: Interval: -1 Content: From c26b9b3f723baedd528572f83d0d534afafc84cf Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 12:22:37 +0200 Subject: [PATCH 316/366] Removed debugs and unused config --- .../skyblock/placeholder/PlaceholderProcessor.java | 9 ++++----- .../songoda/skyblock/scoreboard/ScoreboardManager.java | 4 ---- src/main/resources/scoreboard.yml | 4 ---- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java index 6ffb3e1f..2562ee92 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java @@ -26,6 +26,10 @@ import java.util.UUID; public class PlaceholderProcessor { public String processPlaceholder(Player player, String placeholder) { + if(player == null || placeholder == null) { + return ""; + } + SkyBlock plugin = SkyBlock.getInstance(); IslandManager islandManager = plugin.getIslandManager(); VisitManager visitManager = plugin.getVisitManager(); @@ -36,7 +40,6 @@ public class PlaceholderProcessor { new File(plugin.getDataFolder(), "placeholders.yml")).getFileConfiguration(); if(placeholdersLoad == null) { - Bukkit.broadcastMessage("ABC"); return "Error"; } @@ -44,10 +47,6 @@ public class PlaceholderProcessor { String returnValue = null; - if(player == null || placeholder == null) { - return ""; - } - switch (placeholder.toLowerCase()) { case "fabledskyblock_island_exists": if (island == null) { diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 92a7e36a..a365d3ec 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -82,7 +82,6 @@ public class ScoreboardManager extends Manager { } setPlayerScoreboard(player, type); - Bukkit.broadcastMessage(type.toString()); } } @@ -116,7 +115,6 @@ public class ScoreboardManager extends Manager { driver.runTaskTimer(plugin, 1L, 1L); } drivers.add(driver); - Bukkit.broadcastMessage("G " + drivers.size()); } public void clearDrivers() { @@ -128,12 +126,10 @@ public class ScoreboardManager extends Manager { public void setPlayerScoreboard(Player player, ScoreboardType type) { for(Driver driver : drivers) { if(driver.getBoardType().equals(type)) { - Bukkit.broadcastMessage("F"); driver.registerHolder(new Holder(plugin, driver, player)); } else { driver.unregisterHolder(player); } } - Bukkit.broadcastMessage(drivers.size() + ""); } } diff --git a/src/main/resources/scoreboard.yml b/src/main/resources/scoreboard.yml index e97546c6..543fde4a 100644 --- a/src/main/resources/scoreboard.yml +++ b/src/main/resources/scoreboard.yml @@ -191,10 +191,6 @@ Scoreboards: Content: - '&ewww.songoda.com' Team: - Word: - Owner: 'Owner' - Operator: 'Operator' - Member: 'Member' Empty: Title: Interval: 3 From c7c52ef555095fd03bbb7357fd4addd750936896 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 12:23:51 +0200 Subject: [PATCH 317/366] Fixed backup system --- .../com/songoda/skyblock/config/FileManager.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java index 3abd9501..e267af6b 100644 --- a/src/main/java/com/songoda/skyblock/config/FileManager.java +++ b/src/main/java/com/songoda/skyblock/config/FileManager.java @@ -48,7 +48,7 @@ public class FileManager { } // Will remain null unless WorldEdit is present. - File schematicsDirectory = null; + File schematicsDirectory; if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !(schematicsDirectory = new File(plugin.getDataFolder().toString() + "/schematics")).exists()) { schematicsDirectory.mkdir(); @@ -63,7 +63,7 @@ public class FileManager { configFiles.put("settings.yml", new File(plugin.getDataFolder(), "settings.yml")); configFiles.put("upgrades.yml", new File(plugin.getDataFolder(), "upgrades.yml")); configFiles.put("biomes.yml", new File(plugin.getDataFolder(), "biomes.yml")); - // configFiles.put("menus.yml", new File(skyblock.getDataFolder(), "menus.yml")); + // configFiles.put("menus.yml", new File(plugin.getDataFolder(), "menus.yml")); configFiles.put("scoreboard.yml", new File(plugin.getDataFolder(), "scoreboard.yml")); configFiles.put("placeholders.yml", new File(plugin.getDataFolder(), "placeholders.yml")); configFiles.put("generators.yml", new File(plugin.getDataFolder(), "generators.yml")); @@ -107,7 +107,7 @@ public class FileManager { fileName.equals("placeholders.yml")) { FileChecker fileChecker; - if (fileName.equals("config.yml") || fileName.equals("biomes.yml") || fileName.equals("scoreboard.yml")) { + if (fileName.equals("config.yml") || fileName.equals("biomes.yml")) { fileChecker = new FileChecker(plugin, this, fileName, true); } else { fileChecker = new FileChecker(plugin, this, fileName, false); @@ -178,20 +178,20 @@ public class FileManager { } public void backupIfNeeded() { - File languageFile = new File(plugin.getDataFolder().toString() + "language.yml"); - File scoreboardFile = new File(plugin.getDataFolder().toString() + "scoreboard.yml"); - File placeholderFile = new File(plugin.getDataFolder().toString() + "placeholders.yml"); + File languageFile = new File(plugin.getDataFolder(), "language.yml"); + File scoreboardFile = new File(plugin.getDataFolder(), "scoreboard.yml"); + File placeholderFile = new File(plugin.getDataFolder(), "placeholders.yml"); if(languageFile.exists() && (!scoreboardFile.exists() || !placeholderFile.exists())) { File backupDir = new File(plugin.getDataFolder().toString() + "/backup"); if(!backupDir.exists()) { backupDir.mkdir(); } - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy-HH:mm:ss"); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MM-yyyy_HH-mm-ss"); LocalDateTime now = LocalDateTime.now(); Path oldLanguagePath = languageFile.toPath(); - Path newLanguagePath = new File(plugin.getDataFolder().toString() + "/backup/language" + dtf.format(now) + ".yml").toPath(); + Path newLanguagePath = new File(plugin.getDataFolder().toString() + "/backup", "language" + dtf.format(now) + ".yml").toPath(); CopyOption[] options = new CopyOption[]{ StandardCopyOption.REPLACE_EXISTING, From 70931439b43cd3f16576ce34bd1de21a94ba1a4f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 12:38:43 +0200 Subject: [PATCH 318/366] Fixed title in coop gui --- src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java index b7e28fa8..c3c901d2 100644 --- a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java +++ b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoop.java @@ -80,8 +80,7 @@ public class GuiCoop extends Gui { guiManager.showGUI(event.player, new GuiCoopChoose(plugin, island, e.gui.getParent(), playerName)); })); gui.setTitle(TextUtils.formatText( - languageLoad.getString("Menu.Coop.Item.Word.Normal") + - " / " + languageLoad.getString("Menu.Coop.Item.Word.Temp"))); + languageLoad.getString("Menu.Coop.Item.Word.Enter"))); guiManager.showGUI(event.player, gui); } else { messageManager.sendMessage(event.player, From c5dbeca38d94ee332e679bbaa05b2ccae84de8d4 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 14:30:06 +0200 Subject: [PATCH 319/366] Added last placeholders --- .../placeholder/PlaceholderProcessor.java | 447 +++++++++++------- src/main/resources/placeholders.yml | 209 +++----- 2 files changed, 359 insertions(+), 297 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java index 2562ee92..31093bf2 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java @@ -1,25 +1,25 @@ package com.songoda.skyblock.placeholder; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.invite.Invite; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.island.IslandStatus; +import com.songoda.skyblock.island.*; import com.songoda.skyblock.leaderboard.Leaderboard; import com.songoda.skyblock.leaderboard.LeaderboardManager; import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.upgrade.Upgrade; import com.songoda.skyblock.utils.NumberUtil; +import com.songoda.skyblock.utils.player.OfflinePlayer; +import com.songoda.skyblock.visit.Visit; import com.songoda.skyblock.visit.VisitManager; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -34,6 +34,7 @@ public class PlaceholderProcessor { IslandManager islandManager = plugin.getIslandManager(); VisitManager visitManager = plugin.getVisitManager(); IslandLevelManager levellingManager = plugin.getLevellingManager(); + LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); FileManager fileManager = plugin.getFileManager(); FileConfiguration placeholdersLoad = fileManager.getConfig( @@ -50,45 +51,66 @@ public class PlaceholderProcessor { switch (placeholder.toLowerCase()) { case "fabledskyblock_island_exists": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Not-exists.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Not-exists")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Exists.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Exists")); } break; - case "fabledskyblock_island_isopen": + case "fabledskyblock_island_isopen": //Deprecated if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Empty")); } else { - if (island.getStatus().equals(IslandStatus.OPEN)) { // TODO Update to Status - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Open.Message")); + if (island.getStatus().equals(IslandStatus.OPEN)) { + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Open")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Closed.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Closed")); + } + } + break; + case "fabledskyblock_island_status": + if (island == null) { + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Empty")); + } else { + switch(island.getStatus()){ + case OPEN: + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Open")); + break; + case CLOSED: + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Closed")); + break; + case WHITELISTED: + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Whitelisted")); + break; } } break; case "fabledskyblock_island_size": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Non-empty.Message") - .replace("%placeholder", "" + island.getSize())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getSize())); } break; case "fabledskyblock_island_radius": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Non-empty.Message") - .replace("%placeholder", "" + island.getRadius())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getRadius())); } break; case "fabledskyblock_island_level": @@ -96,12 +118,12 @@ public class PlaceholderProcessor { break; case "fabledskyblock_island_level_formatted": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Non-empty.Message").replace( - "%placeholder", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel()))); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Non-empty").replace( + "{PLACEHOLDER}", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel()))); } break; case "fabledskyblock_island_points": @@ -109,168 +131,168 @@ public class PlaceholderProcessor { break; case "fabledskyblock_island_votes": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Non-empty.Message") - .replace("%placeholder", "" + visitManager.getIslands().get(player.getUniqueId()).getVoters().size())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Non-empty") + .replace("{PLACEHOLDER}", "" + visitManager.getIslands().get(player.getUniqueId()).getVoters().size())); } break; case "fabledskyblock_island_role": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Empty")); } else { for (IslandRole roleList : IslandRole.values()) { if (island.hasRole(roleList, player.getUniqueId())) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Non-empty.Message") - .replace("%placeholder", plugin.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList))); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Non-empty") + .replace("{PLACEHOLDER}", plugin.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList))); } } } break; case "fabledskyblock_island_owner": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Empty")); } else { UUID islandOwnerUUID = island.getOwnerUUID(); Player targetPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID); if (targetPlayer == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other.Message").replace( - "%placeholder", Bukkit.getServer().getOfflinePlayer(islandOwnerUUID).getName())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other").replace( + "{PLACEHOLDER}", Bukkit.getServer().getOfflinePlayer(islandOwnerUUID).getName())); } else { if (targetPlayer.getName().equals(player.getName())) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Yourself.Message") - .replace("%placeholder", targetPlayer.getName())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Yourself") + .replace("{PLACEHOLDER}", targetPlayer.getName())); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other.Message") - .replace("%placeholder", targetPlayer.getName())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other") + .replace("{PLACEHOLDER}", targetPlayer.getName())); } } } break; case "fabledskyblock_island_biome": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Non-empty.Message") - .replace("%placeholder", island.getBiomeName())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Non-empty") + .replace("{PLACEHOLDER}", island.getBiomeName())); } break; case "fabledskyblock_island_time": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Non-empty.Message") - .replace("%placeholder", "" + island.getTime())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getTime())); } break; case "fabledskyblock_island_weather": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Non-empty.Message") - .replace("%placeholder", "" + island.getWeatherName())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getWeatherName())); } break; case "fabledskyblock_island_bans": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Non-empty.Message") - .replace("%placeholder", "" + island.getBan().getBans().size())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getBan().getBans().size())); } break; case "fabledskyblock_island_members_total": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Non-empty.Message") - .replace("%placeholder", "" + (island.getRole(IslandRole.Member).size() + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Non-empty") + .replace("{PLACEHOLDER}", "" + (island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1))); } break; case "fabledskyblock_island_members": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_members.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_members.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty.Message") - .replace("%placeholder", "" + island.getRole(IslandRole.Member).size())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getRole(IslandRole.Member).size())); } break; case "fabledskyblock_island_maxmembers": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Non-empty.Message") - .replace("%placeholder", "" + island.getMaxMembers())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getMaxMembers())); } break; case "fabledskyblock_island_operators": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Non-empty.Message") - .replace("%placeholder", "" + island.getRole(IslandRole.Operator).size())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getRole(IslandRole.Operator).size())); } break; case "fabledskyblock_island_coops": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Non-empty.Message") - .replace("%placeholder", "" + islandManager.getCoopPlayersAtIsland(island).size())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Non-empty") + .replace("{PLACEHOLDER}", "" + islandManager.getCoopPlayersAtIsland(island).size())); } break; case "fabledskyblock_island_coops_total": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Non-empty.Message") - .replace("%placeholder", "" + island.getCoopPlayers().size())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Non-empty") + .replace("{PLACEHOLDER}", "" + island.getCoopPlayers().size())); } break; case "fabledskyblock_island_visitors": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Non-empty.Message") - .replace("%placeholder", "" + islandManager.getVisitorsAtIsland(island).size())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Non-empty") + .replace("{PLACEHOLDER}", "" + islandManager.getVisitorsAtIsland(island).size())); } break; case "fabledskyblock_island_invites": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Empty")); } else { Map invites = plugin.getInviteManager().getInvites(); int invitedPlayers = 0; @@ -284,112 +306,213 @@ public class PlaceholderProcessor { } } - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Non-empty.Message") - .replace("%placeholder", "" + invitedPlayers)); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Non-empty") + .replace("{PLACEHOLDER}", "" + invitedPlayers)); } break; case "fabledskyblock_island_bank_balance": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Non-empty.Message")) - .replace("%placeholder", "" + NumberUtil.formatNumberByDecimal(island.getBankBalance())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Non-empty")) + .replace("{PLACEHOLDER}", "" + NumberUtil.formatNumberByDecimal(island.getBankBalance())); } break; case "fabledskyblock_island_bank_balance_formatted": if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Empty")); } else { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Non-empty.Message")) - .replace("%placeholder", "" + NumberUtil.formatNumberBySuffix((long) island.getBankBalance())); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Non-empty")) + .replace("{PLACEHOLDER}", "" + NumberUtil.formatNumberBySuffix((long) island.getBankBalance())); } break; } if(returnValue == null) { - if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) { - if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty.Message")); + if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_votes_")){ + List leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes); + + String[] values = placeholder.split("_"); + int value; + try { + value = Integer.parseInt(values[values.length-1]); + } catch(NumberFormatException ignored) { + value = 1; + } + + if (value > 0 && value < leaderboardVotesPlayers.size()) { + Leaderboard leaderboard = leaderboardVotesPlayers.get(value); + Visit visit = leaderboard.getVisit(); + + Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); + String islandOwnerName; + + if (targetPlayer == null) { + islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); + } else { + islandOwnerName = targetPlayer.getName(); + } + + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Non-empty") + .replace("{POSITION}", "" + (value)) + .replace("{PLAYER}", islandOwnerName) + .replace("{VOTES}", NumberUtil.formatNumberByDecimal(visit.getVoters().size()))); + } else { + + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty")); + } + } else if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_bank_")){ + List leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank); + + String[] values = placeholder.split("_"); + int value; + try { + value = Integer.parseInt(values[values.length-1]); + } catch(NumberFormatException ignored) { + value = 1; + } + + if (value > 0 && value < leaderboardBankPlayers.size()) { + Leaderboard leaderboard = leaderboardBankPlayers.get(value); + Visit visit = leaderboard.getVisit(); + + Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); + String islandOwnerName; + + if (targetPlayer == null) { + islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); + } else { + islandOwnerName = targetPlayer.getName(); + } + + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty") + .replace("{POSITION}", "" + (value)) + .replace("{PLAYER}", islandOwnerName) + .replace("{BALANCE}", NumberUtil.formatNumberByDecimal(visit.getBankBalance()))); + } else { + + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty")); + } + } else if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_level_")){ + List leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level); + + String[] values = placeholder.split("_"); + int value; + try { + value = Integer.parseInt(values[values.length-1]); + } catch(NumberFormatException ignored) { + value = 1; + } + + if (value > 0 && value < leaderboardLevelPlayers.size()) { + Leaderboard leaderboard = leaderboardLevelPlayers.get(value); + Visit visit = leaderboard.getVisit(); + IslandLevel level = visit.getLevel(); + + Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID()); + String islandOwnerName; + + if (targetPlayer == null) { + islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName(); + } else { + islandOwnerName = targetPlayer.getName(); + } + + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Non-empty") + .replace("{POSITION}", "" + (value)) + .replace("{PLAYER}", islandOwnerName) + .replace("{LEVEL}", NumberUtil.formatNumberByDecimal(level.getLevel())) + .replace("{POINTS}", NumberUtil.formatNumberByDecimal(level.getPoints()))); + } else { + + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Empty")); + } + } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) { + if (island == null) { + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty")); } else { - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level); - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty.Message") - .replace("%placeholder", "" + rank)); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty") + .replace("{PLACEHOLDER}", "" + rank)); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_bank_rank")) { if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty")); } else { - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank); - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty.Message") - .replace("%placeholder", "" + rank)); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty") + .replace("{PLACEHOLDER}", "" + rank)); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) { if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty")); } else { - LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes); - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty.Message") - .replace("%placeholder", "" + rank)); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty") + .replace("{PLACEHOLDER}", "" + rank)); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) { if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Empty")); } else { String materialName = placeholder.replace("fabledskyblock_island_level_block_count_", "").toUpperCase(); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); if (materials == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Invalid.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Invalid")); } else { long blockCount = island.getLevel().getMaterialAmount(materials.name()); - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Non-empty.Message") - .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockCount))); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Non-empty") + .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockCount))); } } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_points_")) { if (island == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Empty.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Empty")); } else { String materialName = placeholder.replace("fabledskyblock_island_level_block_points_", "").toUpperCase(); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); if (materials == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Invalid.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Invalid")); } else { long blockPoints = island.getLevel().getMaterialPoints(materials.name()); - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Non-empty.Message") - .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockPoints))); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Non-empty") + .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockPoints))); } } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_level_block_value_")) { String materialName = placeholder.replace("fabledskyblock_level_block_value_", "").toUpperCase(); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); if (materials == null) { - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid.Message")); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid")); } else { double blockValue = levellingManager.getWorth(materials); - returnValue = ChatColor.translateAlternateColorCodes('&', - placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty.Message") - .replace("%placeholder", NumberUtil.formatNumberByDecimal(blockValue))); + returnValue = TextUtils.formatText( + placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty") + .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockValue))); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_has_upgrade_")) { Upgrade.Type type; diff --git a/src/main/resources/placeholders.yml b/src/main/resources/placeholders.yml index 46d2d601..43e69773 100644 --- a/src/main/resources/placeholders.yml +++ b/src/main/resources/placeholders.yml @@ -1,165 +1,104 @@ Placeholders: fabledskyblock_leaderboard_votes: - Empty: - Message: 'Unclaimed' - Non-empty: - Message: '[%position] %player [%votes]' + Empty: 'Unclaimed' + Non-empty: '[{POSITION}] {PLAYER} [{VOTES]' fabledskyblock_leaderboard_bank: - Empty: - Message: 'Unclaimed' - Non-empty: - Message: '[%position] %player [$%balance]' - fabledskyblock_island_exists: - Exists: - Message: 'true' - Not-exists: - Message: 'false' - fabledskyblock_island_members: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' - fabledskyblock_island_coops: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: 'Unclaimed' + Non-empty: '[{POSITION}] {PLAYER} [${BALANCE}]' fabledskyblock_leaderboard_level: - Empty: - Message: 'Unclaimed' - Non-empty: - Message: '[%position] %player [%level]' + Empty: 'Unclaimed' + Non-empty: '[{POSITION}] {PLAYER} [{LEVEL}]' + fabledskyblock_island_exists: + Exists: 'true' + Not-exists: 'false' + fabledskyblock_island_members: + Non-empty: '{PLACEHOLDER}' + Empty: '0' + fabledskyblock_island_coops: + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_visitors: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_size: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_maxmembers: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_time: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_bank_balance_formatted: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: 0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_owner: Non-empty: - Yourself: - Message: 'You' - Other: - Message: '%placeholder' - Empty: - Message: '&oNone' + Yourself: 'You' + Other: '{PLACEHOLDER}' + Empty: '&oNone' fabledskyblock_island_leaderboard_bank_rank: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_bans: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_coops_total: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_invites: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_level_block_count: - Invalid: - Message: 'Invalid Type' - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Invalid: 'Invalid Type' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_weather: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_role: - Empty: - Message: '&oNone' - Non-empty: - Message: '%placeholder' + Empty: '&oNone' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_operators: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_bank_balance: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_biome: - Empty: - Message: '&oNone' - Non-empty: - Message: '%placeholder' + Empty: '&oNone' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_level_formatted: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_members_total: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_island_level_block_points: - Empty: - Message: '0' - Invalid: - Message: 'Invalid Type' - Non-empty: - Message: '%placeholder' + Empty: '0' + Invalid: 'Invalid Type' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_isopen: - Closed: - Message: 'false' - Open: - Message: 'true' - Empty: - Message: 'false' + Closed: 'false' + Open: 'true' + Empty: 'false' + fabledskyblock_island_status: + Closed: 'Closed' + Open: 'Open' + Whitelisted: 'Whitelisted' + Empty: 'None' fabledskyblock_island_votes: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_radius: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' + Empty: '0' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_leaderboard_votes_rank: - Non-empty: - Message: '%placeholder' - Empty: - Message: '0' + Non-empty: '{PLACEHOLDER}' + Empty: '0' fabledskyblock_level_block_value: - Invalid: - Message: 'Invalid Type' - Non-empty: - Message: '%placeholder' + Invalid: 'Invalid Type' + Non-empty: '{PLACEHOLDER}' fabledskyblock_island_leaderboard_level_rank: - Empty: - Message: '0' - Non-empty: - Message: '%placeholder' \ No newline at end of file + Empty: '0' + Non-empty: '{PLACEHOLDER}' \ No newline at end of file From 9c1b18f4be67629a690767b849d39b5a40c64f80 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 14:38:58 +0200 Subject: [PATCH 320/366] Do not use vault if owner is online --- .../com/songoda/skyblock/listeners/Block.java | 123 ++++++++++-------- 1 file changed, 67 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index ab9afc86..ff4338ec 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -474,46 +474,50 @@ public class Block implements Listener { if(!possiblePlayers.isEmpty()){ boolean nearestPlayer = configLoad.getBoolean("Island.Generator.CheckOnlyNearestPlayer", false); - + double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation()); + boolean onlyOwner = configLoad.getBoolean("Island.Generator.CheckOnlyOwnerPermissions", false); + if(nearestPlayer){ possiblePlayers.sort(Comparator.comparingDouble(a -> a.getLocation().distance(block.getLocation()))); } - boolean onlyOwner = configLoad.getBoolean("Island.Generator.CheckOnlyOwnerPermissions", false); - - double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation()); // Find highest generator available for (Generator generator : generators) { if(island.getLevel().getLevel() >= generator.getLevel()) { if(onlyOwner && plugin.getVaultPermission() != null) { OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); - event.setCancelled(true); - org.bukkit.World finalWorld = event.getBlock().getWorld(); - this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone())); - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || - plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || - plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { - Bukkit.getScheduler().runTask(plugin, () -> { - this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone())); - if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ - BlockState genState = generatorManager.generateBlock(generator, block); - block.setType(genState.getType()); - - if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { - BlockState tempState = block.getState(); - tempState.setData(genState.getData()); - tempState.update(true, true); - } - islandLevelManager.updateLevel(island, genState.getLocation()); - } - }); - } else { - Bukkit.getScheduler().runTask(plugin, () -> { - block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); - }); + if(owner.isOnline()) { + Player onlineOwner = (Player) owner; + if(onlineOwner.hasPermission(generator.getPermission())) { + applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator); } - }); + } else { + event.setCancelled(true); + org.bukkit.World finalWorld = event.getBlock().getWorld(); + this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone())); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission())) { + Bukkit.getScheduler().runTask(plugin, () -> { + this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone())); + if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ + BlockState genState = generatorManager.generateBlock(generator, block); + block.setType(genState.getType()); + + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { + BlockState tempState = block.getState(); + tempState.setData(genState.getData()); + tempState.update(true, true); + } + islandLevelManager.updateLevel(island, genState.getLocation()); + } + }); + } else { + Bukkit.getScheduler().runTask(plugin, () -> { + block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); + }); + } + }); + } } else { for (Player player : possiblePlayers) { if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){ @@ -766,33 +770,40 @@ public class Block implements Listener { if(island.getLevel().getLevel() >= generator.getLevel()) { if(onlyOwner && plugin.getVaultPermission() != null) { OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()); - event.setCancelled(true); - org.bukkit.World finalWorld = event.getBlock().getWorld(); - this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone())); - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || - plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || - plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { - Bukkit.getScheduler().runTask(plugin, () -> { - this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone())); - if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){ - BlockState genState = generatorManager.generateBlock(generator, block); - block.setType(genState.getType()); - - if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { - BlockState tempState = block.getState(); - tempState.setData(genState.getData()); - tempState.update(true, true); - } - islandLevelManager.updateLevel(island, genState.getLocation()); - } - }); - } else { - Bukkit.getScheduler().runTask(plugin, () -> { - block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); - }); + if(owner.isOnline()) { + Player onlineOwner = (Player) owner; + if(onlineOwner.hasPermission(generator.getPermission())) { + applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator); } - }); + } else { + event.setCancelled(true); + org.bukkit.World finalWorld = event.getBlock().getWorld(); + this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone())); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + if (plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") || + plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) { + Bukkit.getScheduler().runTask(plugin, () -> { + this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone())); + if (worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())) { + BlockState genState = generatorManager.generateBlock(generator, block); + block.setType(genState.getType()); + + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) { + BlockState tempState = block.getState(); + tempState.setData(genState.getData()); + tempState.update(true, true); + } + islandLevelManager.updateLevel(island, genState.getLocation()); + } + }); + } else { + Bukkit.getScheduler().runTask(plugin, () -> { + block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()); + }); + } + }); + } } else { for (Player player : possiblePlayers) { if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){ From bbca6703f5f8fe5dcbc5be3985117410e9475169 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 15:02:51 +0200 Subject: [PATCH 321/366] Small improvements --- src/main/java/com/songoda/skyblock/island/Island.java | 2 +- src/main/java/com/songoda/skyblock/island/IslandManager.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 6c9cde9c..4daf712c 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -369,7 +369,7 @@ public class Island { public Location getLocation(IslandWorld world, IslandEnvironment environment) { for (IslandLocation islandLocationList : islandLocations) { - if (islandLocationList.getWorld() == world && islandLocationList.getEnvironment() == environment) { + if (islandLocationList.getWorld().equals(world) && islandLocationList.getEnvironment().equals(environment)) { return islandLocationList.getLocation(); } } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 65926109..4b9c73d6 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1194,8 +1194,8 @@ public class IslandManager { } } else { if (scoreboardManager != null) { - int islandVisitors = getVisitorsAtIsland(island).size(), islandMembers = island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1; - + int islandVisitors = getVisitorsAtIsland(island).size(); + if (islandVisitors == 0) { for (Player loopPlayer : Bukkit.getOnlinePlayers()) { PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(loopPlayer); From 528286857936d6bd529495c7d04d9dba71cdd7b5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 15:07:13 +0200 Subject: [PATCH 322/366] Extracted config from utils --- .../commands/island/TeleportCommand.java | 5 +- .../skyblock/island/IslandManager.java | 9 ++-- .../com/songoda/skyblock/listeners/Move.java | 24 ++++++--- .../songoda/skyblock/listeners/Portal.java | 13 +++-- .../listening/PortalPermission.java | 11 ++-- .../skyblock/utils/world/LocationUtil.java | 52 ++++++++----------- 6 files changed, 64 insertions(+), 50 deletions(-) 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 d7729be9..edd311e4 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 @@ -116,7 +116,10 @@ public class TeleportCommand extends SubCommand { Bukkit.getServer().getScheduler().runTask(plugin, () -> { Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); PaperLib.getChunkAtAsync(loc).thenRun((() -> { - LocationUtil.removeWaterFromLoc(plugin, loc); + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.RemoveWater", false)) { + LocationUtil.removeWaterFromLoc(loc); + } PaperLib.teleportAsync(player, loc); })); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 4b9c73d6..07d1e06a 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1210,9 +1210,12 @@ public class IslandManager { } Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor); if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - Location safeLoc = LocationUtil.getSafeLocation(plugin, loc); - if(safeLoc != null){ - loc = safeLoc; + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { + Location safeLoc = LocationUtil.getSafeLocation(loc); + if (safeLoc != null) { + loc = safeLoc; + } } } if(loc != null){ diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java index a025a08a..0348cc11 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Move.java +++ b/src/main/java/com/songoda/skyblock/listeners/Move.java @@ -203,19 +203,29 @@ public class Move implements Listener { 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)) { - Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(world, IslandEnvironment.Main)); - if(safeLoc != null){ - loc = safeLoc; + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { + Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main)); + if (safeLoc != null) { + loc = safeLoc; + } } } else { loc = island.getLocation(world, IslandEnvironment.Main); - LocationUtil.removeWaterFromLoc(plugin, loc); + + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.RemoveWater", false)) { + LocationUtil.removeWaterFromLoc(loc); + } } } else { if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) { - Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(world, IslandEnvironment.Visitor)); - if(safeLoc != null){ - loc = safeLoc; + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { + Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor)); + if (safeLoc != null) { + loc = safeLoc; + } } } else { loc = island.getLocation(world, IslandEnvironment.Visitor); diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java index f946320e..812d8d20 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Portal.java +++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java @@ -163,13 +163,12 @@ public class Portal implements Listener { IslandWorld toWorldF = toWorld; Bukkit.getScheduler().runTaskLater(plugin, () -> { Location loc = island.getLocation(toWorldF, spawnEnvironment); - Location tempSafeLoc = LocationUtil.getSafeLocation(plugin, loc); - Location safeLoc = null; - if(tempSafeLoc != null) { - safeLoc = tempSafeLoc; - } - if(safeLoc != null){ - loc = safeLoc; + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { + Location safeLoc = LocationUtil.getSafeLocation(loc); + if (safeLoc != null) { + loc = safeLoc; + } } Location finalLoc = loc; PaperLib.teleportAsync(player, finalLoc); diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java index e7dd02be..231a2c50 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/PortalPermission.java @@ -15,6 +15,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import java.io.File; + public class PortalPermission extends ListeningPermission { private final SkyBlock plugin; @@ -71,9 +73,12 @@ public class PortalPermission extends ListeningPermission { Island island = islandManager.getIslandAtLocation(from); Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main); if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){ - Location safeLoc = LocationUtil.getSafeLocation(plugin, island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); - if(safeLoc != null) { - to = safeLoc; + if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { + Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor)); + if (safeLoc != null) { + to = safeLoc; + } } if(to == null){ to = LocationUtil.getSpawnLocation(); 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 d4fe07d4..4221ddc9 100644 --- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java @@ -33,41 +33,35 @@ 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.clone()); - if(tempLoc.getBlock().getType().equals(Material.WATER)){ - tempLoc.getBlock().setType(Material.AIR); - } else if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ - LocationUtil113.removeWaterLoggedFromLocation(tempLoc); - } + public static void removeWaterFromLoc(Location loc) { + Location tempLoc = LocationUtil.getDefinitiveLocation(loc.clone()); + if(tempLoc.getBlock().getType().equals(Material.WATER)){ + tempLoc.getBlock().setType(Material.AIR); + } else if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ + LocationUtil113.removeWaterLoggedFromLocation(tempLoc); } } - public static @Nullable Location getSafeLocation(SkyBlock plugin, @Nonnull Location loc){ + public static @Nullable Location getSafeLocation(@Nonnull Location loc){ Location locChecked = null; - if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")) - .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) { - boolean found = false; - if(loc.getWorld() != null){ - 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); + boolean found = false; + if(loc.getWorld() != null){ + 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){ - 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; - } + } + if (found) { + locChecked = locChecked.add(0d,1d,0d); + } else { + locChecked = null; } } return locChecked; From b4db3f4bf6488fc4cdb2e510ac28d6a36d0d6de7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 15:10:38 +0200 Subject: [PATCH 323/366] Removed old Coop menu --- .../java/com/songoda/skyblock/menus/Coop.java | 275 ------------------ 1 file changed, 275 deletions(-) delete mode 100644 src/main/java/com/songoda/skyblock/menus/Coop.java diff --git a/src/main/java/com/songoda/skyblock/menus/Coop.java b/src/main/java/com/songoda/skyblock/menus/Coop.java deleted file mode 100644 index cd81115e..00000000 --- a/src/main/java/com/songoda/skyblock/menus/Coop.java +++ /dev/null @@ -1,275 +0,0 @@ -package com.songoda.skyblock.menus; - -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.CompatibleSound; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandCoop; -import com.songoda.skyblock.island.IslandManager; -import com.songoda.skyblock.island.IslandRole; -import com.songoda.skyblock.message.MessageManager; -import com.songoda.skyblock.permission.PermissionManager; -import com.songoda.skyblock.placeholder.Placeholder; -import com.songoda.skyblock.playerdata.PlayerData; -import com.songoda.skyblock.playerdata.PlayerDataManager; -import com.songoda.skyblock.sound.SoundManager; -import com.songoda.skyblock.utils.AbstractAnvilGUI; -import com.songoda.skyblock.utils.item.SkullUtil; -import com.songoda.skyblock.utils.item.nInventoryUtil; -import com.songoda.skyblock.utils.player.OfflinePlayer; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.io.File; -import java.util.Map; -import java.util.UUID; - -public class Coop { - - private static Coop instance; - - public static Coop getInstance() { - if (instance == null) { - instance = new Coop(); - } - - return instance; - } - - public void open(Player player) { - SkyBlock plugin = SkyBlock.getInstance(); - - PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); - MessageManager messageManager = plugin.getMessageManager(); - IslandManager islandManager = plugin.getIslandManager(); - PermissionManager permissionManager = plugin.getPermissionManager(); - SoundManager soundManager = plugin.getSoundManager(); - FileManager fileManager = plugin.getFileManager(); - - if (playerDataManager.hasPlayerData(player)) { - Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - String normal = configLoad.getString("Menu.Coop.Item.Word.Normal"); - String temp = configLoad.getString("Menu.Coop.Item.Word.Temp"); - - nInventoryUtil nInv = new nInventoryUtil(player, event -> { - if (playerDataManager.hasPlayerData(player)) { - PlayerData playerData = playerDataManager.getPlayerData(player); - Island island = islandManager.getIsland(player); - - if (island == null) { - messageManager.sendMessage(player, - configLoad.getString("Command.Island.Coop.Owner.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - - return; - } else if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) - .getFileConfiguration().getBoolean("Island.Coop.Enable")) { - messageManager.sendMessage(player, - configLoad.getString("Command.Island.Coop.Disabled.Message")); - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - - return; - } - - ItemStack is = event.getItem(); - - if ((is.getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial()) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Coop.Item.Barrier.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F); - - event.setWillClose(false); - event.setWillDestroy(false); - } else if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Coop.Item.Exit.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F); - player.closeInventory(); - } else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Coop.Item.Information.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { - AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> { - if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { - - AbstractAnvilGUI gui2 = new AbstractAnvilGUI(player, event2 -> { - if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) { - Bukkit.getServer().dispatchCommand(player, - "island coop " + event1.getName() + " " + event2.getName()); - - event2.setWillClose(true); - event2.setWillDestroy(true); - } else { - event2.setWillClose(false); - event2.setWillDestroy(false); - } - }); - - ItemStack is1 = new ItemStack(Material.NAME_TAG); - ItemMeta im = is1.getItemMeta(); - im.setDisplayName(normal + "/" + temp); - is1.setItemMeta(im); - - gui2.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is1); - gui2.open(); - - event1.setWillClose(false); - event1.setWillDestroy(false); - } else { - event1.setWillClose(false); - event1.setWillDestroy(false); - } - }); - - ItemStack is1 = new ItemStack(Material.NAME_TAG); - ItemMeta im = is1.getItemMeta(); - im.setDisplayName(configLoad.getString("Menu.Coop.Item.Word.Enter")); - is1.setItemMeta(im); - - gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is1); - gui.open(); - }, 1L); - } else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta()) - && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Coop.Item.Nothing.Displayname"))))) { - soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); - - event.setWillClose(false); - event.setWillDestroy(false); - } else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) { - if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Coop.Item.Previous.Displayname")))) { - playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) - 1); - soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); - } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes( - '&', configLoad.getString("Menu.Coop.Item.Next.Displayname")))) { - playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) + 1); - soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F); - - Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L); - } else { - if ((island.hasRole(IslandRole.Operator, player.getUniqueId()) - && permissionManager.hasPermission(island, "CoopPlayers", IslandRole.Operator)) - || island.hasRole(IslandRole.Owner, player.getUniqueId())) { - - String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName()); - - int space = playerName.indexOf(" "); - - if(space != -1) playerName = playerName.substring(0, space); - - Bukkit.getServer().dispatchCommand(player, "island coop " + playerName); - - Bukkit.getServer().getScheduler().runTaskLater(plugin, - () -> open(player), 3L); - } else { - messageManager.sendMessage(player, - configLoad.getString("Command.Island.Coop.Permission.Message")); - soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); - - event.setWillClose(false); - event.setWillDestroy(false); - } - } - } - } - }); - - PlayerData playerData = playerDataManager.getPlayerData(player); - Island island = islandManager.getIsland(player); - - Map coopPlayers = island.getCoopPlayers(); - - int playerMenuPage = playerData.getPage(MenuType.COOP), nextEndIndex = coopPlayers.size() - playerMenuPage * 36; - - nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), - configLoad.getString("Menu.Coop.Item.Exit.Displayname"), null, null, null, null), 0, 8); - nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), - configLoad.getString("Menu.Coop.Item.Information.Displayname"), - configLoad.getStringList("Menu.Coop.Item.Information.Lore"), - new Placeholder[]{new Placeholder("%coops", "" + coopPlayers.size())}, null, null), 4); - nInv.addItem( - nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), - configLoad.getString("Menu.Coop.Item.Barrier.Displayname"), null, null, null, null), - 9, 10, 11, 12, 13, 14, 15, 16, 17); - - if (playerMenuPage != 1) { - nInv.addItem(nInv.createItem(SkullUtil.create( - "ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", - "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), - configLoad.getString("Menu.Coop.Item.Previous.Displayname"), null, null, null, null), 1); - } - - if (!(nextEndIndex == 0 || nextEndIndex < 0)) { - nInv.addItem(nInv.createItem(SkullUtil.create( - "wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", - "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), - configLoad.getString("Menu.Coop.Item.Next.Displayname"), null, null, null, null), 7); - } - - if (coopPlayers.size() == 0) { - nInv.addItem( - nInv.createItem(new ItemStack(Material.BARRIER), - configLoad.getString("Menu.Coop.Item.Nothing.Displayname"), null, null, null, null), - 31); - } else { - int index = playerMenuPage * 36 - 36, - endIndex = index >= coopPlayers.size() ? coopPlayers.size() - 1 : index + 36, - inventorySlot = 17; - - for (; index < endIndex; index++) { - if (coopPlayers.size() > index) { - inventorySlot++; - - UUID targetPlayerUUID = (UUID) coopPlayers.keySet().toArray()[index]; - IslandCoop type = (IslandCoop) coopPlayers.values().toArray()[index]; - String targetPlayerName; - String[] targetPlayerTexture; - - Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID); - - if (targetPlayer == null) { - OfflinePlayer offlinePlayer = new OfflinePlayer(targetPlayerUUID); - targetPlayerName = offlinePlayer.getName(); - targetPlayerTexture = offlinePlayer.getTexture(); - } else { - targetPlayerName = targetPlayer.getName(); - - if (playerDataManager.hasPlayerData(targetPlayer)) { - targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture(); - } else { - targetPlayerTexture = new String[]{null, null}; - } - } - - nInv.addItem(nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), - ChatColor.translateAlternateColorCodes('&', - configLoad.getString("Menu.Coop.Item.Coop.Displayname") - .replace("%player", targetPlayerName) - .replace("%type", type == IslandCoop.TEMP ? temp : normal)), - configLoad.getStringList("Menu.Coop.Item.Coop.Lore"), null, null, null), - inventorySlot); - } - } - } - - nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Coop.Title"))); - nInv.setRows(6); - - Bukkit.getServer().getScheduler().runTask(plugin, nInv::open); - } - } -} From 105e5be768c38e96c963fae0269faeac1bea3b62 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 18:28:05 +0200 Subject: [PATCH 324/366] Stop Endersignal in island worlds --- .../java/com/songoda/skyblock/listeners/Entity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java index 6cf86878..c8dacaa5 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Entity.java +++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java @@ -611,6 +611,18 @@ public class Entity implements Listener { }); event.setCancelled(true); // For other plugin API reasons. } + + @EventHandler(ignoreCancelled = true) + public void onEntitySpawn(EntitySpawnEvent event) { + WorldManager worldManager = plugin.getWorldManager(); + if(worldManager.isIslandWorld(event.getLocation().getWorld())) { + org.bukkit.entity.Entity entity = event.getEntity(); + + if(event.getEntity() instanceof EnderSignal) { + ((EnderSignal) entity).setTargetLocation(entity.getLocation().add(0d, 50d, 0d)); + } + } + } @EventHandler(ignoreCancelled = true) public void onDamageVehicle(VehicleDamageEvent event) { From 094228501bee426f783f077e27b472b4d0e20cd6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 18:28:23 +0200 Subject: [PATCH 325/366] Exclude players from mob griefing --- .../listening/MobGriefingPermission.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java index fbeae21e..58847832 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java @@ -58,15 +58,16 @@ public class MobGriefingPermission extends ListeningPermission { @PermissionHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if (!(event.getDamager() instanceof Player) - && (!(event.getDamager() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) - && !(event.getDamager() instanceof TNTPrimed) - && !(event.getDamager() instanceof ExplosiveMinecart) - && !(event.getDamager() instanceof IronGolem) - && !(event.getDamager() instanceof Snowman) - && !(event.getDamager() instanceof Wolf && - ((Wolf) event.getDamager()).isTamed())) { + if (!(event.getDamager() instanceof Player) && + (!(event.getDamager() instanceof org.bukkit.entity.Projectile) || + !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) && + !(event.getDamager() instanceof TNTPrimed) && + !(event.getDamager() instanceof ExplosiveMinecart) && + !(event.getDamager() instanceof IronGolem) && + !(event.getDamager() instanceof Snowman) && + !(event.getDamager() instanceof Wolf && + ((Wolf) event.getDamager()).isTamed()) && + !(event.getEntity() instanceof Player)) { event.setCancelled(true); } } From f633b7dab23fb25d929728d2b4c4935b84e864da Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 18:30:05 +0200 Subject: [PATCH 326/366] Fix for row interval --- src/main/java/com/songoda/skyblock/scoreboard/Driver.java | 2 +- src/main/java/com/songoda/skyblock/scoreboard/Row.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java index 7742f8bc..2bc414c7 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java @@ -41,7 +41,7 @@ class Driver extends BukkitRunnable { for(int i = 1; i<16; i++) { List rowLines = config.getStringList("Rows." + i + ".Content"); if(!rowLines.isEmpty()) { - Row row = new Row(rowLines, config.getInt("Interval")); + Row row = new Row(rowLines, config.getInt("Rows." + i + ".Interval")); rows.add(row); } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Row.java b/src/main/java/com/songoda/skyblock/scoreboard/Row.java index a9e7803e..7431beee 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Row.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Row.java @@ -17,7 +17,7 @@ class Row { public Row(List lines, int interval) { this.lines = lines; this.interval = interval; - this.current = 1; + this.current = 0; this.count = 0; if(interval < 0) { @@ -29,7 +29,7 @@ class Row { if(lines.isEmpty()) { line = ""; } else { - line = TextUtils.formatText(lines.get(0)); + line = TextUtils.formatText(lines.get(current)); } } From cced4fe71ff14ca4effe27205592e3332b90d94f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 18:31:37 +0200 Subject: [PATCH 327/366] Removed unused code --- .../skyblock/command/commands/admin/ReloadCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java index 782ad1c8..b894b7cc 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java @@ -26,15 +26,15 @@ public class ReloadCommand extends SubCommand { @Override public void onCommandByPlayer(Player player, String[] args) { - onCommand(player, args); + onCommand(player); } @Override public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { - onCommand(sender, args); + onCommand(sender); } - public void onCommand(CommandSender sender, String[] args) { + public void onCommand(CommandSender sender) { LeaderboardManager leaderboardManager = plugin.getLeaderboardManager(); MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); From 7897ce6ce072b13854150ded4aa93cd7af0dea59 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 18:31:56 +0200 Subject: [PATCH 328/366] Fixed correct scoreboard --- .../skyblock/scoreboard/ScoreboardManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index a365d3ec..cf1d0681 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -65,17 +65,17 @@ public class ScoreboardManager extends Manager { boolean hasMembers = islandVisit.getMembers() > 1; if(hasMembers) { - if(hasVisitors) { - type = ScoreboardType.ISLAND_SOLO_VISITORS; - } else { - type = ScoreboardType.ISLAND_SOLO_EMPTY; - } - } else { if(hasVisitors) { type = ScoreboardType.ISLAND_TEAM_VISITORS; } else { type = ScoreboardType.ISLAND_TEAM_EMPTY; } + } else { + if(hasVisitors) { + type = ScoreboardType.ISLAND_SOLO_VISITORS; + } else { + type = ScoreboardType.ISLAND_SOLO_EMPTY; + } } } else { type = ScoreboardType.NOISLAND; From bb37b142c8ae157a22e5b8642edbc29c08fa1827 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 18:32:34 +0200 Subject: [PATCH 329/366] Fixed placeholders errors --- .../placeholder/PlaceholderProcessor.java | 42 +++++++++---------- src/main/resources/placeholders.yml | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java index 31093bf2..6ace0f46 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java @@ -235,7 +235,7 @@ public class PlaceholderProcessor { placeholdersLoad.getString("Placeholders.fabledskyblock_island_members.Empty")); } else { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_island_members.Non-empty") .replace("{PLACEHOLDER}", "" + island.getRole(IslandRole.Member).size())); } break; @@ -359,14 +359,14 @@ public class PlaceholderProcessor { } returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_votes.Non-empty") .replace("{POSITION}", "" + (value)) .replace("{PLAYER}", islandOwnerName) .replace("{VOTES}", NumberUtil.formatNumberByDecimal(visit.getVoters().size()))); } else { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_votes.Empty")); } } else if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_bank_")){ List leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank); @@ -393,14 +393,14 @@ public class PlaceholderProcessor { } returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_bank.Non-empty") .replace("{POSITION}", "" + (value)) .replace("{PLAYER}", islandOwnerName) .replace("{BALANCE}", NumberUtil.formatNumberByDecimal(visit.getBankBalance()))); } else { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_bank.Empty")); } } else if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_level_")){ List leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level); @@ -428,7 +428,7 @@ public class PlaceholderProcessor { } returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_level.Non-empty") .replace("{POSITION}", "" + (value)) .replace("{PLAYER}", islandOwnerName) .replace("{LEVEL}", NumberUtil.formatNumberByDecimal(level.getLevel())) @@ -436,69 +436,69 @@ public class PlaceholderProcessor { } else { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_leaderboard_level.Empty")); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) { if (island == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_island_leaderboard_level_rank.Empty")); } else { int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level); returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_island_leaderboard_level_rank.Non-empty") .replace("{PLACEHOLDER}", "" + rank)); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_bank_rank")) { if (island == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_island_leaderboard_bank_rank.Empty")); } else { int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank); returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_island_leaderboard_bank_rank.Non-empty") .replace("{PLACEHOLDER}", "" + rank)); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) { if (island == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_island_leaderboard_votes_rank.Empty")); } else { int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes); returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_island_leaderboard_votes_rank.Non-empty") .replace("{PLACEHOLDER}", "" + rank)); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) { if (island == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_count.Empty")); } else { String materialName = placeholder.replace("fabledskyblock_island_level_block_count_", "").toUpperCase(); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); if (materials == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Invalid")); + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_count.Invalid")); } else { long blockCount = island.getLevel().getMaterialAmount(materials.name()); returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_count.Non-empty") .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockCount))); } } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_points_")) { if (island == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Empty")); + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_points.Empty")); } else { String materialName = placeholder.replace("fabledskyblock_island_level_block_points_", "").toUpperCase(); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); if (materials == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Invalid")); + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_points.Invalid")); } else { long blockPoints = island.getLevel().getMaterialPoints(materials.name()); returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_block_points.Non-empty") .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockPoints))); } } @@ -507,11 +507,11 @@ public class PlaceholderProcessor { CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); if (materials == null) { returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid")); + placeholdersLoad.getString("Placeholders.fabledskyblock_level_block_value.Invalid")); } else { double blockValue = levellingManager.getWorth(materials); returnValue = TextUtils.formatText( - placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty") + placeholdersLoad.getString("Placeholders.fabledskyblock_level_block_value.Non-empty") .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockValue))); } } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_has_upgrade_")) { diff --git a/src/main/resources/placeholders.yml b/src/main/resources/placeholders.yml index 43e69773..c79c56e3 100644 --- a/src/main/resources/placeholders.yml +++ b/src/main/resources/placeholders.yml @@ -30,7 +30,7 @@ Placeholders: Non-empty: '{PLACEHOLDER}' Empty: '0' fabledskyblock_island_bank_balance_formatted: - Empty: 0' + Empty: '0' Non-empty: '{PLACEHOLDER}' fabledskyblock_island_owner: Non-empty: From 621c542d776a8fb1bc8e10842a4a621c7d6c3029 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 18:59:23 +0200 Subject: [PATCH 330/366] Trim scoreboard rows --- src/main/java/com/songoda/skyblock/scoreboard/Board.java | 2 +- .../com/songoda/skyblock/scoreboard/ScoreboardLine.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/Board.java index bb50c5a9..53958fd4 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Board.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Board.java @@ -113,6 +113,6 @@ class Board { prefixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, prefixLine); suffixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, lastColorCodes + suffixLine); } - return new ScoreboardLine(prefixLine, suffixLine); + return new ScoreboardLine(prefixLine, suffixLine, allowed_line_size); } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java index 758fa921..0096f37d 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java @@ -5,7 +5,13 @@ class ScoreboardLine { private final String prefix; private final String suffix; - public ScoreboardLine(String prefix, String suffix) { + public ScoreboardLine(String prefix, String suffix, int limit) { + if(prefix.length() > limit) { + prefix = prefix.substring(0, limit); + } + if(suffix.length() > limit) { + suffix = suffix.substring(0, limit); + } this.prefix = prefix; this.suffix = suffix; } From a5dad17c9862726fc61c0019be2688b8ac037fc7 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 21:59:24 +0200 Subject: [PATCH 331/366] Fixed wrong placeholder management --- .../com/songoda/skyblock/placeholder/PlaceholderManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java index b9e65053..e6356f29 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderManager.java @@ -31,7 +31,7 @@ public class PlaceholderManager extends Manager { } public String parsePlaceholders(Player player, String message) { - String retValue = ""; + String retValue = message; if(PlaceholderAPIEnabled) { retValue = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message); From 07029330c6aabee8ed45d30516ab42302870ae99 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 22:00:52 +0200 Subject: [PATCH 332/366] Simplified scoreboards --- .../com/songoda/skyblock/scoreboard/Board.java | 16 ++++++++-------- .../com/songoda/skyblock/scoreboard/Driver.java | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/Board.java index 53958fd4..f5a9cd5b 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Board.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Board.java @@ -3,6 +3,7 @@ package com.songoda.skyblock.scoreboard; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.placeholder.PlaceholderManager; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; @@ -25,7 +26,11 @@ class Board { this.player = player; this.plugin = plugin; this.board = this.plugin.getServer().getScoreboardManager().getNewScoreboard(); - this.objective = this.board.registerNewObjective("sb1", "sb2"); + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { + this.objective = this.board.registerNewObjective("sb1", "sb2", "sb3"); + } else { + this.objective = this.board.registerNewObjective("sb1", "sb2"); + } this.objective.setDisplaySlot(DisplaySlot.SIDEBAR); this.objective.setDisplayName("..."); @@ -35,8 +40,6 @@ class Board { this.objective.getScore(ChatColor.values()[i] + "").setScore(lineCount - i); } - - //this.player.setScoreboard(this.board); } public void setTitle(String string) { @@ -77,10 +80,7 @@ class Board { private ScoreboardLine convertIntoPieces(String line, int allowed_line_size) { String prefixLine = line.substring(0, Math.min(line.length(), allowed_line_size)); - String suffixLine = ""; - if(line.length() > allowed_line_size) { - suffixLine = line.substring(allowed_line_size); - } + String suffixLine = line.length() <= allowed_line_size ? "" : line.substring(allowed_line_size, Math.min(line.length(), allowed_line_size*2)); if (prefixLine.endsWith(String.valueOf(ChatColor.COLOR_CHAR))) { prefixLine = ChatColor.translateAlternateColorCodes( @@ -109,7 +109,7 @@ class Board { } else { lastColorCodes = ChatColor.WHITE.toString(); } - + prefixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, prefixLine); suffixLine = ChatColor.translateAlternateColorCodes(ChatColor.COLOR_CHAR, lastColorCodes + suffixLine); } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java index 2bc414c7..e00de37f 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java @@ -10,6 +10,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; class Driver extends BukkitRunnable { @@ -46,7 +47,7 @@ class Driver extends BukkitRunnable { } } } else { - title = new Row(new ArrayList<>(), 0); + title = new Row(new ArrayList<>(), -1); } } From 8857ae4d6c587054498d0417e3d44109ea4e4842 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 22:40:21 +0200 Subject: [PATCH 333/366] Fixed async scoreboard and added 1.8.8 support --- .../commands/island/ConfirmCommand.java | 17 +++ .../command/commands/island/KickCommand.java | 17 ++- .../skyblock/island/IslandManager.java | 8 +- .../com/songoda/skyblock/listeners/Join.java | 135 +++++++++--------- .../songoda/skyblock/scoreboard/Board.java | 2 +- .../songoda/skyblock/scoreboard/Holder.java | 1 - .../scoreboard/ScoreboardManager.java | 31 ++-- 7 files changed, 119 insertions(+), 92 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java index 88a015bd..780b5b56 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java @@ -14,6 +14,7 @@ import com.songoda.skyblock.island.IslandStatus; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; +import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.structure.Structure; import com.songoda.skyblock.structure.StructureManager; @@ -39,6 +40,7 @@ public class ConfirmCommand extends SubCommand { IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); + ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); Economy economy = plugin.getEconomyManager().getEconomy(); if (playerDataManager.hasPlayerData(player)) { @@ -108,9 +110,19 @@ public class ConfirmCommand extends SubCommand { .getString("Command.Island.Confirmation.Ownership.Member.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } + Bukkit.getScheduler().runTask(plugin, () -> { + if (scoreboardManager != null) { + scoreboardManager.updatePlayerScoreboardType(player); + } + }); } else if (confirmation.equals(Confirmation.Reset)) { playerData.setConfirmation(null); playerData.setConfirmationTime(0); + Bukkit.getScheduler().runTask(plugin, () -> { + if (scoreboardManager != null) { + scoreboardManager.updatePlayerScoreboardType(player); + } + }); } else if (confirmation.equals(Confirmation.Deletion)) { if (island.getStatus().equals(IslandStatus.OPEN)) { messageManager.sendMessage(player, @@ -175,6 +187,11 @@ public class ConfirmCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1f, 1f); } } + Bukkit.getScheduler().runTask(plugin, () -> { + if (scoreboardManager != null) { + scoreboardManager.updatePlayerScoreboardType(player); + } + }); } } else { messageManager.sendMessage(player, 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 8a3735cf..aa5c87d6 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 @@ -145,10 +145,13 @@ public class KickCommand extends SubCommand { && !targetPlayer.isOp()) { LocationUtil.teleportPlayerToSpawn(targetPlayer); } - - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(targetPlayer); - } + + Player finalTargetPlayer = targetPlayer; + Bukkit.getScheduler().runTask(plugin, () -> { + if (scoreboardManager != null) { + scoreboardManager.updatePlayerScoreboardType(finalTargetPlayer); + } + }); playerData = playerDataManager.getPlayerData(targetPlayer); playerData.setPlaytime(0); @@ -183,11 +186,11 @@ public class KickCommand extends SubCommand { } } - if (scoreboardManager != null) { - if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { + Bukkit.getScheduler().runTask(plugin, () -> { + if (scoreboardManager != null) { scoreboardManager.updatePlayerScoreboardType(player); } - } + }); } } else { switch (island.getStatus()){ diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 07d1e06a..7ec845ac 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -262,9 +262,11 @@ public class IslandManager { data.setIsland(player.getUniqueId()); data.setOwner(player.getUniqueId()); - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + Bukkit.getScheduler().runTask(plugin, () -> { + if (scoreboardManager != null) { + scoreboardManager.updatePlayerScoreboardType(player); + } + }); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index f716dbd9..daad4929 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -37,85 +37,86 @@ public class Join implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - Player player = event.getPlayer(); - ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); UserCacheManager userCacheManager = plugin.getUserCacheManager(); CooldownManager cooldownManager = plugin.getCooldownManager(); IslandManager islandManager = plugin.getIslandManager(); FileManager fileManager = plugin.getFileManager(); - - userCacheManager.addUser(player.getUniqueId(), player.getName()); - userCacheManager.saveAsync(); - - try { - islandManager.loadIsland(player); - Island island = islandManager.getIsland(player); - boolean teleportedToIsland = false; - - Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Join.Spawn")) { - LocationUtil.teleportPlayerToSpawn(player); - } else if (configLoad.getBoolean("Island.Join.Island") && island != null) { - Bukkit.getScheduler().runTask(plugin, () -> { - PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); - player.setFallDistance(0.0F); - }); - teleportedToIsland = true; - } - - if (!teleportedToIsland) { - islandManager.loadPlayer(player); - } - } catch (Exception e) { - e.printStackTrace(); - } - - playerDataManager.loadPlayerData(player); - - if (playerDataManager.hasPlayerData(player)) { - String[] playerTexture; - + + Player player = event.getPlayer(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + userCacheManager.addUser(player.getUniqueId(), player.getName()); + userCacheManager.saveAsync(); + try { - Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player); - Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile"); - GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer); - Property property = gameProfile.getProperties().get("textures").iterator().next(); - playerTexture = new String[]{property.getSignature(), property.getValue()}; + islandManager.loadIsland(player); + Island island = islandManager.getIsland(player); + boolean teleportedToIsland = false; + + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (configLoad.getBoolean("Island.Join.Spawn")) { + LocationUtil.teleportPlayerToSpawn(player); + } else if (configLoad.getBoolean("Island.Join.Island") && island != null) { + Bukkit.getScheduler().runTask(plugin, () -> { + PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main)); + player.setFallDistance(0.0F); + }); + teleportedToIsland = true; + } + + if (!teleportedToIsland) { + islandManager.loadPlayer(player); + } } catch (Exception e) { - playerTexture = new String[]{ - "K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=", - "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19"}; + e.printStackTrace(); } - - PlayerData playerData = playerDataManager.getPlayerData(player); - playerData.setTexture(playerTexture[0], playerTexture[1]); - Bukkit.getScheduler().runTaskAsynchronously(plugin, playerData::save); - } else { - playerDataManager.createPlayerData(player); + playerDataManager.loadPlayerData(player); - } - - playerDataManager.storeIsland(player); - - 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 (playerDataManager.hasPlayerData(player)) { + String[] playerTexture; + + try { + Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player); + Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile"); + GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer); + Property property = gameProfile.getProperties().get("textures").iterator().next(); + playerTexture = new String[]{property.getSignature(), property.getValue()}; + } catch (Exception e) { + playerTexture = new String[]{ + "K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=", + "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19"}; + } + + PlayerData playerData = playerDataManager.getPlayerData(player); + playerData.setTexture(playerTexture[0], playerTexture[1]); + Bukkit.getScheduler().runTaskAsynchronously(plugin, playerData::save); + } else { + playerDataManager.createPlayerData(player); + playerDataManager.loadPlayerData(player); + } + + playerDataManager.storeIsland(player); + + 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)); + + + Island island = islandManager.getIslandPlayerAt(player); + if (island != null) { + islandManager.updateBorder(island); + islandManager.updateFlight(player); + } + + // Load Challenge + SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId()); + }); if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) { scoreboardManager.updatePlayerScoreboardType(player); } - - Island island = islandManager.getIslandPlayerAt(player); - if (island != null) { - islandManager.updateBorder(island); - islandManager.updateFlight(player); - } - - // Load Challenge - SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId()); } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/Board.java index f5a9cd5b..668cb641 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Board.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Board.java @@ -81,7 +81,7 @@ class Board { private ScoreboardLine convertIntoPieces(String line, int allowed_line_size) { String prefixLine = line.substring(0, Math.min(line.length(), allowed_line_size)); String suffixLine = line.length() <= allowed_line_size ? "" : line.substring(allowed_line_size, Math.min(line.length(), allowed_line_size*2)); - + if (prefixLine.endsWith(String.valueOf(ChatColor.COLOR_CHAR))) { prefixLine = ChatColor.translateAlternateColorCodes( ChatColor.COLOR_CHAR, prefixLine.substring(0, prefixLine.length() - 1)); diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java index a06df835..f49be93c 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java @@ -2,7 +2,6 @@ package com.songoda.skyblock.scoreboard; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.placeholder.PlaceholderManager; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; class Holder { diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index cf1d0681..9cd6f372 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -61,8 +61,11 @@ public class ScoreboardManager extends Manager { ScoreboardType type; if(island != null) { Visit islandVisit = island.getVisit(); - boolean hasVisitors = islandVisit.getVisitors().size() > 1; - boolean hasMembers = islandVisit.getMembers() > 1; + boolean hasVisitors = (islandVisit != null && + islandVisit.getVisitors() != null && + islandVisit.getVisitors().size() > 1); + boolean hasMembers = (islandVisit != null && + islandVisit.getMembers() > 1); if(hasMembers) { if(hasVisitors) { @@ -84,7 +87,19 @@ public class ScoreboardManager extends Manager { setPlayerScoreboard(player, type); } } - + + + + public void setPlayerScoreboard(Player player, ScoreboardType type) { + for(Driver driver : drivers) { + if(driver.getBoardType().equals(type)) { + driver.registerHolder(new Holder(plugin, driver, player)); + } else { + driver.unregisterHolder(player); + } + } + } + public void unregisterPlayer(Player player) { for(Driver driver : drivers) { driver.unregisterHolder(player); @@ -122,14 +137,4 @@ public class ScoreboardManager extends Manager { driver.cancel(); drivers.clear(); } - - public void setPlayerScoreboard(Player player, ScoreboardType type) { - for(Driver driver : drivers) { - if(driver.getBoardType().equals(type)) { - driver.registerHolder(new Holder(plugin, driver, player)); - } else { - driver.unregisterHolder(player); - } - } - } } From 53c1c68aa102a1cf4e611f1a33d220b61b0f776d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 22:40:29 +0200 Subject: [PATCH 334/366] Added website animation --- src/main/resources/scoreboard.yml | 151 +++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 3 deletions(-) diff --git a/src/main/resources/scoreboard.yml b/src/main/resources/scoreboard.yml index 543fde4a..0429636d 100644 --- a/src/main/resources/scoreboard.yml +++ b/src/main/resources/scoreboard.yml @@ -59,9 +59,38 @@ Scoreboards: Content: - '' 10: - Interval: -1 + Interval: 1 Content: - '&ewww.songoda.com' + - '&cw&eww.songoda.com' + - '&cww&ew.songoda.com' + - '&cwww&e.songoda.com' + - '&cwww.&esongoda.com' + - '&cwww.s&eongoda.com' + - '&cwww.so&engoda.com' + - '&cwww.son&egoda.com' + - '&cwww.song&eoda.com' + - '&cwww.songo&eda.com' + - '&cwww.songod&ea.com' + - '&cwww.songoda&e.com' + - '&cwww.songoda.&ecom' + - '&cwww.songoda.c&eom' + - '&cwww.songoda.co&em' + - '&cwww.songoda.com' + - '&ew&cww.songoda.com' + - '&eww&cw.songoda.com' + - '&ewww&c.songoda.com' + - '&ewww.&csongoda.com' + - '&ewww.s&congoda.com' + - '&ewww.so&cngoda.com' + - '&ewww.son&cgoda.com' + - '&ewww.song&coda.com' + - '&ewww.songo&cda.com' + - '&ewww.songod&ca.com' + - '&ewww.songoda&c.com' + - '&ewww.songoda.&ccom' + - '&ewww.songoda.c&com' + - '&ewww.songoda.co&cm' Island: Solo: Empty: @@ -122,9 +151,38 @@ Scoreboards: Content: - '' 10: - Interval: -1 + Interval: 1 Content: - '&ewww.songoda.com' + - '&cw&eww.songoda.com' + - '&cww&ew.songoda.com' + - '&cwww&e.songoda.com' + - '&cwww.&esongoda.com' + - '&cwww.s&eongoda.com' + - '&cwww.so&engoda.com' + - '&cwww.son&egoda.com' + - '&cwww.song&eoda.com' + - '&cwww.songo&eda.com' + - '&cwww.songod&ea.com' + - '&cwww.songoda&e.com' + - '&cwww.songoda.&ecom' + - '&cwww.songoda.c&eom' + - '&cwww.songoda.co&em' + - '&cwww.songoda.com' + - '&ew&cww.songoda.com' + - '&eww&cw.songoda.com' + - '&ewww&c.songoda.com' + - '&ewww.&csongoda.com' + - '&ewww.s&congoda.com' + - '&ewww.so&cngoda.com' + - '&ewww.son&cgoda.com' + - '&ewww.song&coda.com' + - '&ewww.songo&cda.com' + - '&ewww.songod&ca.com' + - '&ewww.songoda&c.com' + - '&ewww.songoda.&ccom' + - '&ewww.songoda.c&com' + - '&ewww.songoda.co&cm' Occupied: Title: Interval: 3 @@ -190,6 +248,35 @@ Scoreboards: Interval: -1 Content: - '&ewww.songoda.com' + - '&cw&eww.songoda.com' + - '&cww&ew.songoda.com' + - '&cwww&e.songoda.com' + - '&cwww.&esongoda.com' + - '&cwww.s&eongoda.com' + - '&cwww.so&engoda.com' + - '&cwww.son&egoda.com' + - '&cwww.song&eoda.com' + - '&cwww.songo&eda.com' + - '&cwww.songod&ea.com' + - '&cwww.songoda&e.com' + - '&cwww.songoda.&ecom' + - '&cwww.songoda.c&eom' + - '&cwww.songoda.co&em' + - '&cwww.songoda.com' + - '&ew&cww.songoda.com' + - '&eww&cw.songoda.com' + - '&ewww&c.songoda.com' + - '&ewww.&csongoda.com' + - '&ewww.s&congoda.com' + - '&ewww.so&cngoda.com' + - '&ewww.son&cgoda.com' + - '&ewww.song&coda.com' + - '&ewww.songo&cda.com' + - '&ewww.songod&ca.com' + - '&ewww.songoda&c.com' + - '&ewww.songoda.&ccom' + - '&ewww.songoda.c&com' + - '&ewww.songoda.co&cm' Team: Empty: Title: @@ -260,6 +347,35 @@ Scoreboards: Interval: -1 Content: - '&ewww.songoda.com' + - '&cw&eww.songoda.com' + - '&cww&ew.songoda.com' + - '&cwww&e.songoda.com' + - '&cwww.&esongoda.com' + - '&cwww.s&eongoda.com' + - '&cwww.so&engoda.com' + - '&cwww.son&egoda.com' + - '&cwww.song&eoda.com' + - '&cwww.songo&eda.com' + - '&cwww.songod&ea.com' + - '&cwww.songoda&e.com' + - '&cwww.songoda.&ecom' + - '&cwww.songoda.c&eom' + - '&cwww.songoda.co&em' + - '&cwww.songoda.com' + - '&ew&cww.songoda.com' + - '&eww&cw.songoda.com' + - '&ewww&c.songoda.com' + - '&ewww.&csongoda.com' + - '&ewww.s&congoda.com' + - '&ewww.so&cngoda.com' + - '&ewww.son&cgoda.com' + - '&ewww.song&coda.com' + - '&ewww.songo&cda.com' + - '&ewww.songod&ca.com' + - '&ewww.songoda&c.com' + - '&ewww.songoda.&ccom' + - '&ewww.songoda.c&com' + - '&ewww.songoda.co&cm' Occupied: Title: Interval: 3 @@ -332,4 +448,33 @@ Scoreboards: 13: Interval: -1 Content: - - '&ewww.songoda.com' \ No newline at end of file + - '&ewww.songoda.com' + - '&cw&eww.songoda.com' + - '&cww&ew.songoda.com' + - '&cwww&e.songoda.com' + - '&cwww.&esongoda.com' + - '&cwww.s&eongoda.com' + - '&cwww.so&engoda.com' + - '&cwww.son&egoda.com' + - '&cwww.song&eoda.com' + - '&cwww.songo&eda.com' + - '&cwww.songod&ea.com' + - '&cwww.songoda&e.com' + - '&cwww.songoda.&ecom' + - '&cwww.songoda.c&eom' + - '&cwww.songoda.co&em' + - '&cwww.songoda.com' + - '&ew&cww.songoda.com' + - '&eww&cw.songoda.com' + - '&ewww&c.songoda.com' + - '&ewww.&csongoda.com' + - '&ewww.s&congoda.com' + - '&ewww.so&cngoda.com' + - '&ewww.son&cgoda.com' + - '&ewww.song&coda.com' + - '&ewww.songo&cda.com' + - '&ewww.songod&ca.com' + - '&ewww.songoda&c.com' + - '&ewww.songoda.&ccom' + - '&ewww.songoda.c&com' + - '&ewww.songoda.co&cm' \ No newline at end of file From 06a99744e1de05424e27e179b7ffd527f82517b0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 23:57:00 +0200 Subject: [PATCH 335/366] Renamed scoreboard type --- .../com/songoda/skyblock/scoreboard/ScoreboardManager.java | 3 +-- .../java/com/songoda/skyblock/scoreboard/ScoreboardType.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 9cd6f372..85dead1d 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -9,7 +9,6 @@ import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.visit.Visit; import io.netty.util.internal.ConcurrentSet; -import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -81,7 +80,7 @@ public class ScoreboardManager extends Manager { } } } else { - type = ScoreboardType.NOISLAND; + type = ScoreboardType.NO_ISLAND; } setPlayerScoreboard(player, type); diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java index 5848ff7d..4a438da5 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardType.java @@ -3,7 +3,7 @@ package com.songoda.skyblock.scoreboard; import javax.annotation.Nonnull; enum ScoreboardType { - NOISLAND("Scoreboards.NoIsland"), + NO_ISLAND("Scoreboards.NoIsland"), ISLAND_SOLO_EMPTY("Scoreboards.Island.Solo.Empty"), ISLAND_SOLO_VISITORS("Scoreboards.Island.Solo.Occupied"), ISLAND_TEAM_EMPTY("Scoreboards.Island.Team.Empty"), From bc3c042dd1dc9a5385567616bb23f8ada93ed78c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 3 Aug 2020 23:57:10 +0200 Subject: [PATCH 336/366] Changed default website in holograms --- src/main/resources/language.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 3ab56c7b..8c4ec696 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -3634,12 +3634,12 @@ Island: Hologram: Leaderboard: Votes: - Footer: '&ewww.example.net' + Footer: '&ewww.songoda.com' Claimed: '&8* &f&o[%position] &a%player &7- &6%votes' Unclaimed: '&8* &f&o[%position] &7&oUnclaimed Position' Header: '&b&lSkyBlock &8&l| &e&lTop 10 Votes' Bank: - Footer: '&ewww.example.net' + Footer: '&ewww.songoda.com' Unclaimed: '&8* &f&o[%position] &7&oUnclaimed Position' Claimed: '&8* &f&o[%position] &a%player &7- &6$%balance' Header: '&b&lSkyBlock &8&l| &e&lTop 10 Bank Balances' @@ -3647,7 +3647,7 @@ Hologram: Header: '&b&lSkyBlock &8&l| &e&lTop 10 Level' Claimed: '&8* &f&o[%position] &a%player &7- &6%level' Unclaimed: '&8* &f&o[%position] &7&oUnclaimed Position' - Footer: '&ewww.example.net' + Footer: '&ewww.songoda.com' Stackable: Message: '%blocks: %amount' Challenge: From c94860913e85fd594db9c645a9b804a324191bde Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 00:24:24 +0200 Subject: [PATCH 337/366] Fix npe on join --- src/main/java/com/songoda/skyblock/listeners/Join.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index daad4929..e9d73d19 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -114,9 +114,12 @@ public class Join implements Listener { // Load Challenge SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId()); + + Bukkit.getScheduler().runTask(plugin, () -> { + if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) { + scoreboardManager.updatePlayerScoreboardType(player); + } + }); }); - if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) { - scoreboardManager.updatePlayerScoreboardType(player); - } } } From 1938545a9c2bed569c7fce7d6a3498904ed617a0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 00:24:43 +0200 Subject: [PATCH 338/366] Restored 32 chars scorebord on 1.8-1.12 --- src/main/java/com/songoda/skyblock/scoreboard/Board.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/Board.java index 668cb641..48cd20f2 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Board.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Board.java @@ -64,13 +64,10 @@ class Board { cache.put(line, string); ScoreboardLine parts; - - if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) { - parts = convertIntoPieces(string, 16); - } else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ parts = convertIntoPieces(string, 64); } else { - parts = convertIntoPieces(string, 8); + parts = convertIntoPieces(string, 16); } t.setPrefix(parts.getPrefix()); From ab85621f67dda4629166b464e6f7505a29a0d0af Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 00:44:09 +0200 Subject: [PATCH 339/366] Removed wrong scoreboard update --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 7ec845ac..d3c93679 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -532,7 +532,6 @@ public class IslandManager { } public synchronized boolean deleteIsland(Island island, boolean force) { - ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); CooldownManager cooldownManager = plugin.getCooldownManager(); FileManager fileManager = plugin.getFileManager(); @@ -585,10 +584,6 @@ public class IslandManager { playerData.setChat(false); playerData.save(); - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } - if (isPlayerAtIsland(island, player)) { LocationUtil.teleportPlayerToSpawn(player); } From eab672dc01f22e4c143278104e0d9fa323680506 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 00:44:19 +0200 Subject: [PATCH 340/366] Fixed iterator remove --- .../com/songoda/skyblock/scoreboard/Driver.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java index e00de37f..d9fa4e4e 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java @@ -10,7 +10,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Iterator; import java.util.List; class Driver extends BukkitRunnable { @@ -60,6 +60,11 @@ class Driver extends BukkitRunnable { } public void registerHolder(Holder holder) { + try { + throw new Exception(); + } catch (Exception exception) { + exception.printStackTrace(); + } holders.add(holder); } @@ -68,11 +73,14 @@ class Driver extends BukkitRunnable { } public void unregisterHolder(Player player) { - for(Holder holder : holders) + Iterator it = holders.iterator(); + while(it.hasNext()) { + Holder holder = it.next(); if(holder.player.equals(player)) { - holders.remove(holder); + it.remove(); break; } + } } @Override From 69cadd6ddaed5081d17eefcd9eb76d7e3ef8c74c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 00:44:43 +0200 Subject: [PATCH 341/366] Synchronized scoreboard type auto update --- .../com/songoda/skyblock/scoreboard/ScoreboardManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 85dead1d..0dc9de44 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -82,8 +82,9 @@ public class ScoreboardManager extends Manager { } else { type = ScoreboardType.NO_ISLAND; } - - setPlayerScoreboard(player, type); + synchronized (player) { + setPlayerScoreboard(player, type); + } } } From d81de7b23a9ca419dc625f3a46cd9e5d2989fe9f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 00:47:07 +0200 Subject: [PATCH 342/366] Removed debug exception --- src/main/java/com/songoda/skyblock/scoreboard/Driver.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java index d9fa4e4e..5fc0568d 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java @@ -60,11 +60,6 @@ class Driver extends BukkitRunnable { } public void registerHolder(Holder holder) { - try { - throw new Exception(); - } catch (Exception exception) { - exception.printStackTrace(); - } holders.add(holder); } From 77cfd8a65618901de940812382567dc04689d00d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 18:29:42 +0200 Subject: [PATCH 343/366] Fixed paper recognize --- src/main/java/com/songoda/skyblock/SkyBlock.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 9a2fc3ae..0d9c3ee4 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -118,11 +118,11 @@ public class SkyBlock extends SongodaPlugin { this.getLogger().warning("This Minecraft version is not officially supported."); } - if(paper = ServerProject.isServer(ServerProject.PAPER) && - ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)){ + if(paper = ServerProject.isServer(ServerProject.PAPER)){ try { Bukkit.spigot().getClass().getMethod("getPaperConfig"); - paperAsync = Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); + paperAsync = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && + Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); } catch (NoSuchMethodException ignored) { paperAsync = false; } From ccbe8de7e0c16b6948199d43dad5cfbc43cefb91 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 18:32:56 +0200 Subject: [PATCH 344/366] Optimized island scan --- .../skyblock/blockscanner/BlockScanner.java | 101 +++++++++++++----- .../skyblock/blockscanner/ChunkLoader.java | 60 +++++++---- .../skyblock/blockscanner/LocationBounds.java | 28 +++++ .../blockscanner/MaterialIDHelper.java | 10 +- .../island/removal/ChunkDeleteSplitter.java | 2 +- .../skyblock/levelling/IslandScan.java | 22 ++-- 6 files changed, 159 insertions(+), 64 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/blockscanner/LocationBounds.java diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index 9ca2e44c..adf40798 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -2,10 +2,14 @@ package com.songoda.skyblock.blockscanner; import com.google.common.collect.Lists; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.utils.version.NMSUtil; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandEnvironment; +import com.songoda.skyblock.world.WorldManager; import org.bukkit.Bukkit; import org.bukkit.ChunkSnapshot; +import org.bukkit.Location; import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; @@ -19,6 +23,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicInteger; public final class BlockScanner extends BukkitRunnable { @@ -29,9 +34,7 @@ public final class BlockScanner extends BukkitRunnable { try { temp = ChunkSnapshot.class.getMethod("getBlockTypeId", int.class, int.class, int.class); - } catch (NoSuchMethodException ignored) { - - } + } catch (NoSuchMethodException ignored) {} ID_FIELD = temp; } @@ -49,22 +52,30 @@ public final class BlockScanner extends BukkitRunnable { return id; } - private final static int VERSION = NMSUtil.getVersionNumber(); - - private int completedNum; + private final AtomicInteger completedNum; private final int threadCount; private final Queue blocks; private final ScannerTasks tasks; + private final Island island; + private final boolean ignoreLiquids; private final boolean ignoreAir; - private BlockScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + private BlockScanner(Map> snapshots, + Island island, + boolean ignoreLiquids, + boolean ignoreLiquidsY, + boolean ignoreAir, + boolean ignoreY, + ScannerTasks tasks) { this.ignoreLiquids = ignoreLiquids; this.ignoreAir = ignoreAir; this.blocks = new ConcurrentLinkedQueue<>(); this.tasks = tasks; + this.completedNum = new AtomicInteger(); + this.island = island; FileConfiguration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")).getFileConfiguration(); @@ -73,7 +84,7 @@ public final class BlockScanner extends BukkitRunnable { for (Entry> entry : snapshots.entrySet()) { final List> parts = Lists.partition(entry.getValue(), 16); - + threadCount += parts.size(); World world = entry.getKey(); @@ -109,21 +120,62 @@ public final class BlockScanner extends BukkitRunnable { } private void queueWork(World world, int scanY, List subList) { + WorldManager worldManager = SkyBlock.getInstance().getWorldManager(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> { + LocationBounds bounds = null; + if(island != null) { + Location islandLocation = island.getLocation(worldManager.getIslandWorld(world), IslandEnvironment.Island); + + Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius()); + Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius()); + + int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()); + int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()); + + int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()); + int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()); + + bounds = new LocationBounds(minX, minZ, maxX, maxZ); + } for (ChunkSnapshot shot : subList) { - final int cX = shot.getX() << 4; final int cZ = shot.getZ() << 4; - - for (int x = 0; x < 16; x++) { - for (int z = 0; z < 16; z++) { - for (int y = scanY; y < shot.getHighestBlockYAt(x, z); y++) { - - - final CompatibleMaterial type = CompatibleMaterial.getBlockMaterial(VERSION > 12 - ? shot.getBlockType(x, y, z) : MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z))); - - + + int initX = 0; + int initZ = 0; + int lastX = 15; + int lastZ = 15; + + if(bounds != null) { + initX = Math.max(cX, bounds.getMinX())&0x000F; + initZ = Math.max(cZ, bounds.getMinZ())&0x000F; + + lastX = Math.min(cX | 15, bounds.getMaxX()-1)&0x000F; + lastZ = Math.min(cZ | 15, bounds.getMaxZ()-1)&0x000F; + } + + int finalInitX = initX; + int finalInitZ = initZ; + int finalLastZ = lastZ; + int finalLastX = lastX; + Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> { + world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalInitX, 80, finalInitZ).setType(CompatibleMaterial.GOLD_BLOCK.getBlockMaterial()); + world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalLastX, 80, finalLastZ).setType(CompatibleMaterial.CRYING_OBSIDIAN.getBlockMaterial()); + Bukkit.getScheduler().runTaskLater(SkyBlock.getInstance(), () -> { + world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalInitX, 80, finalInitZ).setType(CompatibleMaterial.AIR.getBlockMaterial()); + world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalLastX, 80, finalLastZ).setType(CompatibleMaterial.AIR.getBlockMaterial()); + }, 300L); + }); + + for (int x = initX; x <= lastX; x++) { + for (int z = initZ; z <= lastZ; z++) { + for (int y = scanY; y < world.getMaxHeight(); y++) { + final CompatibleMaterial type = CompatibleMaterial.getBlockMaterial( + ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) + ? shot.getBlockType(x, y, z) : + MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z))); + if(type == null){ continue; } else if(type.equals(CompatibleMaterial.AIR) && ignoreAir){ @@ -142,12 +194,11 @@ public final class BlockScanner extends BukkitRunnable { } private synchronized int increment() { - completedNum += 1; - return completedNum; + return completedNum.getAndIncrement(); } private synchronized int get() { - return completedNum; + return completedNum.get(); } @Override @@ -158,12 +209,12 @@ public final class BlockScanner extends BukkitRunnable { cancel(); } - public static void startScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + public static void startScanner(Map> snapshots, Island island, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null"); if (tasks == null) throw new IllegalArgumentException("tasks cannot be null"); - final BlockScanner scanner = new BlockScanner(snapshots, ignoreLiquids, ignoreLiquidsY, ignoreAir, ignoreY, tasks); + final BlockScanner scanner = new BlockScanner(snapshots, island, ignoreLiquids, ignoreLiquidsY, ignoreAir, ignoreY, tasks); scanner.runTaskTimer(SkyBlock.getInstance(), 5, 5); } diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java index dcdb88b6..01316250 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java @@ -20,19 +20,24 @@ public class ChunkLoader extends BukkitRunnable { private ChunkScannerTask generalTask; private ChunkForChunkScannerTask chunkTask; - private boolean chunkForChunk; - private boolean paper; + private final boolean chunkForChunk; + private final boolean paper; private World world; - private Island island; + private final Island island; private int x; private int z; private int minZ; private int maxX; private int maxZ; - private int chunkPerTick; - private CompleteTask completeTask; + private final int chunkPerTick; + private final CompleteTask completeTask; - private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkForChunkScannerTask chunkTask, CompleteTask complete) { + private ChunkLoader(Island island, + IslandWorld islandWorld, + boolean paper, + boolean chunkForChunk, + ChunkForChunkScannerTask chunkTask, + CompleteTask complete) { chunkPerTick = SkyBlock.getInstance().getFileManager() .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25); @@ -51,11 +56,11 @@ public class ChunkLoader extends BukkitRunnable { Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius()); Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius()); - int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()); - minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()); + int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 ; + minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4; - maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()); - maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()); + maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15; + maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15; x = minX; z = minZ; @@ -67,7 +72,12 @@ public class ChunkLoader extends BukkitRunnable { } } - private ChunkLoader(Island island, IslandWorld islandWorld, boolean paper, boolean chunkForChunk, ChunkScannerTask generalTask, CompleteTask complete) { + private ChunkLoader(Island island, + IslandWorld islandWorld, + boolean paper, + boolean chunkForChunk, + ChunkScannerTask generalTask, + CompleteTask complete) { chunkPerTick = SkyBlock.getInstance().getFileManager() .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")) .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25); @@ -83,18 +93,26 @@ public class ChunkLoader extends BukkitRunnable { world = islandLocation.getWorld(); - Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius()); - Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius()); + Location minLocation = new Location( + world, + islandLocation.getBlockX() - island.getRadius(), + 0, + islandLocation.getBlockZ() - island.getRadius()); + Location maxLocation = new Location( + world, + islandLocation.getBlockX() + island.getRadius(), + world.getMaxHeight(), + islandLocation.getBlockZ() + island.getRadius()); + + int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4; + minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4; - int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()); - minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()); - - maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()); - maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()); + maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15; + maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15; x = minX; z = minZ; - + if(paper){ this.runTaskAsynchronously(SkyBlock.getInstance()); } else { @@ -105,8 +123,8 @@ public class ChunkLoader extends BukkitRunnable { @Override public void run() { // TODO New algorithm that start from the center of the island for(int i = 0; i < chunkPerTick || paper; i++){ - if(x < maxX){ - if(z < maxZ){ + if(x <= maxX){ + if(z <= maxZ){ if(!chunkForChunk){ positions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4)); } else { diff --git a/src/main/java/com/songoda/skyblock/blockscanner/LocationBounds.java b/src/main/java/com/songoda/skyblock/blockscanner/LocationBounds.java new file mode 100644 index 00000000..5f52fdd5 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/blockscanner/LocationBounds.java @@ -0,0 +1,28 @@ +package com.songoda.skyblock.blockscanner; + +public class LocationBounds { + private final int minX, minZ, maxX, maxZ; + + public LocationBounds(int minX, int minZ, int maxX, int maxZ) { + this.minX = minX; + this.minZ = minZ; + this.maxX = maxX; + this.maxZ = maxZ; + } + + public int getMinX() { + return minX; + } + + public int getMinZ() { + return minZ; + } + + public int getMaxX() { + return maxX; + } + + public int getMaxZ() { + return maxZ; + } +} diff --git a/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java b/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java index fecc94d2..2604a4a1 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/MaterialIDHelper.java @@ -1,6 +1,6 @@ package com.songoda.skyblock.blockscanner; -import com.songoda.skyblock.utils.version.NMSUtil; +import com.songoda.core.compatibility.ServerVersion; import org.bukkit.Material; import java.util.HashMap; @@ -9,18 +9,14 @@ import java.util.Map; @SuppressWarnings("deprecation") public final class MaterialIDHelper { - private final static int VERSION = NMSUtil.getVersionNumber(); - - private MaterialIDHelper() { - - } + private MaterialIDHelper() {} private final static Map MATERIALS; static { MATERIALS = new HashMap<>(); - if (VERSION > 12) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { for (Material type : Material.values()) { if (type.isLegacy()) MATERIALS.put(type.getId(), type); } diff --git a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java index ae9059ba..e5588999 100644 --- a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java +++ b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java @@ -25,7 +25,7 @@ public class ChunkDeleteSplitter extends BukkitRunnable { } private void start() { - BlockScanner.startScanner(snapshots, false, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, null,false, true, true, false, (blocks) -> { this.blocks = blocks; this.runTaskTimer(SkyBlock.getInstance(), 20, 20); }); diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java index eefd5983..9f8f84cb 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -12,7 +12,10 @@ import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.levelling.amount.AmountMaterialPair; import com.songoda.skyblock.levelling.amount.BlockAmount; import com.songoda.skyblock.message.MessageManager; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChunkSnapshot; +import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -22,8 +25,6 @@ import java.io.File; import java.text.NumberFormat; import java.util.*; import java.util.Map.Entry; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; public final class IslandScan extends BukkitRunnable { @@ -81,28 +82,25 @@ public final class IslandScan extends BukkitRunnable { populate(snapshots, IslandWorld.Nether, plugin.isPaperAsync(), () -> { if (hasEnd) { populate(snapshots, IslandWorld.End, plugin.isPaperAsync(), () -> { - BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); - }); }); } else { - BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); - }); } }); } else { - BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); - }); } }); @@ -169,8 +167,12 @@ public final class IslandScan extends BukkitRunnable { Bukkit.getScheduler().runTask(plugin, () -> { if (language.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) { - final double percent = ((double) totalScanned / (double) blocksSize) * 100; + double percent = ((double) totalScanned / (double) blocksSize) * 100; + if(Double.isNaN(percent)) { + percent = 0d; + } + String message = language.getString("Command.Island.Level.Scanning.Progress.Message"); message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned)); message = message.replace("%max_blocks%", String.valueOf(blocksSize)); From 1123664ef65fd7581b880ee928b6caef03066485 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 18:33:12 +0200 Subject: [PATCH 345/366] Removed deprecated size fix --- src/main/java/com/songoda/skyblock/island/Island.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 4daf712c..e720c460 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -81,16 +81,16 @@ public class Island { if (minimumSize < 0 || minimumSize > 1000) minimumSize = 50; - if(minimumSize % 2 != 0) { + /*if(minimumSize % 2 != 0) { minimumSize += 1; - } + }*/ if (maximumSize < 0 || maximumSize > 1000) maximumSize = 100; - if(maximumSize % 2 != 0) { + /*if(maximumSize % 2 != 0) { maximumSize += 1; - } + }*/ size = Math.max(minimumSize, Math.min(customSize, maximumSize)); } From 9c47619df4955edb14830fa4acd0628405abaa9f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 19:03:33 +0200 Subject: [PATCH 346/366] Do not update static lines --- src/main/java/com/songoda/skyblock/scoreboard/Row.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Row.java b/src/main/java/com/songoda/skyblock/scoreboard/Row.java index 7431beee..e20f9b8f 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Row.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Row.java @@ -19,12 +19,8 @@ class Row { this.interval = interval; this.current = 0; this.count = 0; - - if(interval < 0) { - static_line = true; - } else { - static_line = false; - } + + static_line = interval < 0 || lines.isEmpty() || lines.size() <= 1; if(lines.isEmpty()) { line = ""; @@ -34,7 +30,7 @@ class Row { } public void update() { - if (!static_line && !lines.isEmpty()) { + if (!static_line) { if (count >= interval) { count = 0; current++; From cd70c7182bc4fea0dff3fd910869ef333ea78f1c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 21:24:53 +0200 Subject: [PATCH 347/366] Optimized imports --- src/main/java/com/songoda/skyblock/bank/BankManager.java | 1 - src/main/java/com/songoda/skyblock/biome/BiomeManager.java | 1 - .../java/com/songoda/skyblock/command/CommandManager.java | 1 - .../songoda/skyblock/command/commands/island/KickCommand.java | 1 - .../java/com/songoda/skyblock/economy/EconomyManager.java | 3 --- .../java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java | 1 - .../permissions/listening/ProtectorDamagePermission.java | 4 +++- src/main/java/com/songoda/skyblock/playerdata/PlayerData.java | 1 - .../com/songoda/skyblock/playerdata/PlayerDataManager.java | 1 - src/main/java/com/songoda/skyblock/scoreboard/Board.java | 1 - src/main/java/com/songoda/skyblock/scoreboard/Driver.java | 1 - .../com/songoda/skyblock/scoreboard/ScoreboardManager.java | 4 +++- 12 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 1573e7a6..b4309e51 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -3,7 +3,6 @@ package com.songoda.skyblock.bank; import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.economy.EconomyManager; import com.songoda.skyblock.island.Island; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index 5719ca7d..7313d840 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -7,7 +7,6 @@ import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; import com.songoda.skyblock.island.IslandWorld; import com.songoda.skyblock.utils.version.NMSUtil; -import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Biome; diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java index dd016d76..83755b72 100644 --- a/src/main/java/com/songoda/skyblock/command/CommandManager.java +++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java @@ -13,7 +13,6 @@ import com.songoda.skyblock.command.commands.island.UpgradeCommand; import com.songoda.skyblock.command.commands.island.*; import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager.Config; -import com.songoda.skyblock.menus.ControlPanel; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.ChatComponent; 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 aa5c87d6..d694ae16 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 @@ -19,7 +19,6 @@ import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.utils.world.LocationUtil; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java index 48a6ad64..19ab1107 100644 --- a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java +++ b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java @@ -4,9 +4,6 @@ import com.songoda.core.hooks.Hook; import com.songoda.core.hooks.economies.Economy; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.manager.Manager; -import org.bukkit.Bukkit; - -import java.util.Arrays; public class EconomyManager extends Manager { diff --git a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java index 0b86c846..96249aa4 100644 --- a/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java +++ b/src/main/java/com/songoda/skyblock/gui/coop/GuiCoopChoose.java @@ -3,7 +3,6 @@ package com.songoda.skyblock.gui.coop; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.gui.Gui; -import com.songoda.core.gui.GuiType; import com.songoda.core.gui.GuiUtils; import com.songoda.core.utils.TextUtils; import com.songoda.skyblock.SkyBlock; diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java index 7af194e8..54c19b84 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ProtectorDamagePermission.java @@ -5,7 +5,9 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; -import org.bukkit.entity.*; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Snowman; +import org.bukkit.entity.Wolf; import org.bukkit.event.entity.EntityDamageByEntityEvent; public class ProtectorDamagePermission extends ListeningPermission { diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index b5d632db..0644294f 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -2,7 +2,6 @@ package com.songoda.skyblock.playerdata; import com.eatthepath.uuid.FastUUID; import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.bank.BankManager; import com.songoda.skyblock.bank.Transaction; import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.confirmation.Confirmation; diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index d1e43d31..3a398a56 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -14,7 +14,6 @@ import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.visit.Visit; import com.songoda.skyblock.world.WorldManager; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/Board.java index 48cd20f2..530c4cc0 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Board.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Board.java @@ -3,7 +3,6 @@ package com.songoda.skyblock.scoreboard; import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.placeholder.PlaceholderManager; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java index 5fc0568d..f48599c4 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java @@ -2,7 +2,6 @@ package com.songoda.skyblock.scoreboard; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.config.FileManager; -import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 0dc9de44..9218452d 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -13,7 +13,9 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; public class ScoreboardManager extends Manager { From 323afe7abb7950b1c5de0a7c46c054e52da71212 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 21:52:29 +0200 Subject: [PATCH 348/366] Moved scoreboard options to config.yml --- .../com/songoda/skyblock/scoreboard/ScoreboardManager.java | 6 +++--- src/main/resources/config.yml | 2 ++ src/main/resources/scoreboard.yml | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 9218452d..068c5742 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -122,11 +122,11 @@ public class ScoreboardManager extends Manager { private void newDriver(ScoreboardType board) { FileManager fileManager = plugin.getFileManager(); - FileConfiguration scoreboardLoad = fileManager.getConfig( - new File(plugin.getDataFolder(), "scoreboard.yml")).getFileConfiguration(); + FileConfiguration configload = fileManager.getConfig( + new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); Driver driver = new Driver(plugin, board); - if(scoreboardLoad.getBoolean("Settings.Async", true)) { + if(configload.getBoolean("Island.Scoreboard.Async", true)) { driver.runTaskTimerAsynchronously(plugin, 1L, 1L); } else { driver.runTaskTimer(plugin, 1L, 1L); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f0f61846..a1a8405e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -328,6 +328,8 @@ Island: Selector: "DIAMOND_AXE" Scoreboard: Enable: true + # Set it to false if you notice some visual problems. + Async: true Generator: Enable: true # Check only the island owner's permissions diff --git a/src/main/resources/scoreboard.yml b/src/main/resources/scoreboard.yml index 0429636d..eb1aaac0 100644 --- a/src/main/resources/scoreboard.yml +++ b/src/main/resources/scoreboard.yml @@ -1,5 +1,3 @@ -Settings: - Async: true Scoreboards: NoIsland: Title: From d7339ec3adbbffad9e177b101b0f3f384f8a4909 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 21:57:07 +0200 Subject: [PATCH 349/366] Small improvements in file manager --- .../songoda/skyblock/config/FileManager.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java index e267af6b..f974181e 100644 --- a/src/main/java/com/songoda/skyblock/config/FileManager.java +++ b/src/main/java/com/songoda/skyblock/config/FileManager.java @@ -161,13 +161,13 @@ public class FileManager { final ConfigurationSection section = config.getFileConfiguration().createSection(path); section.set("world", location.getWorld().getName()); - section.set("x", Double.valueOf(location.getX())); - section.set("y", Double.valueOf(location.getY())); - section.set("z", Double.valueOf(location.getZ())); + section.set("x", location.getX()); + section.set("y", location.getY()); + section.set("z", location.getZ()); if (direction) { - section.set("yaw", Float.valueOf(location.getYaw())); - section.set("pitch", Float.valueOf(location.getPitch())); + section.set("yaw", location.getYaw()); + section.set("pitch", location.getPitch()); } try { @@ -272,10 +272,10 @@ public class FileManager { while ((currentLine = bufferedReader.readLine()) != null) { if (currentLine.contains("#")) { addLine = currentLine.replace("[!]", "IMPORTANT").replace(":", "-").replaceFirst("#", pluginName + "_COMMENT_" + commentNum + ":"); - whole.append(addLine + "\n"); + whole.append(addLine).append("\n"); commentNum++; } else { - whole.append(currentLine + "\n"); + whole.append(currentLine).append("\n"); } } @@ -311,9 +311,9 @@ public class FileManager { for (String line : lines) { if (line.contains(plugin.getDescription().getName() + "_COMMENT")) { - config.append(line.replace("IMPORTANT", "[!]").replace("\n", "").replace(plugin.getDescription().getName() + "_COMMENT_", "#").replaceAll("[0-9]+:", "") + "\n"); + config.append(line.replace("IMPORTANT", "[!]").replace("\n", "").replace(plugin.getDescription().getName() + "_COMMENT_", "#").replaceAll("[0-9]+:", "")).append("\n"); } else if (line.contains(":")) { - config.append(line + "\n"); + config.append(line).append("\n"); } } From 43d52ff0e45091a3c4c8cfdb5193cde9db3fb63f Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 22:06:49 +0200 Subject: [PATCH 350/366] Removed debug stuff --- .../songoda/skyblock/blockscanner/BlockScanner.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index adf40798..38efd626 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -154,19 +154,6 @@ public final class BlockScanner extends BukkitRunnable { lastX = Math.min(cX | 15, bounds.getMaxX()-1)&0x000F; lastZ = Math.min(cZ | 15, bounds.getMaxZ()-1)&0x000F; } - - int finalInitX = initX; - int finalInitZ = initZ; - int finalLastZ = lastZ; - int finalLastX = lastX; - Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> { - world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalInitX, 80, finalInitZ).setType(CompatibleMaterial.GOLD_BLOCK.getBlockMaterial()); - world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalLastX, 80, finalLastZ).setType(CompatibleMaterial.CRYING_OBSIDIAN.getBlockMaterial()); - Bukkit.getScheduler().runTaskLater(SkyBlock.getInstance(), () -> { - world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalInitX, 80, finalInitZ).setType(CompatibleMaterial.AIR.getBlockMaterial()); - world.getChunkAt(shot.getX(), shot.getZ()).getBlock(finalLastX, 80, finalLastZ).setType(CompatibleMaterial.AIR.getBlockMaterial()); - }, 300L); - }); for (int x = initX; x <= lastX; x++) { for (int z = initZ; z <= lastZ; z++) { From fc48700c32a710a166fd77ddf8d4d807a25b1465 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 4 Aug 2020 22:07:34 +0200 Subject: [PATCH 351/366] 2.3.6-DEV4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 14623d79..917db08a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.6-DEV3 + 2.3.6-DEV4 jar UTF-8 From 5542ff42dc051a3ad6f89c8c716674963d84c0c1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 5 Aug 2020 16:20:02 +0200 Subject: [PATCH 352/366] Do not create empty scoreboards async --- src/main/java/com/songoda/skyblock/scoreboard/Holder.java | 2 +- .../songoda/skyblock/scoreboard/ScoreboardManager.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java index f49be93c..ed21cfe9 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java @@ -39,7 +39,7 @@ class Holder { this.player.setScoreboard(board.board); } else { - this.player.setScoreboard(plugin.getServer().getScoreboardManager().getNewScoreboard()); + this.player.setScoreboard(scoreboardManager.getEmptyScoreboard()); } } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index 068c5742..c97125ef 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -9,8 +9,10 @@ import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.visit.Visit; import io.netty.util.internal.ConcurrentSet; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Scoreboard; import java.io.File; import java.util.ArrayList; @@ -19,6 +21,7 @@ import java.util.Set; public class ScoreboardManager extends Manager { + private final Scoreboard emptyScoreboard; private final List drivers; private final Set disabledPlayers; @@ -26,6 +29,7 @@ public class ScoreboardManager extends Manager { super(plugin); this.drivers = new ArrayList<>(); this.disabledPlayers = new ConcurrentSet<>(); + this.emptyScoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); for(ScoreboardType type : ScoreboardType.values()) { newDriver(type); @@ -139,4 +143,8 @@ public class ScoreboardManager extends Manager { driver.cancel(); drivers.clear(); } + + public Scoreboard getEmptyScoreboard() { + return emptyScoreboard; + } } From 7837c490cdf4357d417e38138f61b834a2aa20f9 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 5 Aug 2020 16:20:41 +0200 Subject: [PATCH 353/366] Update scoreboard type on scoreboard enable --- .../skyblock/command/commands/island/ScoreboardCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java index 3107cb34..d4489f43 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java @@ -8,6 +8,7 @@ import com.songoda.skyblock.playerdata.PlayerData; import com.songoda.skyblock.playerdata.PlayerDataManager; import com.songoda.skyblock.scoreboard.ScoreboardManager; import com.songoda.skyblock.sound.SoundManager; +import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -44,6 +45,9 @@ public class ScoreboardCommand extends SubCommand { } else { playerData.setScoreboard(true); scoreboardManager.removeDisabledPlayer(player); + Bukkit.getScheduler().runTask(plugin, () -> { + scoreboardManager.updatePlayerScoreboardType(player); + }); messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Enabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); From 1e74d196e98bc21a97dd82b370286b018a30c959 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 5 Aug 2020 22:19:09 +0200 Subject: [PATCH 354/366] Fix scoreboard flickering --- .../skyblock/command/commands/island/ScoreboardCommand.java | 5 ++--- .../com/songoda/skyblock/scoreboard/ScoreboardManager.java | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java index d4489f43..b72a1800 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ScoreboardCommand.java @@ -45,9 +45,8 @@ public class ScoreboardCommand extends SubCommand { } else { playerData.setScoreboard(true); scoreboardManager.removeDisabledPlayer(player); - Bukkit.getScheduler().runTask(plugin, () -> { - scoreboardManager.updatePlayerScoreboardType(player); - }); + Bukkit.getScheduler().runTask(plugin, () -> + scoreboardManager.updatePlayerScoreboardType(player)); messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Enabled.Message")); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F); diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index c97125ef..ec671537 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -98,10 +98,9 @@ public class ScoreboardManager extends Manager { public void setPlayerScoreboard(Player player, ScoreboardType type) { for(Driver driver : drivers) { + driver.unregisterHolder(player); if(driver.getBoardType().equals(type)) { driver.registerHolder(new Holder(plugin, driver, player)); - } else { - driver.unregisterHolder(player); } } } @@ -110,10 +109,12 @@ public class ScoreboardManager extends Manager { for(Driver driver : drivers) { driver.unregisterHolder(player); } + player.setScoreboard(emptyScoreboard); } public void addDisabledPlayer(Player player) { disabledPlayers.add(player); + Bukkit.getScheduler().runTask(plugin, () -> this.unregisterPlayer(player)); } public void removeDisabledPlayer(Player player) { From 97737608ddf07bb2f70d55b3288b2f20e893d701 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 5 Aug 2020 22:55:16 +0200 Subject: [PATCH 355/366] Added .0 to every value in levelling.yml --- src/main/resources/levelling.yml | 1600 +++++++++++++++--------------- 1 file changed, 800 insertions(+), 800 deletions(-) diff --git a/src/main/resources/levelling.yml b/src/main/resources/levelling.yml index bf96aa28..1efb714d 100644 --- a/src/main/resources/levelling.yml +++ b/src/main/resources/levelling.yml @@ -4,2401 +4,2401 @@ Materials: ACACIA_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 ACACIA_DOOR: Limit: -1 - Points: 1 + Points: 1.0 ACACIA_FENCE: Limit: -1 - Points: 2 + Points: 2.0 ACACIA_FENCE_GATE: Limit: -1 - Points: 4 + Points: 4.0 ACACIA_LEAVES: Limit: -1 - Points: 0 + Points: 0.0 ACACIA_LOG: Limit: -1 - Points: 0 + Points: 0.0 ACACIA_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 ACACIA_PRESSURE_PLATE: Limit: -1 - Points: 2 + Points: 2.0 ACACIA_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 ACACIA_SLAB: Limit: -1 - Points: 1 + Points: 1.0 ACACIA_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 ACACIA_TRAPDOOR: Limit: -1 - Points: 3 + Points: 3.0 ACACIA_WOOD: Limit: -1 - Points: 1 + Points: 1.0 ACTIVATOR_RAIL: Limit: -1 - Points: 1 + Points: 1.0 ALLIUM: Limit: -1 - Points: 1 + Points: 1.0 ANCIENT_DEBRIES: Limit: -1 - Points: 2 + Points: 2.0 ANDESITE: Limit: -1 - Points: 1 + Points: 1.0 ANDESITE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 ANDESITE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 ANDESITE_WALL: Limit: -1 - Points: 1 + Points: 1.0 ANVIL: Limit: -1 - Points: 10 + Points: 10.0 ATTACHED_MELON_STEM: Limit: -1 - Points: 1 + Points: 1.0 ATTACHED_PUMPKIN_STEM: Limit: -1 - Points: 1 + Points: 1.0 AZURE_BLUET: Limit: -1 - Points: 1 + Points: 1.0 BARRIER: Limit: -1 - Points: 0 + Points: 0.0 BAMBOO: Limit: -1 - Points: 1 + Points: 1.0 BAMBOO_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 BARREL: Limit: -1 - Points: 1 + Points: 1.0 BASALT: Limit: -1 - Points: 2 + Points: 2.0 BEACON: Limit: -1 - Points: 500 + Points: 500.0 BEDROCK: Limit: -1 - Points: 0 + Points: 0.0 BEETROOTS: Limit: -1 - Points: 1 + Points: 1.0 BEE_NEST: Limit: -1 - Points: 1 + Points: 1.0 BEEHIVE: Limit: -1 - Points: 1 + Points: 1.0 BELL: Limit: -1 - Points: 7 + Points: 7.0 BIRCH_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 BIRCH_DOOR: Limit: -1 - Points: 2 + Points: 2.0 BIRCH_FENCE: Limit: -1 - Points: 2 + Points: 2.0 BIRCH_FENCE_GATE: Limit: -1 - Points: 4 + Points: 4.0 BIRCH_LEAVES: Limit: -1 - Points: 0 + Points: 0.0 BIRCH_LOG: Limit: -1 - Points: 0 + Points: 0.0 BIRCH_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 BIRCH_PRESSURE_PLATE: Limit: -1 - Points: 2 + Points: 2.0 BIRCH_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 BIRCH_SIGN: Limit: -1 - Points: 6 + Points: 6.0 BIRCH_SLAB: Limit: -1 - Points: 1 + Points: 1.0 BIRCH_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 BIRCH_TRAPDOOR: Limit: -1 - Points: 3 + Points: 3.0 BIRCH_WALL_SIGN: Limit: -1 - Points: 6 + Points: 6.0 BIRCH_WOOD: Limit: -1 - Points: 1 + Points: 1.0 BLACK_BANNER: Limit: -1 - Points: 2 + Points: 2.0 BLACK_BED: Limit: -1 - Points: 6 + Points: 6.0 BLACK_CARPET: Limit: -1 - Points: 1 + Points: 1.0 BLACK_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 BLACK_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 BLACK_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 BLACK_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 BLACK_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 BLACK_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 BLACK_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 BLACK_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 BLACK_WOOL: Limit: -1 - Points: 2 + Points: 2.0 BLACKSTONE: Limit: -1 - Points: 2 + Points: 2.0 BLACKSTONE_STAIRS: Limit: -1 - Points: 5 + Points: 5.0 BLACKSTONE_WALL: Limit: -1 - Points: 5 + Points: 5.0 BLASTSTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 BLAST_FURNACE: Limit: -1 - Points: 6 + Points: 6.0 BLUE_BANNER: Limit: -1 - Points: 2 + Points: 2.0 BLUE_BED: Limit: -1 - Points: 6 + Points: 6.0 BLUE_CARPET: Limit: -1 - Points: 1 + Points: 1.0 BLUE_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 BLUE_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 BLUE_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 BLUE_ICE: Limit: -1 - Points: 1 + Points: 1.0 BLUE_ORCHID: Limit: -1 - Points: 1 + Points: 1.0 BLUE_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 BLUE_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 BLUE_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 BLUE_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 BLUE_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 BLUE_WOOL: Limit: -1 - Points: 2 + Points: 2.0 BONE_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 BOOKSHELF: Limit: -1 - Points: 5 + Points: 5.0 BRAIN_CORAL: Limit: -1 - Points: 1 + Points: 1.0 BRAIN_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 BRAIN_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 BRAIN_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 BREWING_STAND: Limit: -1 - Points: 20 + Points: 20.0 BRICKS: Limit: -1 - Points: 5 + Points: 5.0 BRICK_SLAB: Limit: -1 - Points: 3 + Points: 3.0 BRICK_STAIRS: Limit: -1 - Points: 5 + Points: 5.0 BRICK_WALL: Limit: -1 - Points: 3 + Points: 3.0 BROWN_BANNER: Limit: -1 - Points: 2 + Points: 2.0 BROWN_BED: Limit: -1 - Points: 6 + Points: 6.0 BROWN_CARPET: Limit: -1 - Points: 1 + Points: 1.0 BROWN_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 BROWN_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 BROWN_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 BROWN_MUSHROOM: Limit: -1 - Points: 1 + Points: 1.0 BROWN_MUSHROOM_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 BROWN_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 BROWN_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 BROWN_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 BROWN_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 BROWN_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 BROWN_WOOL: Limit: -1 - Points: 1 + Points: 1.0 BUBBLE_COLUMN: Limit: -1 - Points: 1 + Points: 1.0 BUBBLE_CORAL: Limit: -1 - Points: 1 + Points: 1.0 BUBBLE_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 BUBBLE_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 BUBBLE_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 CACTUS: Limit: -1 - Points: 1 + Points: 1.0 CAMPFIRE: Limit: -1 - Points: 2 + Points: 2.0 CAKE: Limit: -1 - Points: 9 + Points: 9.0 CARROTS: Limit: -1 - Points: 1 + Points: 1.0 CARTOGRAPHY_TABLE: Limit: -1 - Points: 5 + Points: 5.0 CARVED_PUMPKIN: Limit: -1 - Points: 2 + Points: 2.0 CAULDRON: Limit: -1 - Points: 10 + Points: 10.0 CAVE_AIR: Limit: -1 - Points: 0 + Points: 0.0 CHAIN: Limit: -1 - Points: 1 + Points: 1.0 CHAIN_COMMAND_BLOCK: Limit: -1 - Points: 0 + Points: 0.0 CHEST: Limit: -1 - Points: 8 + Points: 8.0 CHIPPED_ANVIL: Limit: -1 - Points: 9 + Points: 9.0 CHISELED_NETHER_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 CHISELED_POLISHED_BLACKSTONE: Limit: -1 - Points: 2 + Points: 2.0 CHISELED_QUARTZ_BLOCK: Limit: -1 - Points: 2 + Points: 2.0 CHISELED_RED_SANDSTONE: Limit: -1 - Points: 2 + Points: 2.0 CHISELED_SANDSTONE: Limit: -1 - Points: 2 + Points: 2.0 CHISELED_STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 CHORUS_FLOWER: Limit: -1 - Points: 1 + Points: 1.0 CHORUS_PLANT: Limit: -1 - Points: 1 + Points: 1.0 CLAY: Limit: -1 - Points: 2 + Points: 2.0 COAL_BLOCK: Limit: -1 - Points: 9 + Points: 9.0 COAL_ORE: Limit: -1 - Points: 1 + Points: 1.0 COARSE_DIRT: Limit: -1 - Points: 2 + Points: 2.0 COBBLESTONE: Limit: -1 - Points: 1 + Points: 1.0 COBBLESTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 COBBLESTONE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 COBBLESTONE_WALL: Limit: -1 - Points: 1 + Points: 1.0 COBWEB: Limit: -1 - Points: 10 + Points: 10.0 COCOA: Limit: -1 - Points: 1 + Points: 1.0 COMMAND_BLOCK: Limit: -1 - Points: 0 + Points: 0.0 COMPARATOR: Limit: -1 - Points: 10 + Points: 10.0 COMPOSTER: Limit: -1 - Points: 4 + Points: 4.0 CONDUIT: Limit: -1 - Points: 1 + Points: 1.0 CORNFLOWER: Limit: -1 - Points: 1 + Points: 1.0 CRACKED_NETHER_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 CRACKED_POLISHED_BLACKSTONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 CRACKED_STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 CRAFTING_TABLE: Limit: -1 - Points: 1 + Points: 1.0 CREEPER_HEAD: Limit: -1 - Points: 1 + Points: 1.0 CREEPER_WALL_HEAD: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_DOOR: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_FENCE: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_FENCE_GATE: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_FUNGUS: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_HYPHAE: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_NYLIUM: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_PRESSURE_PLATE: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_ROOTS: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_SIGN: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_SLAB: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_STEM: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_TRAPDOOR: Limit: -1 - Points: 1 + Points: 1.0 CRIMSON_WALL_SIGN: Limit: -1 - Points: 1 + Points: 1.0 CUT_RED_SANDSTONE: Limit: -1 - Points: 1 + Points: 1.0 CUT_RED_SANDSTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 CUT_SANDSTONE: Limit: -1 - Points: 1 + Points: 1.0 CUT_SANDSTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 CRYING_OBSIDIAN: Limit: -1 - Points: 20 + Points: 20.0 CYAN_BANNER: Limit: -1 - Points: 2 + Points: 2.0 CYAN_BED: Limit: -1 - Points: 6 + Points: 6.0 CYAN_CARPET: Limit: -1 - Points: 1 + Points: 1.0 CYAN_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 CYAN_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 CYAN_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 CYAN_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 CYAN_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 CYAN_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 CYAN_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 CYAN_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 CYAN_WOOL: Limit: -1 - Points: 2 + Points: 2.0 DAMAGED_ANVIL: Limit: -1 - Points: 5 + Points: 5.0 DANDELION: Limit: -1 - Points: 1 + Points: 1.0 DARK_OAK_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 DARK_OAK_DOOR: Limit: -1 - Points: 2 + Points: 2.0 DARK_OAK_FENCE: Limit: -1 - Points: 2 + Points: 2.0 DARK_OAK_FENCE_GATE: Limit: -1 - Points: 4 + Points: 4.0 DARK_OAK_LEAVES: Limit: -1 - Points: 0 + Points: 0.0 DARK_OAK_LOG: Limit: -1 - Points: 0 + Points: 0.0 DARK_OAK_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 DARK_OAK_PRESSURE_PLATE: Limit: -1 - Points: 2 + Points: 2.0 DARK_OAK_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 DARK_OAK_SIGN: Limit: -1 - Points: 6 + Points: 6.0 DARK_OAK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 DARK_OAK_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 DARK_OAK_TRAPDOOR: Limit: -1 - Points: 3 + Points: 3.0 DARK_OAK_WALL_SIGN: Limit: -1 - Points: 6 + Points: 6.0 DARK_OAK_WOOD: Limit: -1 - Points: 1 + Points: 1.0 DARK_PRISMARINE: Limit: -1 - Points: 1 + Points: 1.0 DARK_PRISMARINE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 DARK_PRISMARINE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 DAYLIGHT_DETECTOR: Limit: -1 - Points: 10 + Points: 10.0 DEAD_BRAIN_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 DEAD_BRAIN_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_BRAIN_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_BUBBLE_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 DEAD_BUBBLE_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_BUBBLE_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_BUSH: Limit: -1 - Points: 1 + Points: 1.0 DEAD_FIRE_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 DEAD_FIRE_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_FIRE_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_HORN_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 DEAD_HORN_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_HORN_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_TUBE_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 DEAD_TUBE_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DEAD_TUBE_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 DETECTOR_RAIL: Limit: -1 - Points: 10 + Points: 10.0 DIAMOND_BLOCK: Limit: -1 - Points: 300 + Points: 300.0 DIAMOND_ORE: Limit: -1 - Points: 1 + Points: 1.0 DIORITE: Limit: -1 - Points: 1 + Points: 1.0 DIORITE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 DIORITE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 DIORITE_WALL: Limit: -1 - Points: 1 + Points: 1.0 DIRT: Limit: -1 - Points: 3 + Points: 3.0 DISPENSER: Limit: -1 - Points: 5 + Points: 5.0 DRAGON_EGG: Limit: -1 - Points: 150 + Points: 150.0 DRAGON_HEAD: Limit: -1 - Points: 1 + Points: 1.0 DRAGON_WALL_HEAD: Limit: -1 - Points: 1 + Points: 1.0 DRIED_KELP_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 DROPPER: Limit: -1 - Points: 4 + Points: 4.0 EMERALD_BLOCK: Limit: -1 - Points: 150 + Points: 150.0 EMERALD_ORE: Limit: -1 - Points: 1 + Points: 1.0 ENCHANTING_TABLE: Limit: -1 - Points: 150 + Points: 150.0 ENDER_CHEST: Limit: -1 - Points: 150 + Points: 150.0 END_GATEWAY: Limit: -1 - Points: 0 + Points: 0.0 END_PORTAL: Limit: -1 - Points: 0 + Points: 0.0 END_PORTAL_FRAME: Limit: -1 - Points: 0 + Points: 0.0 END_ROD: Limit: -1 - Points: 1 + Points: 1.0 END_STONE: Limit: -1 - Points: 1 + Points: 1.0 END_STONE_BRICK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 END_STONE_BRICK_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 END_STONE_BRICK_WALL: Limit: -1 - Points: 1 + Points: 1.0 END_STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 FARMLAND: Limit: -1 - Points: 1 + Points: 1.0 FERN: Limit: -1 - Points: 1 + Points: 1.0 FIRE: Limit: -1 - Points: 0 + Points: 0.0 FIRE_CORAL: Limit: -1 - Points: 1 + Points: 1.0 FIRE_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 FIRE_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 FIRE_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 FLETCHING_TABLE: Limit: -1 - Points: 4 + Points: 4.0 FLOWER_POT: Limit: -1 - Points: 1 + Points: 1.0 FROSTED_ICE: Limit: -1 - Points: 1 + Points: 1.0 FURNACE: Limit: -1 - Points: 8 + Points: 8.0 GLASS: Limit: -1 - Points: 2 + Points: 2.0 GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 GILDED_BLACKSTONE: Limit: -1 - Points: 2 + Points: 2.0 GLOWSTONE: Limit: -1 - Points: 1 + Points: 1.0 GOLD_BLOCK: Limit: -1 - Points: 150 + Points: 150.0 GOLD_ORE: Limit: -1 - Points: 1 + Points: 1.0 GRANITE: Limit: -1 - Points: 1 + Points: 1.0 GRANITE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 GRANITE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 GRANITE_WALL: Limit: -1 - Points: 1 + Points: 1.0 GRASS: Limit: -1 - Points: 4 + Points: 4.0 GRASS_BLOCK: Limit: -1 - Points: 4 + Points: 4.0 GRASS_PATH: Limit: -1 - Points: 4 + Points: 4.0 GRAVEL: Limit: -1 - Points: 1 + Points: 1.0 GRAY_BANNER: Limit: -1 - Points: 2 + Points: 2.0 GRAY_BED: Limit: -1 - Points: 6 + Points: 6.0 GRAY_CARPET: Limit: -1 - Points: 1 + Points: 1.0 GRAY_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 GRAY_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 GRAY_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 GRAY_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 GRAY_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 GRAY_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 GRAY_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 GRAY_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 GRAY_WOOL: Limit: -1 - Points: 2 + Points: 2.0 GREEN_BANNER: Limit: -1 - Points: 2 + Points: 2.0 GREEN_BED: Limit: -1 - Points: 6 + Points: 6.0 GREEN_CARPET: Limit: -1 - Points: 1 + Points: 1.0 GREEN_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 GREEN_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 GREEN_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 GREEN_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 GREEN_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 GREEN_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 GREEN_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 GREEN_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 GREEN_WOOL: Limit: -1 - Points: 2 + Points: 2.0 GRINDSTONE: Limit: -1 - Points: 4 + Points: 4.0 HAY_BLOCK: Limit: -1 - Points: 2 + Points: 2.0 HEAVY_WEIGHTED_PRESSURE_PLATE: Limit: -1 - Points: 3 + Points: 3.0 HONEY_BLOCK: Limit: -1 - Points: 2 + Points: 2.0 HONEYCOMB_BLOCK: Limit: -1 - Points: 3 + Points: 3.0 HOPPER: Limit: -1 - Points: 5 + Points: 5.0 HORN_CORAL: Limit: -1 - Points: 1 + Points: 1.0 HORN_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 HORN_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 HORN_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 ICE: Limit: -1 - Points: 5 + Points: 5.0 INFESTED_CHISELED_STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 INFESTED_COBBLESTONE: Limit: -1 - Points: 1 + Points: 1.0 INFESTED_CRACKED_STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 INFESTED_MOSSY_STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 INFESTED_STONE: Limit: -1 - Points: 1 + Points: 1.0 INFESTED_STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 IRON_BARS: Limit: -1 - Points: 2 + Points: 2.0 IRON_BLOCK: Limit: -1 - Points: 10 + Points: 10.0 IRON_DOOR: Limit: -1 - Points: 5 + Points: 5.0 IRON_ORE: Limit: -1 - Points: 1 + Points: 1.0 IRON_TRAPDOOR: Limit: -1 - Points: 4 + Points: 4.0 JACK_O_LANTERN: Limit: -1 - Points: 2 + Points: 2.0 JIGSAW: Limit: -1 - Points: 4 + Points: 4.0 JUKEBOX: Limit: -1 - Points: 10 + Points: 10.0 JUNGLE_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 JUNGLE_DOOR: Limit: -1 - Points: 2 + Points: 2.0 JUNGLE_FENCE: Limit: -1 - Points: 2 + Points: 2.0 JUNGLE_FENCE_GATE: Limit: -1 - Points: 4 + Points: 4.0 JUNGLE_LEAVES: Limit: -1 - Points: 0 + Points: 0.0 JUNGLE_LOG: Limit: -1 - Points: 0 + Points: 0.0 JUNGLE_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 JUNGLE_PRESSURE_PLATE: Limit: -1 - Points: 2 + Points: 2.0 JUNGLE_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 JUNGLE_SIGN: Limit: -1 - Points: 6 + Points: 6.0 JUNGLE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 JUNGLE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 JUNGLE_TRAPDOOR: Limit: -1 - Points: 3 + Points: 3.0 JUNGLE_WALL_SIGN: Limit: -1 - Points: 6 + Points: 6.0 JUNGLE_WOOD: Limit: -1 - Points: 1 + Points: 1.0 KELP: Limit: -1 - Points: 1 + Points: 1.0 KELP_PLANT: Limit: -1 - Points: 1 + Points: 1.0 LADDER: Limit: -1 - Points: 2 + Points: 2.0 LANTERN: Limit: -1 - Points: 3 + Points: 3.0 LAPIS_BLOCK: Limit: -1 - Points: 10 + Points: 10.0 LAPIS_ORE: Limit: -1 - Points: 1 + Points: 1.0 LARGE_FERN: Limit: -1 - Points: 1 + Points: 1.0 LECTERN: Limit: -1 - Points: 4 + Points: 4.0 LEVER: Limit: -1 - Points: 1 + Points: 1.0 LIGHT_BLUE_BANNER: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_BLUE_BED: Limit: -1 - Points: 6 + Points: 6.0 LIGHT_BLUE_CARPET: Limit: -1 - Points: 1 + Points: 1.0 LIGHT_BLUE_CONCRETE: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_BLUE_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_BLUE_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 LIGHT_BLUE_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 LIGHT_BLUE_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_BLUE_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 LIGHT_BLUE_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_BLUE_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_BLUE_WOOL: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_GRAY_BANNER: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_GRAY_BED: Limit: -1 - Points: 6 + Points: 6.0 LIGHT_GRAY_CARPET: Limit: -1 - Points: 1 + Points: 1.0 LIGHT_GRAY_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 LIGHT_GRAY_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_GRAY_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 LIGHT_GRAY_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 LIGHT_GRAY_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_GRAY_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 LIGHT_GRAY_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_GRAY_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_GRAY_WOOL: Limit: -1 - Points: 2 + Points: 2.0 LIGHT_WEIGHTED_PRESSURE_PLATE: Limit: -1 - Points: 3 + Points: 3.0 LILAC: Limit: -1 - Points: 1 + Points: 1.0 LILY_OF_THE_VALLEY: Limit: -1 - Points: 1 + Points: 1.0 LILY_PAD: Limit: -1 - Points: 5 + Points: 5.0 LIME_BANNER: Limit: -1 - Points: 2 + Points: 2.0 LIME_BED: Limit: -1 - Points: 6 + Points: 6.0 LIME_CARPET: Limit: -1 - Points: 1 + Points: 1.0 LIME_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 LIME_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 LIME_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 LIME_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 LIME_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 LIME_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 LIME_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 LIME_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 LIME_WOOL: Limit: -1 - Points: 2 + Points: 2.0 LODESTONE: Limit: -1 - Points: 15 + Points: 15.0 LOOM: Limit: -1 - Points: 4 + Points: 4.0 MAGENTA_BANNER: Limit: -1 - Points: 2 + Points: 2.0 MAGENTA_BED: Limit: -1 - Points: 6 + Points: 6.0 MAGENTA_CARPET: Limit: -1 - Points: 1 + Points: 1.0 MAGENTA_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 MAGENTA_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 MAGENTA_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 MAGENTA_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 MAGENTA_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 MAGENTA_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 MAGENTA_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 MAGENTA_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 MAGENTA_WOOL: Limit: -1 - Points: 2 + Points: 2.0 MAGMA_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 MELON: Limit: -1 - Points: 1 + Points: 1.0 MELON_STEM: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_COBBLESTONE: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_COBBLESTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_COBBLESTONE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_COBBLESTONE_WALL: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_STONE_BRICK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_STONE_BRICK_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_STONE_BRICK_WALL: Limit: -1 - Points: 1 + Points: 1.0 MOSSY_STONE_BRICKS: Limit: -1 - Points: 1 + Points: 1.0 MOVING_PISTON: Limit: -1 - Points: 1 + Points: 1.0 MUSHROOM_STEM: Limit: -1 - Points: 1 + Points: 1.0 MYCELIUM: Limit: -1 - Points: 5 + Points: 5.0 NETHERRACK: Limit: -1 - Points: 1 + Points: 1.0 NETHER_BRICK_WALL: Limit: -1 - Points: 1 + Points: 1.0 NETHER_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 NETHER_BRICK_FENCE: Limit: -1 - Points: 2 + Points: 2.0 NETHER_BRICK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 NETHER_BRICK_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 NETHER_GOLD_ORE: Limit: -1 - Points: 2 + Points: 2.0 NETHER_PORTAL: Limit: -1 - Points: 1 + Points: 1.0 NETHER_QUARTZ_ORE: Limit: -1 - Points: 1 + Points: 1.0 NETHER_SPROUTS: Limit: -1 - Points: 1 + Points: 1.0 NETHER_WART: Limit: -1 - Points: 1 + Points: 1.0 NETHER_WART_BLOCK: Limit: -1 - Points: 2 + Points: 2.0 NETHERITE_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 NOTE_BLOCK: Limit: -1 - Points: 10 + Points: 10.0 OAK_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 OAK_DOOR: Limit: -1 - Points: 2 + Points: 2.0 OAK_FENCE: Limit: -1 - Points: 2 + Points: 2.0 OAK_FENCE_GATE: Limit: -1 - Points: 4 + Points: 4.0 OAK_LEAVES: Limit: -1 - Points: 0 + Points: 0.0 OAK_LOG: Limit: -1 - Points: 0 + Points: 0.0 OAK_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 OAK_PRESSURE_PLATE: Limit: -1 - Points: 2 + Points: 2.0 OAK_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 OAK_SIGN: Limit: -1 - Points: 6 + Points: 6.0 OAK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 OAK_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 OAK_TRAPDOOR: Limit: -1 - Points: 3 + Points: 3.0 OAK_WALL_SIGN: Limit: -1 - Points: 6 + Points: 6.0 OAK_WOOD: Limit: -1 - Points: 1 + Points: 1.0 OBSERVER: Limit: -1 - Points: 1 + Points: 1.0 OBSIDIAN: Limit: -1 - Points: 10 + Points: 10.0 ORANGE_BANNER: Limit: -1 - Points: 2 + Points: 2.0 ORANGE_BED: Limit: -1 - Points: 6 + Points: 6.0 ORANGE_CARPET: Limit: -1 - Points: 1 + Points: 1.0 ORANGE_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 ORANGE_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 ORANGE_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 ORANGE_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 ORANGE_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 ORANGE_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 ORANGE_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 ORANGE_TULIP: Limit: -1 - Points: 1 + Points: 1.0 ORANGE_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 ORANGE_WOOL: Limit: -1 - Points: 2 + Points: 2.0 OXEYE_DAISY: Limit: -1 - Points: 1 + Points: 1.0 PACKED_ICE: Limit: -1 - Points: 5 + Points: 5.0 PEONY: Limit: -1 - Points: 1 + Points: 1.0 PETRIFIED_OAK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 PINK_BANNER: Limit: -1 - Points: 2 + Points: 2.0 PINK_BED: Limit: -1 - Points: 6 + Points: 6.0 PINK_CARPET: Limit: -1 - Points: 1 + Points: 1.0 PINK_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 PINK_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 PINK_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 PINK_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 PINK_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 PINK_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 PINK_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 PINK_TULIP: Limit: -1 - Points: 1 + Points: 1.0 PINK_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 PINK_WOOL: Limit: -1 - Points: 2 + Points: 2.0 PISTON: Limit: -1 - Points: 2 + Points: 2.0 PISTON_HEAD: Limit: -1 - Points: 1 + Points: 1.0 PLAYER_HEAD: Limit: -1 - Points: 1 + Points: 1.0 PLAYER_WALL_HEAD: Limit: -1 - Points: 1 + Points: 1.0 PODZOL: Limit: -1 - Points: 2 + Points: 2.0 POLISHED_ANDESITE: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_ANDESITE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_ANDESITE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_BASALT: Limit: -1 - Points: 3 + Points: 3.0 POLISHED_BLACKSTONE: Limit: -1 - Points: 3 + Points: 3.0 POLISHED_BLACKSTONE_BRICKS: Limit: -1 - Points: 5 + Points: 5.0 POLISHED_BLACKSTONE_BRICK_SLAB: Limit: -1 - Points: 2 + Points: 2.0 POLISHED_BLACKSTONE_BRICK_STAIRS: Limit: -1 - Points: 3 + Points: 3.0 POLISHED_BLACKSTONE_BRICK_WALL: Limit: -1 - Points: 2 + Points: 2.0 POLISHED_BLACKSTONE_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_BLACKSTONE_PRESSURE_PLATE: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_BLACKSTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_BLACKSTONE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 POLISHED_BLACKSTONE_WALL: Limit: -1 - Points: 3 + Points: 3.0 POLISHED_DIORITE: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_DIORITE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_DIORITE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_GRANITE: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_GRANITE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 POLISHED_GRANITE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 POPPY: Limit: -1 - Points: 1 + Points: 1.0 POTATOES: Limit: -1 - Points: 1 + Points: 1.0 POTTED_ACACIA_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 POTTED_ALLIUM: Limit: -1 - Points: 1 + Points: 1.0 POTTED_AZURE_BLUET: Limit: -1 - Points: 1 + Points: 1.0 POTTED_BAMBOO: Limit: -1 - Points: 1 + Points: 1.0 POTTED_BIRCH_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 POTTED_BLUE_ORCHID: Limit: -1 - Points: 1 + Points: 1.0 POTTED_BROWN_MUSHROOM: Limit: -1 - Points: 1 + Points: 1.0 POTTED_CACTUS: Limit: -1 - Points: 1 + Points: 1.0 POTTED_CORNFLOWER: Limit: -1 - Points: 1 + Points: 1.0 POTTED_DANDELION: Limit: -1 - Points: 1 + Points: 1.0 POTTED_DARK_OAK_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 POTTED_DEAD_BUSH: Limit: -1 - Points: 1 + Points: 1.0 POTTED_FERN: Limit: -1 - Points: 1 + Points: 1.0 POTTED_JUNGLE_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 POTTED_LILY_OF_THE_VALLEY: Limit: -1 - Points: 1 + Points: 1.0 POTTED_OAK_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 POTTED_ORANGE_TULIP: Limit: -1 - Points: 1 + Points: 1.0 POTTED_OXEYE_DAISY: Limit: -1 - Points: 1 + Points: 1.0 POTTED_PINK_TULIP: Limit: -1 - Points: 1 + Points: 1.0 POTTED_POPPY: Limit: -1 - Points: 1 + Points: 1.0 POTTED_RED_MUSHROOM: Limit: -1 - Points: 1 + Points: 1.0 POTTED_RED_TULIP: Limit: -1 - Points: 1 + Points: 1.0 POTTED_SPRUCE_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 POTTED_WHITE_TULIP: Limit: -1 - Points: 1 + Points: 1.0 POTTED_WITHER_ROSE: Limit: -1 - Points: 1 + Points: 1.0 POWERED_RAIL: Limit: -1 - Points: 2 + Points: 2.0 PRISMARINE: Limit: -1 - Points: 1 + Points: 1.0 PRISMARINE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 PRISMARINE_BRICK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 PRISMARINE_BRICK_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 PRISMARINE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 PRISMARINE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 PRISMARINE_WALL: Limit: -1 - Points: 1 + Points: 1.0 PUMPKIN: Limit: -1 - Points: 1 + Points: 1.0 PUMPKIN_STEM: Limit: -1 - Points: 1 + Points: 1.0 PURPLE_BANNER: Limit: -1 - Points: 2 + Points: 2.0 PURPLE_BED: Limit: -1 - Points: 6 + Points: 6.0 PURPLE_CARPET: Limit: -1 - Points: 1 + Points: 1.0 PURPLE_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 PURPLE_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 PURPLE_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 PURPLE_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 PURPLE_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 PURPLE_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 PURPLE_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 PURPLE_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 PURPLE_WOOL: Limit: -1 - Points: 2 + Points: 2.0 PURPUR_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 PURPUR_PILLAR: Limit: -1 - Points: 1 + Points: 1.0 PURPUR_SLAB: Limit: -1 - Points: 1 + Points: 1.0 PURPUR_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 QUARTZ_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 QUARTZ_BRICKS: Limit: -1 - Points: 1 + Points: 1.0 QUARTZ_PILLAR: Limit: -1 - Points: 1 + Points: 1.0 QUARTZ_SLAB: Limit: -1 - Points: 1 + Points: 1.0 QUARTZ_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 RAIL: Limit: -1 - Points: 1 + Points: 1.0 REDSTONE_BLOCK: Limit: -1 - Points: 10 + Points: 10.0 REDSTONE_LAMP: Limit: -1 - Points: 10 + Points: 10.0 REDSTONE_ORE: Limit: -1 - Points: 1 + Points: 1.0 REDSTONE_TORCH: Limit: -1 - Points: 5 + Points: 5.0 REDSTONE_WALL_TORCH: Limit: -1 - Points: 5 + Points: 5.0 REDSTONE_WIRE: Limit: -1 - Points: 1 + Points: 1.0 RED_BED: Limit: -1 - Points: 6 + Points: 6.0 RED_CARPET: Limit: -1 - Points: 1 + Points: 1.0 RED_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 RED_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 RED_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 RED_MUSHROOM: Limit: -1 - Points: 1 + Points: 1.0 RED_MUSHROOM_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 RED_NETHER_BRICK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 RED_NETHER_BRICK_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 RED_NETHER_BRICK_WALL: Limit: -1 - Points: 1 + Points: 1.0 RED_NETHER_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 RED_SAND: Limit: -1 - Points: 1 + Points: 1.0 RED_SANDSTONE: Limit: -1 - Points: 1 + Points: 1.0 RED_SANDSTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 RED_SANDSTONE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 RED_SANDSTONE_WALL: Limit: -1 - Points: 1 + Points: 1.0 RED_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 RED_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 RED_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 RED_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 RED_TULIP: Limit: -1 - Points: 1 + Points: 1.0 RED_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 RED_WOOL: Limit: -1 - Points: 1 + Points: 1.0 REPEATER: Limit: -1 - Points: 6 + Points: 6.0 REPEATING_COMMAND_BLOCK: Limit: -1 - Points: 0 + Points: 0.0 RESPAWN_ANCHOR: Limit: -1 - Points: 20 + Points: 20.0 ROSE_BUSH: Limit: -1 - Points: 1 + Points: 1.0 SAND: Limit: -1 - Points: 1 + Points: 1.0 SANDSTONE: Limit: -1 - Points: 1 + Points: 1.0 SANDSTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 SANDSTONE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 SANDSTONE_WALL: Limit: -1 - Points: 1 + Points: 1.0 SCAFFOLDING: Limit: -1 - Points: 1 + Points: 1.0 SEAGRASS: Limit: -1 - Points: 1 + Points: 1.0 SEA_LANTERN: Limit: -1 - Points: 9 + Points: 9.0 SEA_PICKLE: Limit: -1 - Points: 1 + Points: 1.0 SHROOMLIGHT: Limit: -1 - Points: 2 + Points: 2.0 SHULKER_BOX: Limit: -1 - Points: 10 + Points: 10.0 SKELETON_SKULL: Limit: -1 - Points: 10 + Points: 10.0 SKELETON_WALL_SKULL: Limit: -1 - Points: 10 + Points: 10.0 SLIME_BLOCK: Limit: -1 - Points: 10 + Points: 10.0 SMITHING_TABLE: Limit: -1 - Points: 4 + Points: 4.0 SMOKER: Limit: -1 - Points: 4 + Points: 4.0 SMOOTH_QUARTZ: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_QUARTZ_SLAB: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_QUARTZ_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_RED_SANDSTONE: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_SANDSTONE: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_SANDSTONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_SANDSTONE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_STONE: Limit: -1 - Points: 1 + Points: 1.0 SMOOTH_STONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 SNOW: Limit: -1 - Points: 1 + Points: 1.0 SNOW_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 SOUL_CAMPFIRE: Limit: -1 - Points: 1 + Points: 1.0 SOUL_LANTERN: Limit: -1 - Points: 1 + Points: 1.0 SOUL_SAND: Limit: -1 - Points: 1 + Points: 1.0 SOUL_SOIL: Limit: -1 - Points: 1 + Points: 1.0 SOUL_TORCH: Limit: -1 - Points: 0 + Points: 0.0 SOUL_WALL_TORCH: Limit: -1 - Points: 0 + Points: 0.0 SPAWNER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_BAT: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_BLAZE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_CAVE_SPIDER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_CHICKEN: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_COD: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_COW: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_CREEPER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_DOLPHIN: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_DONKEY: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_DROWNED: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ELDER_GUARDIAN: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ENDER_DRAGON: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ENDERMAN: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ENDERMITE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_EVOKER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_GHAST: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_GIANT: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_GUARDIAN: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_HORSE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_HUSK: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ILLUSIONER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_IRON_GOLEM: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_LLAMA: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_MAGMA_CUBE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_MULE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_MUSHROOM_COW: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_OCELOT: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_PARROT: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_PHANTOM: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_PIG: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_PIG_ZOMBIE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_POLAR_BEAR: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_PUFFERFISH: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_RABBIT: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SALMON: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SHEEP: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SHULKER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SILVERFISH: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SKELETON: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SKELETON_HORSE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SLIME: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SNOWMAN: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SPIDER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_SQUID: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_STRAY: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_TROPICAL_FISH: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_TURTLE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_VEX: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_VILLAGER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_VINDICATOR: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_WITCH: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_WITHER: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_WITHER_SKELETON: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_WOLF: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ZOMBIE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ZOMBIE_HORSE: Limit: -1 - Points: 10 + Points: 10.0 SPAWNER_ZOMBIE_VILLAGER: Limit: -1 - Points: 10 + Points: 10.0 SPONGE: Limit: -1 - Points: 10 + Points: 10.0 SPRUCE_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 SPRUCE_DOOR: Limit: -1 - Points: 2 + Points: 2.0 SPRUCE_FENCE: Limit: -1 - Points: 2 + Points: 2.0 SPRUCE_FENCE_GATE: Limit: -1 - Points: 4 + Points: 4.0 SPRUCE_LEAVES: Limit: -1 - Points: 0 + Points: 0.0 SPRUCE_LOG: Limit: -1 - Points: 0 + Points: 0.0 SPRUCE_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 SPRUCE_PRESSURE_PLATE: Limit: -1 - Points: 2 + Points: 2.0 SPRUCE_SAPLING: Limit: -1 - Points: 1 + Points: 1.0 SPRUCE_SIGN: Limit: -1 - Points: 6 + Points: 6.0 SPRUCE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 SPRUCE_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 SPRUCE_TRAPDOOR: Limit: -1 - Points: 3 + Points: 3.0 SPRUCE_WALL_SIGN: Limit: -1 - Points: 6 + Points: 6.0 SPRUCE_WOOD: Limit: -1 - Points: 1 + Points: 1.0 STICKY_PISTON: Limit: -1 - Points: 1 + Points: 1.0 STONE: Limit: -1 - Points: 1 + Points: 1.0 STONE_BRICKS: Limit: -1 - Points: 2 + Points: 2.0 STONE_BRICK_SLAB: Limit: -1 - Points: 1 + Points: 1.0 STONE_BRICK_STAIRS: Limit: -1 - Points: 2 + Points: 2.0 STONE_BRICK_WALL: Limit: -1 - Points: 1 + Points: 1.0 STONE_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 STONECUTTER: Limit: -1 - Points: 4 + Points: 4.0 STONE_PRESSURE_PLATE: Limit: -1 - Points: 2 + Points: 2.0 STONE_SLAB: Limit: -1 - Points: 1 + Points: 1.0 STONE_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 STRIPPED_ACACIA_LOG: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_ACACIA_WOOD: Limit: -1 - Points: 1 + Points: 1.0 STRIPPED_BIRCH_LOG: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_BIRCH_WOOD: Limit: -1 - Points: 1 + Points: 1.0 STRIPPED_CRIMSON_HYPHAE: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_CRIMSON_STEM: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_DARK_OAK_LOG: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_DARK_OAK_WOOD: Limit: -1 - Points: 1 + Points: 1.0 STRIPPED_JUNGLE_LOG: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_JUNGLE_WOOD: Limit: -1 - Points: 1 + Points: 1.0 STRIPPED_OAK_LOG: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_OAK_WOOD: Limit: -1 - Points: 1 + Points: 1.0 STRIPPED_SPRUCE_LOG: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_SPRUCE_WOOD: Limit: -1 - Points: 1 + Points: 1.0 STRIPPED_WARPED_HYPHAE: Limit: -1 - Points: 0 + Points: 0.0 STRIPPED_WARPED_STEM: Limit: -1 - Points: 0 + Points: 0.0 SUGAR_CANE: Limit: -1 - Points: 1 + Points: 1.0 SUNFLOWER: Limit: -1 - Points: 1 + Points: 1.0 SWEET_BERRY_BUSH: Limit: -1 - Points: 1 + Points: 1.0 TALL_GRASS: Limit: -1 - Points: 1 + Points: 1.0 TALL_SEAGRASS: Limit: -1 - Points: 1 + Points: 1.0 TARGET: Limit: -1 - Points: 1 + Points: 1.0 TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 TNT: Limit: -1 - Points: 5 + Points: 5.0 TORCH: Limit: -1 - Points: 1 + Points: 1.0 TRAPPED_CHEST: Limit: -1 - Points: 10 + Points: 10.0 TRIPWIRE: Limit: -1 - Points: 2 + Points: 2.0 TRIPWIRE_HOOK: Limit: -1 - Points: 2 + Points: 2.0 TUBE_CORAL: Limit: -1 - Points: 1 + Points: 1.0 TUBE_CORAL_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 TUBE_CORAL_FAN: Limit: -1 - Points: 1 + Points: 1.0 TUBE_CORAL_WALL_FAN: Limit: -1 - Points: 1 + Points: 1.0 TURTLE_EGG: Limit: -1 - Points: 1 + Points: 1.0 TWISTING_VINES: Limit: -1 - Points: 1 + Points: 1.0 TWISTING_VINES_PLANT: Limit: -1 - Points: 1 + Points: 1.0 VINE: Limit: -1 - Points: 1 + Points: 1.0 VOID_AIR: Limit: -1 - Points: 0 + Points: 0.0 WALL_TORCH: Limit: -1 - Points: 1 + Points: 1.0 WARPED_BUTTON: Limit: -1 - Points: 1 + Points: 1.0 WARPED_DOOR: Limit: -1 - Points: 1 + Points: 1.0 WARPED_FENCE: Limit: -1 - Points: 1 + Points: 1.0 WARPED_FENCE_GATE: Limit: -1 - Points: 1 + Points: 1.0 WARPED_FUNGUS: Limit: -1 - Points: 1 + Points: 1.0 WARPED_HYPHAE: Limit: -1 - Points: 1 + Points: 1.0 WARPED_NYLIUM: Limit: -1 - Points: 1 + Points: 1.0 WARPED_PLANKS: Limit: -1 - Points: 1 + Points: 1.0 WARPED_PRESSURE_PLATE: Limit: -1 - Points: 1 + Points: 1.0 WARPED_ROOTS: Limit: -1 - Points: 1 + Points: 1.0 WARPED_SIGN: Limit: -1 - Points: 1 + Points: 1.0 WARPED_SLAB: Limit: -1 - Points: 1 + Points: 1.0 WARPED_STAIRS: Limit: -1 - Points: 1 + Points: 1.0 WARPED_STEM: Limit: -1 - Points: 1 + Points: 1.0 WARPED_TRAPDOOR: Limit: -1 - Points: 1 + Points: 1.0 WARPED_WALL_SIGN: Limit: -1 - Points: 1 + Points: 1.0 WARPED_WART_BLOCK: Limit: -1 - Points: 1 + Points: 1.0 WEEPING_VINES: Limit: -1 - Points: 1 + Points: 1.0 WEEPING_VINES_PLANT: Limit: -1 - Points: 1 + Points: 1.0 WET_SPONGE: Limit: -1 - Points: 10 + Points: 10.0 WHEAT: Limit: -1 - Points: 1 + Points: 1.0 WHITE_BANNER: Limit: -1 - Points: 2 + Points: 2.0 WHITE_BED: Limit: -1 - Points: 6 + Points: 6.0 WHITE_CARPET: Limit: -1 - Points: 1 + Points: 1.0 WHITE_CONCRETE: Limit: -1 - Points: 3 + Points: 3.0 WHITE_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 WHITE_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 WHITE_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 WHITE_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 WHITE_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 WHITE_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 WHITE_TULIP: Limit: -1 - Points: 1 + Points: 1.0 WHITE_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 WHITE_WOOL: Limit: -1 - Points: 3 + Points: 3.0 WITHER_ROSE: Limit: -1 - Points: 1 + Points: 1.0 WITHER_SKELETON_SKULL: Limit: -1 - Points: 10 + Points: 10.0 WITHER_SKELETON_WALL_SKULL: Limit: -1 - Points: 10 + Points: 10.0 YELLOW_BANNER: Limit: -1 - Points: 2 + Points: 2.0 YELLOW_BED: Limit: -1 - Points: 6 + Points: 6.0 YELLOW_CARPET: Limit: -1 - Points: 1 + Points: 1.0 YELLOW_CONCRETE: Limit: -1 - Points: 2 + Points: 2.0 YELLOW_CONCRETE_POWDER: Limit: -1 - Points: 2 + Points: 2.0 YELLOW_GLAZED_TERRACOTTA: Limit: -1 - Points: 5 + Points: 5.0 YELLOW_SHULKER_BOX: Limit: -1 - Points: 11 + Points: 11.0 YELLOW_STAINED_GLASS: Limit: -1 - Points: 2 + Points: 2.0 YELLOW_STAINED_GLASS_PANE: Limit: -1 - Points: 1 + Points: 1.0 YELLOW_TERRACOTTA: Limit: -1 - Points: 2 + Points: 2.0 YELLOW_WALL_BANNER: Limit: -1 - Points: 2 + Points: 2.0 YELLOW_WOOL: Limit: -1 - Points: 2 + Points: 2.0 ZOMBIE_HEAD: Limit: -1 - Points: 1 + Points: 1.0 ZOMBIE_WALL_HEAD: Limit: -1 - Points: 1 \ No newline at end of file + Points: 1.0 \ No newline at end of file From 389b3d779eb2f8d82603d4431426dcf22a81b5bd Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 5 Aug 2020 23:03:53 +0200 Subject: [PATCH 356/366] Modified sentence in help --- src/main/resources/language.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 8c4ec696..bc6bdc7a 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -201,7 +201,7 @@ Command: NotANumber: Message: '&bSkyBlock &8| &cError&8: &eThe provided value is not valid.' Info: - Message: '&f&oEdit all the islands in one time.' + Message: '&f&oEdit all the islands at once.' Bank: Short01: Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank []' From 8f41ae6ee3e82e2e4502cd45ee6fe5aeb749f21d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 5 Aug 2020 23:05:52 +0200 Subject: [PATCH 357/366] 2.3.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 917db08a..3438c1f2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.6-DEV4 + 2.3.6 jar UTF-8 From 0da43a9b55599ef35f4333f1b9b6f3892046f6b1 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 6 Aug 2020 15:46:10 +0200 Subject: [PATCH 358/366] Fixed npe in scoreboard manager --- .../java/com/songoda/skyblock/SkyBlock.java | 6 +- .../songoda/skyblock/scoreboard/Board.java | 12 +- .../songoda/skyblock/scoreboard/Driver.java | 16 +-- .../songoda/skyblock/scoreboard/Holder.java | 34 ++--- .../com/songoda/skyblock/scoreboard/Row.java | 6 +- .../skyblock/scoreboard/ScoreboardLine.java | 6 +- .../scoreboard/ScoreboardManager.java | 120 +++++++++++------- 7 files changed, 112 insertions(+), 88 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 0d9c3ee4..0591378f 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -151,11 +151,7 @@ public class SkyBlock extends SongodaPlugin { cooldownManager = new CooldownManager(this); limitationHandler = new LimitationInstanceHandler(); fabledChallenge = new FabledChallenge(this); - - if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) { - scoreboardManager = new ScoreboardManager(this); - } - + scoreboardManager = new ScoreboardManager(this); inviteManager = new InviteManager(this); biomeManager = new BiomeManager(this); levellingManager = new IslandLevelManager(this); diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Board.java b/src/main/java/com/songoda/skyblock/scoreboard/Board.java index 530c4cc0..5b4fe650 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Board.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Board.java @@ -16,12 +16,12 @@ class Board { private final Player player; private final SkyBlock plugin; - public Scoreboard board; + private final Scoreboard board; private final Objective objective; private final HashMap cache = new HashMap<>(); - public Board(SkyBlock plugin, Player player, int lineCount) { + Board(SkyBlock plugin, Player player, int lineCount) { this.player = player; this.plugin = plugin; this.board = this.plugin.getServer().getScoreboardManager().getNewScoreboard(); @@ -41,7 +41,7 @@ class Board { } } - public void setTitle(String string) { + void setTitle(String string) { PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); if(string == null) string = ""; @@ -54,7 +54,7 @@ class Board { } } - public void setLine(int line, String string) { + void setLine(int line, String string) { Team t = board.getTeam(String.valueOf(line)); if(string == null) string = ""; @@ -74,6 +74,10 @@ class Board { } } + Scoreboard getBoard() { + return board; + } + private ScoreboardLine convertIntoPieces(String line, int allowed_line_size) { String prefixLine = line.substring(0, Math.min(line.length(), allowed_line_size)); String suffixLine = line.length() <= allowed_line_size ? "" : line.substring(allowed_line_size, Math.min(line.length(), allowed_line_size*2)); diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java index f48599c4..985b8d1a 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java @@ -21,7 +21,7 @@ class Driver extends BukkitRunnable { private final List holders; private final ScoreboardType boardType; - public Driver(SkyBlock plugin, ScoreboardType boardType) { + Driver(SkyBlock plugin, ScoreboardType boardType) { this.plugin = plugin; FileManager fileManager = plugin.getFileManager(); FileConfiguration scoreboardLoad = fileManager.getConfig( @@ -50,27 +50,27 @@ class Driver extends BukkitRunnable { } } - public List getRows() { + List getRows() { return rows; } - public Row getTitle() { + Row getTitle() { return title; } - public void registerHolder(Holder holder) { + void registerHolder(Holder holder) { holders.add(holder); } - public void unregisterHolder(Holder holder) { + void unregisterHolder(Holder holder) { holders.remove(holder); } - public void unregisterHolder(Player player) { + void unregisterHolder(Player player) { Iterator it = holders.iterator(); while(it.hasNext()) { Holder holder = it.next(); - if(holder.player.equals(player)) { + if(holder.getPlayer().equals(player)) { it.remove(); break; } @@ -89,7 +89,7 @@ class Driver extends BukkitRunnable { } } - public ScoreboardType getBoardType() { + ScoreboardType getBoardType() { return boardType; } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java index ed21cfe9..ce42e19b 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java @@ -9,11 +9,11 @@ class Holder { private final SkyBlock plugin; private final Driver driver; - public final Player player; + private final Player player; private final Board board; - public Holder(SkyBlock plugin, Driver driver, Player player) { + Holder(SkyBlock plugin, Driver driver, Player player) { this.plugin = plugin; this.driver = driver; this.player = player; @@ -22,26 +22,28 @@ class Holder { update(); } - public void update() { + void update() { PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); - if(scoreboardManager != null) { - if (!scoreboardManager.isPlayerDisabled(player)) { - board.setTitle(driver.getTitle().getLine()); + if (!scoreboardManager.isPlayerDisabled(player)) { + board.setTitle(driver.getTitle().getLine()); - int count = 0; - for(Row row : driver.getRows()) { - String line = placeholderManager.parsePlaceholders(player, row.getLine()); - board.setLine(count, line); - count++; - } - - this.player.setScoreboard(board.board); - } else { - this.player.setScoreboard(scoreboardManager.getEmptyScoreboard()); + int count = 0; + for(Row row : driver.getRows()) { + String line = placeholderManager.parsePlaceholders(player, row.getLine()); + board.setLine(count, line); + count++; } + + this.player.setScoreboard(board.getBoard()); + } else { + this.player.setScoreboard(scoreboardManager.getEmptyScoreboard()); } } + Player getPlayer() { + return player; + } + } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Row.java b/src/main/java/com/songoda/skyblock/scoreboard/Row.java index e20f9b8f..bd0c3b2d 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Row.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Row.java @@ -14,7 +14,7 @@ class Row { public boolean static_line; - public Row(List lines, int interval) { + Row(List lines, int interval) { this.lines = lines; this.interval = interval; this.current = 0; @@ -29,7 +29,7 @@ class Row { } } - public void update() { + void update() { if (!static_line) { if (count >= interval) { count = 0; @@ -43,7 +43,7 @@ class Row { } } - public String getLine() { + String getLine() { return this.line; } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java index 0096f37d..c23ca2b9 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardLine.java @@ -5,7 +5,7 @@ class ScoreboardLine { private final String prefix; private final String suffix; - public ScoreboardLine(String prefix, String suffix, int limit) { + ScoreboardLine(String prefix, String suffix, int limit) { if(prefix.length() > limit) { prefix = prefix.substring(0, limit); } @@ -16,11 +16,11 @@ class ScoreboardLine { this.suffix = suffix; } - public String getPrefix() { + String getPrefix() { return prefix; } - public String getSuffix() { + String getSuffix() { return suffix; } } diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java index ec671537..3ebd1f04 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java @@ -21,21 +21,29 @@ import java.util.Set; public class ScoreboardManager extends Manager { + private final boolean enabled; private final Scoreboard emptyScoreboard; private final List drivers; private final Set disabledPlayers; public ScoreboardManager(SkyBlock plugin) { super(plugin); + FileManager fileManager = plugin.getFileManager(); + + this.enabled = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")) + .getFileConfiguration().getBoolean("Island.Scoreboard.Enable", true); + this.drivers = new ArrayList<>(); this.disabledPlayers = new ConcurrentSet<>(); this.emptyScoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - for(ScoreboardType type : ScoreboardType.values()) { - newDriver(type); + if(enabled) { + for(ScoreboardType type : ScoreboardType.values()) { + newDriver(type); + } + + updateOnlinePlayers(); } - - updateOnlinePlayers(); } @Override @@ -50,46 +58,50 @@ public class ScoreboardManager extends Manager { } public void updateOnlinePlayers() { - for(Player player : plugin.getServer().getOnlinePlayers()) { - updatePlayerScoreboardType(player); + if(enabled) { + for(Player player : plugin.getServer().getOnlinePlayers()) { + updatePlayerScoreboardType(player); + } } } public void updatePlayerScoreboardType(Player player) { - PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); - IslandManager islandManager = plugin.getIslandManager(); - - PlayerData playerData = playerDataManager.getPlayerData(player); - Island island = islandManager.getIslandByPlayer(player); - - if(playerData.isScoreboard()) { - ScoreboardType type; - if(island != null) { - Visit islandVisit = island.getVisit(); - boolean hasVisitors = (islandVisit != null && - islandVisit.getVisitors() != null && - islandVisit.getVisitors().size() > 1); - boolean hasMembers = (islandVisit != null && - islandVisit.getMembers() > 1); - - if(hasMembers) { - if(hasVisitors) { - type = ScoreboardType.ISLAND_TEAM_VISITORS; + if(enabled) { + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + IslandManager islandManager = plugin.getIslandManager(); + + PlayerData playerData = playerDataManager.getPlayerData(player); + Island island = islandManager.getIslandByPlayer(player); + + if(playerData.isScoreboard()) { + ScoreboardType type; + if(island != null) { + Visit islandVisit = island.getVisit(); + boolean hasVisitors = (islandVisit != null && + islandVisit.getVisitors() != null && + islandVisit.getVisitors().size() > 1); + boolean hasMembers = (islandVisit != null && + islandVisit.getMembers() > 1); + + if(hasMembers) { + if(hasVisitors) { + type = ScoreboardType.ISLAND_TEAM_VISITORS; + } else { + type = ScoreboardType.ISLAND_TEAM_EMPTY; + } } else { - type = ScoreboardType.ISLAND_TEAM_EMPTY; + if(hasVisitors) { + type = ScoreboardType.ISLAND_SOLO_VISITORS; + } else { + type = ScoreboardType.ISLAND_SOLO_EMPTY; + } } } else { - if(hasVisitors) { - type = ScoreboardType.ISLAND_SOLO_VISITORS; - } else { - type = ScoreboardType.ISLAND_SOLO_EMPTY; - } + type = ScoreboardType.NO_ISLAND; + } + synchronized (player) { + setPlayerScoreboard(player, type); } - } else { - type = ScoreboardType.NO_ISLAND; - } - synchronized (player) { - setPlayerScoreboard(player, type); } } } @@ -97,28 +109,36 @@ public class ScoreboardManager extends Manager { public void setPlayerScoreboard(Player player, ScoreboardType type) { - for(Driver driver : drivers) { - driver.unregisterHolder(player); - if(driver.getBoardType().equals(type)) { - driver.registerHolder(new Holder(plugin, driver, player)); + if(enabled) { + for(Driver driver : drivers) { + driver.unregisterHolder(player); + if(driver.getBoardType().equals(type)) { + driver.registerHolder(new Holder(plugin, driver, player)); + } } } } public void unregisterPlayer(Player player) { - for(Driver driver : drivers) { - driver.unregisterHolder(player); + if(enabled) { + for(Driver driver : drivers) { + driver.unregisterHolder(player); + } + player.setScoreboard(emptyScoreboard); } - player.setScoreboard(emptyScoreboard); } public void addDisabledPlayer(Player player) { - disabledPlayers.add(player); - Bukkit.getScheduler().runTask(plugin, () -> this.unregisterPlayer(player)); + if(enabled) { + disabledPlayers.add(player); + Bukkit.getScheduler().runTask(plugin, () -> this.unregisterPlayer(player)); + } } public void removeDisabledPlayer(Player player) { - disabledPlayers.remove(player); + if(enabled) { + disabledPlayers.remove(player); + } } public boolean isPlayerDisabled(Player player) { @@ -140,9 +160,11 @@ public class ScoreboardManager extends Manager { } public void clearDrivers() { - for(Driver driver : drivers) - driver.cancel(); - drivers.clear(); + if(enabled) { + for(Driver driver : drivers) + driver.cancel(); + drivers.clear(); + } } public Scoreboard getEmptyScoreboard() { From 168a204a6a776cb213c5792db901870f2e8a32e3 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 6 Aug 2020 18:04:25 +0200 Subject: [PATCH 359/366] Restore biome generation on pre-1.16 --- .../world/generator/VoidGenerator.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java index 672cc9fa..87ab3db6 100644 --- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java +++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java @@ -29,28 +29,26 @@ public class VoidGenerator extends ChunkGenerator { final Configuration configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration(); final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World"); - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { - Biome biome; - - switch (world.getEnvironment()) { - case NORMAL: - biome = CompatibleBiome.valueOf(configLoad.getString("Island.Biome.Default.Type", "PLAINS").toUpperCase()).getBiome(); - break; - case NETHER: - biome = CompatibleBiome.NETHER_WASTES.getBiome(); - break; - case THE_END: - biome = CompatibleBiome.THE_END.getBiome(); - break; - default: - throw new IllegalStateException("Unexpected value: " + world.getEnvironment()); - } - - if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there - setChunkBiome3D(biome, biomeGrid, world); - } else { - setChunkBiome2D(biome, biomeGrid); - } + Biome biome; + + switch (world.getEnvironment()) { + case NORMAL: + biome = CompatibleBiome.valueOf(configLoad.getString("Island.Biome.Default.Type", "PLAINS").toUpperCase()).getBiome(); + break; + case NETHER: + biome = CompatibleBiome.NETHER_WASTES.getBiome(); + break; + case THE_END: + biome = CompatibleBiome.THE_END.getBiome(); + break; + default: + throw new IllegalStateException("Unexpected value: " + world.getEnvironment()); + } + + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { // TODO Should be 1.15 but it works fine there + setChunkBiome3D(biome, biomeGrid, world); + } else { + setChunkBiome2D(biome, biomeGrid); } for (IslandWorld worldList : IslandWorld.values()) { From b7a09b76a2156e7a06d480d4d43f5a1e2358f51d Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Thu, 6 Aug 2020 18:28:21 +0200 Subject: [PATCH 360/366] Removed null check in scoreboard manager --- .../commands/island/AcceptCommand.java | 15 ++++------ .../commands/island/ConfirmCommand.java | 12 ++------ .../command/commands/island/KickCommand.java | 8 ++---- .../command/commands/island/LeaveCommand.java | 12 +++----- .../skyblock/island/IslandManager.java | 28 ++++++++----------- .../com/songoda/skyblock/listeners/Join.java | 2 +- .../playerdata/PlayerDataManager.java | 14 ++++------ 7 files changed, 33 insertions(+), 58 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java index baf485de..2e64c606 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java @@ -140,20 +140,17 @@ public class AcceptCommand extends SubCommand { soundManager.playSound(loopPlayer, CompatibleSound.ENTITY_FIREWORK_ROCKET_BLAST.getSound(), 1.0F, 1.0F); - if (scoreboardManager != null) { - if (island.getRole(IslandRole.Member).size() == 1 - && island.getRole(IslandRole.Operator).size() == 0) { - scoreboardManager.updatePlayerScoreboardType(loopPlayer); - } + + if (island.getRole(IslandRole.Member).size() == 1 + && island.getRole(IslandRole.Operator).size() == 0) { + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } } } } } - - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + + scoreboardManager.updatePlayerScoreboardType(player); } } else { messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Owner.Message")); diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java index 780b5b56..33d50114 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java @@ -111,17 +111,13 @@ public class ConfirmCommand extends SubCommand { soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F); } Bukkit.getScheduler().runTask(plugin, () -> { - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + scoreboardManager.updatePlayerScoreboardType(player); }); } else if (confirmation.equals(Confirmation.Reset)) { playerData.setConfirmation(null); playerData.setConfirmationTime(0); Bukkit.getScheduler().runTask(plugin, () -> { - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + scoreboardManager.updatePlayerScoreboardType(player); }); } else if (confirmation.equals(Confirmation.Deletion)) { if (island.getStatus().equals(IslandStatus.OPEN)) { @@ -188,9 +184,7 @@ public class ConfirmCommand extends SubCommand { } } Bukkit.getScheduler().runTask(plugin, () -> { - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + scoreboardManager.updatePlayerScoreboardType(player); }); } } else { 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 d694ae16..6bc055ce 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 @@ -147,9 +147,7 @@ public class KickCommand extends SubCommand { Player finalTargetPlayer = targetPlayer; Bukkit.getScheduler().runTask(plugin, () -> { - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(finalTargetPlayer); - } + scoreboardManager.updatePlayerScoreboardType(player); }); playerData = playerDataManager.getPlayerData(targetPlayer); @@ -186,9 +184,7 @@ public class KickCommand extends SubCommand { } Bukkit.getScheduler().runTask(plugin, () -> { - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + scoreboardManager.updatePlayerScoreboardType(player); }); } } else { diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java index 98d6de8b..b0dec378 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/LeaveCommand.java @@ -105,10 +105,8 @@ public class LeaveCommand extends SubCommand { if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) { - if (scoreboardManager != null) { - if (islandManager.getVisitorsAtIsland(island).size() != 0) { - scoreboardManager.updatePlayerScoreboardType(loopPlayer); - } + if (islandManager.getVisitorsAtIsland(island).size() != 0) { + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } break; @@ -120,10 +118,8 @@ public class LeaveCommand extends SubCommand { messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Leave.Left.Sender.Message")); soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 5.0F, 5.0F); - - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + + scoreboardManager.updatePlayerScoreboardType(player); } } } diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index d3c93679..98638e4b 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -263,9 +263,7 @@ public class IslandManager { data.setOwner(player.getUniqueId()); Bukkit.getScheduler().runTask(plugin, () -> { - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(player); - } + scoreboardManager.updatePlayerScoreboardType(player); }); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { @@ -950,9 +948,7 @@ public class IslandManager { island.hasRole(IslandRole.Operator, loopPlayer.getUniqueId()) || island.hasRole(IslandRole.Owner, loopPlayer.getUniqueId()) || island.getCoopType(loopPlayer.getUniqueId()) == IslandCoop.NORMAL) { - if (scoreboardManager != null) { - scoreboardManager.updatePlayerScoreboardType(loopPlayer); - } + scoreboardManager.updatePlayerScoreboardType(loopPlayer); unloadIsland = false; } @@ -1190,18 +1186,16 @@ public class IslandManager { .getFileConfiguration().getString("Island.Teleport.Unsafe.Message"))); } } else { - if (scoreboardManager != null) { - int islandVisitors = getVisitorsAtIsland(island).size(); - - if (islandVisitors == 0) { - for (Player loopPlayer : Bukkit.getOnlinePlayers()) { - PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(loopPlayer); + int islandVisitors = getVisitorsAtIsland(island).size(); - if (targetPlayerData != null && - targetPlayerData.getOwner() != null && - targetPlayerData.getOwner().equals(island.getOwnerUUID())) { - scoreboardManager.updatePlayerScoreboardType(loopPlayer); - } + if (islandVisitors == 0) { + for (Player loopPlayer : Bukkit.getOnlinePlayers()) { + PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(loopPlayer); + + if (targetPlayerData != null && + targetPlayerData.getOwner() != null && + targetPlayerData.getOwner().equals(island.getOwnerUUID())) { + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } } } diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java index e9d73d19..2827312d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Join.java +++ b/src/main/java/com/songoda/skyblock/listeners/Join.java @@ -116,7 +116,7 @@ public class Join implements Listener { SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId()); Bukkit.getScheduler().runTask(plugin, () -> { - if (scoreboardManager != null && playerDataManager.getPlayerData(player).isScoreboard()) { + if (playerDataManager.getPlayerData(player).isScoreboard()) { scoreboardManager.updatePlayerScoreboardType(player); } }); diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index 3a398a56..3c6e97ea 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -190,14 +190,12 @@ public class PlayerDataManager { ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); - if (scoreboardManager != null) { - for (Player loopPlayer : Bukkit.getOnlinePlayers()) { - PlayerData targetPlayerData = getPlayerData(loopPlayer); - - if (targetPlayerData.getOwner() != null && - targetPlayerData.getOwner().equals(island.getOwnerUUID())) { - scoreboardManager.updatePlayerScoreboardType(loopPlayer); - } + for (Player loopPlayer : Bukkit.getOnlinePlayers()) { + PlayerData targetPlayerData = getPlayerData(loopPlayer); + + if (targetPlayerData.getOwner() != null && + targetPlayerData.getOwner().equals(island.getOwnerUUID())) { + scoreboardManager.updatePlayerScoreboardType(loopPlayer); } } From f8830771f6678c964062df5ce275bb721c29f1e5 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 7 Aug 2020 00:24:00 +0200 Subject: [PATCH 361/366] Fixed async chunk loading in 1.16 --- src/main/java/com/songoda/skyblock/SkyBlock.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 0591378f..e466bdec 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -121,8 +121,12 @@ public class SkyBlock extends SongodaPlugin { if(paper = ServerProject.isServer(ServerProject.PAPER)){ try { Bukkit.spigot().getClass().getMethod("getPaperConfig"); - paperAsync = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && - Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) { + paperAsync = true; + } else { + paperAsync = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && + Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false); + } } catch (NoSuchMethodException ignored) { paperAsync = false; } From 28f3e9aa13e7e2448a5ef90dd9bcc88815f5b387 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 7 Aug 2020 00:24:12 +0200 Subject: [PATCH 362/366] 2.3.7-DEV1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3438c1f2..0cee4754 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.6 + 2.3.7-DEV1 jar UTF-8 From 92e2769c55380afb2413e0a382b422687c2d8a9a Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 7 Aug 2020 18:17:27 +0200 Subject: [PATCH 363/366] Fixed npe in scoreboard manager --- .../songoda/skyblock/scoreboard/Holder.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java index ce42e19b..1687009e 100644 --- a/src/main/java/com/songoda/skyblock/scoreboard/Holder.java +++ b/src/main/java/com/songoda/skyblock/scoreboard/Holder.java @@ -26,19 +26,21 @@ class Holder { PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); - if (!scoreboardManager.isPlayerDisabled(player)) { - board.setTitle(driver.getTitle().getLine()); - - int count = 0; - for(Row row : driver.getRows()) { - String line = placeholderManager.parsePlaceholders(player, row.getLine()); - board.setLine(count, line); - count++; + if(scoreboardManager != null) { + if (!scoreboardManager.isPlayerDisabled(player)) { + board.setTitle(driver.getTitle().getLine()); + + int count = 0; + for(Row row : driver.getRows()) { + String line = placeholderManager.parsePlaceholders(player, row.getLine()); + board.setLine(count, line); + count++; + } + + this.player.setScoreboard(board.getBoard()); + } else { + this.player.setScoreboard(scoreboardManager.getEmptyScoreboard()); } - - this.player.setScoreboard(board.getBoard()); - } else { - this.player.setScoreboard(scoreboardManager.getEmptyScoreboard()); } } From f54f2b30e8a616e2b0c9954178dc38eadac83944 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 7 Aug 2020 18:17:35 +0200 Subject: [PATCH 364/366] Fixed critical issue with block events --- .../java/com/songoda/skyblock/SkyBlock.java | 4 ++ .../com/songoda/skyblock/listeners/Block.java | 41 ------------ .../songoda/skyblock/listeners/Sponge.java | 65 +++++++++++++++++++ 3 files changed, 69 insertions(+), 41 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/listeners/Sponge.java diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index e466bdec..63230c14 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -214,6 +214,10 @@ public class SkyBlock extends SongodaPlugin { pluginManager.registerEvents(new Piston(this), this); pluginManager.registerEvents(new FallBreak(this), this); pluginManager.registerEvents(new World(this), this); + + if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { + pluginManager.registerEvents(new Sponge(this), this); + } if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this); diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java index ff4338ec..67709274 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Block.java +++ b/src/main/java/com/songoda/skyblock/listeners/Block.java @@ -836,47 +836,6 @@ public class Block implements Listener { return false; } - @EventHandler(ignoreCancelled = true) - public void onSponge(SpongeAbsorbEvent event) { - IslandLevelManager islandLevelManager = plugin.getLevellingManager(); - IslandManager islandManager = plugin.getIslandManager(); - StackableManager stackableManager = plugin.getStackableManager(); - WorldManager worldManager = plugin.getWorldManager(); - - org.bukkit.block.Block block = event.getBlock(); - - if (worldManager.isIslandWorld(block.getWorld())) { - Location blockLocation = block.getLocation(); - - Island island = islandManager.getIslandAtLocation(blockLocation); - if (island != null) { - if (plugin.getPermissionManager().processPermission(event, island) && !event.isCancelled()) { - if (stackableManager == null || !stackableManager.isStacked(blockLocation)) { - IslandLevel level = island.getLevel(); - - CompatibleMaterial material = CompatibleMaterial.SPONGE; - if (level.hasMaterial(material.name())) { - long materialAmount = level.getMaterialAmount(material.name()); - - if (materialAmount - 1 <= 0) { - level.removeMaterial(material.name()); - } else { - level.setMaterialAmount(material.name(), materialAmount - 1); - } - - Bukkit.getScheduler().runTask(plugin, () -> islandLevelManager.updateLevel(island, blockLocation)); - } - } else { - event.setCancelled(true); - } - } - } else { - event.setCancelled(true); - } - } - - } - @EventHandler(ignoreCancelled = true) public void onBlockBurn(BlockBurnEvent event) { org.bukkit.block.Block block = event.getBlock(); diff --git a/src/main/java/com/songoda/skyblock/listeners/Sponge.java b/src/main/java/com/songoda/skyblock/listeners/Sponge.java new file mode 100644 index 00000000..18f02d99 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/listeners/Sponge.java @@ -0,0 +1,65 @@ +package com.songoda.skyblock.listeners; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandLevel; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.levelling.IslandLevelManager; +import com.songoda.skyblock.stackable.StackableManager; +import com.songoda.skyblock.world.WorldManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.SpongeAbsorbEvent; + +public class Sponge implements Listener { + + private final SkyBlock plugin; + + public Sponge(SkyBlock plugin) { + this.plugin = plugin; + } + + @EventHandler(ignoreCancelled = true) + public void onSponge(SpongeAbsorbEvent event) { + IslandLevelManager islandLevelManager = plugin.getLevellingManager(); + IslandManager islandManager = plugin.getIslandManager(); + StackableManager stackableManager = plugin.getStackableManager(); + WorldManager worldManager = plugin.getWorldManager(); + + org.bukkit.block.Block block = event.getBlock(); + + if (worldManager.isIslandWorld(block.getWorld())) { + Location blockLocation = block.getLocation(); + + Island island = islandManager.getIslandAtLocation(blockLocation); + if (island != null) { + if (plugin.getPermissionManager().processPermission(event, island) && !event.isCancelled()) { + if (stackableManager == null || !stackableManager.isStacked(blockLocation)) { + IslandLevel level = island.getLevel(); + + CompatibleMaterial material = CompatibleMaterial.SPONGE; + if (level.hasMaterial(material.name())) { + long materialAmount = level.getMaterialAmount(material.name()); + + if (materialAmount - 1 <= 0) { + level.removeMaterial(material.name()); + } else { + level.setMaterialAmount(material.name(), materialAmount - 1); + } + + Bukkit.getScheduler().runTask(plugin, () -> islandLevelManager.updateLevel(island, blockLocation)); + } + } else { + event.setCancelled(true); + } + } + } else { + event.setCancelled(true); + } + } + + } +} From 8ea9254f8e8b337cb1ff8d9335ae56269c643384 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 7 Aug 2020 18:33:39 +0200 Subject: [PATCH 365/366] 2.3.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0cee4754..ac1dd1ce 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.3.7-DEV1 + 2.3.7 jar UTF-8 From 070f93f83fb1253ec19109ea660f2f9d7c2fa0f2 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 7 Aug 2020 21:31:36 +0200 Subject: [PATCH 366/366] Fix for language error --- src/main/java/com/songoda/skyblock/island/IslandManager.java | 2 +- .../com/songoda/skyblock/playerdata/PlayerDataManager.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 98638e4b..7692cd62 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -1257,7 +1257,7 @@ public class IslandManager { if (!island.isCoopPlayer(visitor)) { Player targetPlayer = Bukkit.getServer().getPlayer(visitor); LocationUtil.teleportPlayerToSpawn(targetPlayer); - messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Closed.Message").replace("%player", islandOwnerPlayerName)); + messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", islandOwnerPlayerName)); } } } diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java index 3c6e97ea..ee0cdd6f 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java @@ -202,7 +202,7 @@ public class PlayerDataManager { return; } else { if (messageManager != null) - messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Message").replace("%player", targetPlayerName)); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName)); } } @@ -263,7 +263,7 @@ public class PlayerDataManager { } else { islandManager.unloadIsland(island, Bukkit.getServer().getOfflinePlayer(visitIslandList)); if (messageManager != null) - messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Message").replace("%player", targetPlayerName)); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName)); } } }