diff --git a/pom.xml b/pom.xml
index 68a3e2338..fc91f8455 100644
--- a/pom.xml
+++ b/pom.xml
@@ -314,6 +314,13 @@
${spigot.version}
provided
+
+
+ com.github.Slimefun
+ Slimefun4
+ RC-36
+ provided
+
diff --git a/src/main/java/world/bentobox/bentobox/BentoBox.java b/src/main/java/world/bentobox/bentobox/BentoBox.java
index 60cbc2fe8..1fb0ed916 100644
--- a/src/main/java/world/bentobox/bentobox/BentoBox.java
+++ b/src/main/java/world/bentobox/bentobox/BentoBox.java
@@ -24,6 +24,7 @@
import world.bentobox.bentobox.database.DatabaseSetup;
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
import world.bentobox.bentobox.hooks.MyWorldsHook;
+import world.bentobox.bentobox.hooks.SlimefunHook;
import world.bentobox.bentobox.hooks.VaultHook;
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
import world.bentobox.bentobox.listeners.BannedCommands;
@@ -231,6 +232,9 @@ private void completeSetup(long loadTime) {
hooksManager.registerHook(new MyWorldsHook());
islandWorldManager.registerWorldsToMultiverse(true);
+ // Register Slimefun
+ hooksManager.registerHook(new SlimefunHook());
+
// TODO: re-enable after implementation
//hooksManager.registerHook(new DynmapHook());
// TODO: re-enable after rework
diff --git a/src/main/java/world/bentobox/bentobox/hooks/SlimefunHook.java b/src/main/java/world/bentobox/bentobox/hooks/SlimefunHook.java
new file mode 100644
index 000000000..897a247ca
--- /dev/null
+++ b/src/main/java/world/bentobox/bentobox/hooks/SlimefunHook.java
@@ -0,0 +1,35 @@
+package world.bentobox.bentobox.hooks;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+
+import me.mrCookieSlime.Slimefun.api.BlockStorage;
+import world.bentobox.bentobox.api.hooks.Hook;
+
+/**
+ * Hook to enable slimefun blocks to be deleted when islands are deleted.
+ */
+public class SlimefunHook extends Hook {
+
+ public SlimefunHook() {
+ super("Slimefun", Material.SLIME_BLOCK);
+ }
+
+ @Override
+ public boolean hook() {
+ // See if Slimefun is around
+ return Bukkit.getPluginManager().getPlugin("SlimeFun") != null;
+ }
+
+ @Override
+ public String getFailureCause() {
+ return ""; // No errors
+ }
+
+ public void clearBlockInfo(Location location, boolean destroy) {
+ BlockStorage.clearBlockInfo(location, destroy);
+ }
+
+
+}
diff --git a/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java b/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java
index e8c60c53d..6b6a2800c 100644
--- a/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java
+++ b/src/main/java/world/bentobox/bentobox/nms/CopyWorldRegenerator.java
@@ -38,6 +38,7 @@
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.database.objects.IslandDeletion;
+import world.bentobox.bentobox.hooks.SlimefunHook;
import world.bentobox.bentobox.util.MyBiomeGrid;
/**
@@ -117,6 +118,7 @@ public CompletableFuture regenerateChunk(Chunk chunk) {
}
private CompletableFuture regenerateChunk(@Nullable IslandDeletion di, World world, int chunkX, int chunkZ) {
+
CompletableFuture seedWorldFuture = getSeedWorldChunk(world, chunkX, chunkZ);
// Set up a future to get the chunk requests using Paper's Lib. If Paper is used, this should be done async
@@ -192,6 +194,10 @@ private void copyChunkDataToChunk(Chunk toChunk, Chunk fromChunk, BoundingBox li
if (x % 4 == 0 && y % 4 == 0 && z % 4 == 0) {
toChunk.getBlock(x, y, z).setBiome(fromChunk.getBlock(x, y, z).getBiome());
}
+ // Delete any slimefun blocks
+ Location loc = new Location(toChunk.getWorld(), baseX + x, y, baseZ + z);
+ plugin.getHooks().getHook("Slimefun")
+ .ifPresent(sf -> ((SlimefunHook) sf).clearBlockInfo(loc, true));
}
}
}
@@ -371,6 +377,10 @@ private void copyChunkDataToChunk(Chunk chunk, ChunkGenerator.ChunkData chunkDat
if (x % 4 == 0 && y % 4 == 0 && z % 4 == 0) {
chunk.getBlock(x, y, z).setBiome(biomeGrid.getBiome(x, y, z));
}
+ // Delete any slimefun blocks
+ Location loc = new Location(chunk.getWorld(), baseX + x, y, baseZ + z);
+ plugin.getHooks().getHook("Slimefun")
+ .ifPresent(sf -> ((SlimefunHook) sf).clearBlockInfo(loc, true));
}
}
}
diff --git a/src/main/java/world/bentobox/bentobox/nms/SimpleWorldRegenerator.java b/src/main/java/world/bentobox/bentobox/nms/SimpleWorldRegenerator.java
index f37efc192..218c72af7 100644
--- a/src/main/java/world/bentobox/bentobox/nms/SimpleWorldRegenerator.java
+++ b/src/main/java/world/bentobox/bentobox/nms/SimpleWorldRegenerator.java
@@ -7,6 +7,7 @@
import java.util.concurrent.CompletableFuture;
import org.bukkit.Chunk;
+import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
@@ -21,6 +22,7 @@
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.database.objects.IslandDeletion;
+import world.bentobox.bentobox.hooks.SlimefunHook;
import world.bentobox.bentobox.util.MyBiomeGrid;
public abstract class SimpleWorldRegenerator implements WorldRegenerator {
@@ -140,6 +142,11 @@ private void copyChunkDataToChunk(Chunk chunk, ChunkGenerator.ChunkData chunkDat
if (x % 4 == 0 && y % 4 == 0 && z % 4 == 0) {
chunk.getBlock(x, y, z).setBiome(biomeGrid.getBiome(x, y, z));
}
+ // Delete any slimefun blocks
+ Location loc = new Location(chunk.getWorld(), baseX + x, y, baseZ + z);
+ BentoBox.getInstance().logDebug(loc + " " + plugin.getHooks().getHook("Slimefun").isPresent());
+ plugin.getHooks().getHook("Slimefun")
+ .ifPresent(sf -> ((SlimefunHook) sf).clearBlockInfo(loc, true));
}
}
}