diff --git a/src/main/java/com/dre/brewery/Barrel.java b/src/main/java/com/dre/brewery/Barrel.java index 39fd890a..c9c25aaa 100644 --- a/src/main/java/com/dre/brewery/Barrel.java +++ b/src/main/java/com/dre/brewery/Barrel.java @@ -392,6 +392,7 @@ public static boolean create(Block sign, Player player) { * @param breaker The Player that broke it, or null if not known * @param dropItems If the items in the barrels inventory should drop to the ground */ + @Override public void remove(@Nullable Block broken, @Nullable Player breaker, boolean dropItems) { BarrelRemoveEvent event = new BarrelRemoveEvent(this, dropItems); // Listened to by LWCBarrel (IntegrationListener) diff --git a/src/main/java/com/dre/brewery/BarrelBody.java b/src/main/java/com/dre/brewery/BarrelBody.java index aeed3ece..8e874a3e 100644 --- a/src/main/java/com/dre/brewery/BarrelBody.java +++ b/src/main/java/com/dre/brewery/BarrelBody.java @@ -23,12 +23,15 @@ import com.dre.brewery.utility.BUtil; import com.dre.brewery.utility.BoundingBox; import com.dre.brewery.utility.MaterialUtil; +import com.dre.brewery.utility.MinecraftVersion; import lombok.Getter; import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; /** * The Blocks that make up a Barrel in the World @@ -45,6 +48,15 @@ public BarrelBody(Block spigot, byte signoffset) { this.spigot = spigot; this.signoffset = signoffset; this.bounds = new BoundingBox(0, 0, 0, 0, 0, 0); + + if (MinecraftVersion.isFolia()) { // Issues#70 + BreweryPlugin.getScheduler().runTask(spigot.getLocation(), () -> { + Block broken = getBrokenBlock(true); + if (broken != null) { + this.remove(broken, null, true); + } + }); + } } /** @@ -201,6 +213,8 @@ public static Block getSpigotOfSign(Block block) { return block; } + public abstract void remove(@Nullable Block broken, @Nullable Player breaker, boolean dropItems); + /** * Regenerate the Barrel Bounds. * diff --git a/src/main/java/com/dre/brewery/BreweryPlugin.java b/src/main/java/com/dre/brewery/BreweryPlugin.java index 02cd3462..914a73ae 100644 --- a/src/main/java/com/dre/brewery/BreweryPlugin.java +++ b/src/main/java/com/dre/brewery/BreweryPlugin.java @@ -149,11 +149,29 @@ public void onEnable() { return; } + // Load objects DataManager.loadMiscData(dataManager.getBreweryMiscData()); - Barrel.getBarrels().addAll(dataManager.getAllBarrels().stream().filter(Objects::nonNull).toList()); - BCauldron.getBcauldrons().putAll(dataManager.getAllCauldrons().stream().filter(Objects::nonNull).collect(Collectors.toMap(BCauldron::getBlock, Function.identity()))); - BPlayer.getPlayers().putAll(dataManager.getAllPlayers().stream().filter(Objects::nonNull).collect(Collectors.toMap(BPlayer::getUuid, Function.identity()))); - Wakeup.getWakeups().addAll(dataManager.getAllWakeups().stream().filter(Objects::nonNull).toList()); + Barrel.getBarrels().addAll(dataManager.getAllBarrels() + .stream() + .filter(Objects::nonNull) + .toList()); + BCauldron.getBcauldrons().putAll(dataManager.getAllCauldrons().stream() + .filter(Objects::nonNull) + .collect(Collectors.toMap( + BCauldron::getBlock, Function.identity(), + (existing, replacement) -> replacement // Issues#69 + ))); + BPlayer.getPlayers().putAll(dataManager.getAllPlayers() + .stream() + .filter(Objects::nonNull) + .collect(Collectors.toMap( + BPlayer::getUuid, + Function.identity() + ))); + Wakeup.getWakeups().addAll(dataManager.getAllWakeups() + .stream() + .filter(Objects::nonNull) + .toList()); // Setup Metrics