From cd5a2f38f736fccda94fe01a99d26859b4786c77 Mon Sep 17 00:00:00 2001 From: Brianna Date: Tue, 14 Apr 2020 08:50:47 -0400 Subject: [PATCH 1/5] Fix for concurrent modification exception. --- src/main/java/com/songoda/skyblock/tasks/HologramTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java index d6472e18..329f06b1 100644 --- a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java @@ -163,7 +163,7 @@ public class HologramTask extends BukkitRunnable { } public void updateHologram() { - for (Hologram hologramList : hologramStorage) { + for (Hologram hologramList : new ArrayList<>(hologramStorage)) { hologramList.update(getHologramLines(hologramList.getType())); } } From 7250d74677163f20635775f228f19565541cdf29 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 16 Apr 2020 02:22:04 -0400 Subject: [PATCH 2/5] Properly update hologram lines. --- .../java/com/songoda/skyblock/tasks/HologramTask.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java index 329f06b1..7d568d2c 100644 --- a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java @@ -9,9 +9,9 @@ import com.songoda.skyblock.hologram.HologramType; import com.songoda.skyblock.island.IslandLevel; import com.songoda.skyblock.leaderboard.Leaderboard; import com.songoda.skyblock.leaderboard.LeaderboardManager; -import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.player.OfflinePlayer; +import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.visit.Visit; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -63,7 +63,12 @@ public class HologramTask extends BukkitRunnable { } public void spawnHologram(HologramType type, Location location, List lines) { - hologramStorage.add(new Hologram(type, location, lines)); + Hologram hologram = hologramStorage.stream() + .filter(h -> LocationUtil.isLocationLocation(h.getLocation(), location)).findFirst().orElse(null); + if (hologram == null) + hologramStorage.add(new Hologram(type, location, lines)); + else + hologram.update(lines); } public void spawnHologram(HologramType type) { From 1df8a0a3d44b44859b68b28f4b7ad351e71ecae2 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 16 Apr 2020 02:29:30 -0400 Subject: [PATCH 3/5] Delete old holograms when moved. --- .../commands/admin/RemoveHologramCommand.java | 2 +- .../commands/admin/SetHologramCommand.java | 15 ++++++++------- .../com/songoda/skyblock/tasks/HologramTask.java | 5 +++++ 3 files changed, 14 insertions(+), 8 deletions(-) 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 ee6dfd39..d72ef499 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 @@ -77,7 +77,7 @@ public class RemoveHologramCommand extends SubCommand { Hologram hologram = hologramManager.getHologram(hologramType1); if (hologram != null) - hologram.remove(); + hologramManager.removeHologram(hologram); }); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.name())); 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 25739d7a..1f3c947f 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 @@ -49,15 +49,16 @@ public class SetHologramCommand extends SubCommand { fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")), "Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true); - HologramType hologramType1 = HologramType - .valueOf(WordUtils.capitalize(args[0].toLowerCase())); - Hologram hologram = hologramManager.getHologram(hologramType1); - if (hologram != null) - hologram.remove(); + Bukkit.getServer().getScheduler().runTask(skyblock, () -> { + HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase())); + Hologram hologram = hologramManager.getHologram(hologramType1); - Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> - hologramManager.spawnHologram(hologramType1)); + if (hologram != null) + hologramManager.removeHologram(hologram); + + hologramManager.spawnHologram(hologramType1); + }); messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type", diff --git a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java index 7d568d2c..3dcfe777 100644 --- a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java +++ b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java @@ -172,4 +172,9 @@ public class HologramTask extends BukkitRunnable { hologramList.update(getHologramLines(hologramList.getType())); } } + + public void removeHologram(Hologram hologram) { + hologramStorage.remove(hologram); + hologram.remove(); + } } From 53e029bd3bc82bf99a266addabd2fa26fa82c517 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 16 Apr 2020 02:57:42 -0400 Subject: [PATCH 4/5] Preserve BlockData in 1.13+ --- .../songoda/skyblock/utils/world/block/BlockData.java | 10 ++++++++++ .../songoda/skyblock/utils/world/block/BlockUtil.java | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 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 5fc9c006..02c81bd8 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 @@ -17,6 +17,7 @@ import java.util.Map; public class BlockData { private String material; + private String blockData = ""; private String biome; private String stateType = BlockStateType.NORMAL.toString(); private String dataType = BlockDataType.NORMAL.toString(); @@ -72,6 +73,15 @@ public class BlockData { this.material = material.name(); } + public String getBlockData() { + return blockData; + } + + public void setBlockData(String blockData) { + this.blockData = blockData; + } + + public String getBiome() { return this.biome; } 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 7e9740fc..6434bb73 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 @@ -28,6 +28,10 @@ public final class BlockUtil extends BlockUtils { int NMSVersion = NMSUtil.getVersionNumber(); blockData.setVersion(NMSVersion); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { + blockData.setBlockData(block.getBlockData().getAsString()); + } + BlockState blockState = block.getState(); MaterialData materialData = blockState.getData(); @@ -252,7 +256,10 @@ public final class BlockUtil extends BlockUtils { Material material = Material.valueOf(materialStr); if (material == Material.AIR) return; - setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData()); + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) + setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData()); + else + block.setBlockData(Bukkit.getServer().createBlockData(blockData.getBlockData())); // TODO Create a class to support biome changes // block.setBiome(Biome.valueOf(blockData.getBiome().toUpperCase())); @@ -417,7 +424,7 @@ public final class BlockUtil extends BlockUtils { state.setData(stairs); } else if (blockDataType == BlockDataType.FLOWERPOT) { setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), CompatibleMaterial.STONE, (byte) 0); - if (NMSVersion >= 8 && NMSVersion <= 12) { + if (NMSVersion >= 8 && NMSVersion <= 12) { if (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR) { setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), CompatibleMaterial.STONE, (byte) 0); } From afe954496c6a6c6f3d895c7b3dbb45f16c24c872 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 16 Apr 2020 03:11:29 -0400 Subject: [PATCH 5/5] version 2.2.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 81715e0b..f4e62326 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2.7 + 2.2.8 clean install FabledSkyblock-${project.version}