mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-25 20:25:16 +01:00
Delete slimefun chunks/blocks when island is deleted. (#2247)
This commit is contained in:
parent
96499f3ad6
commit
86d8d147d1
7
pom.xml
7
pom.xml
@ -314,6 +314,13 @@
|
||||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Slimefun -->
|
||||
<dependency>
|
||||
<groupId>com.github.Slimefun</groupId>
|
||||
<artifactId>Slimefun4</artifactId>
|
||||
<version>RC-36</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -24,6 +24,7 @@ import world.bentobox.bentobox.commands.BentoBoxCommand;
|
||||
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 @@ public class BentoBox extends JavaPlugin implements Listener {
|
||||
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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -38,6 +38,7 @@ import io.papermc.lib.PaperLib;
|
||||
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 abstract class CopyWorldRegenerator implements WorldRegenerator {
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> regenerateChunk(@Nullable IslandDeletion di, World world, int chunkX, int chunkZ) {
|
||||
|
||||
CompletableFuture<Chunk> 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 @@ public abstract class CopyWorldRegenerator implements WorldRegenerator {
|
||||
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 @@ public abstract class CopyWorldRegenerator implements WorldRegenerator {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.Random;
|
||||
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 io.papermc.lib.PaperLib;
|
||||
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 @@ public abstract class SimpleWorldRegenerator implements WorldRegenerator {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user