-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from BONNePlayground/develop
Release 1.1
- Loading branch information
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/lv/id/bonne/novahook/listeners/IslandDeleteListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// Created by BONNe | ||
// Copyright - 2023 | ||
// | ||
|
||
|
||
package lv.id.bonne.novahook.listeners; | ||
|
||
|
||
import org.bukkit.Location; | ||
import org.bukkit.World; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
import world.bentobox.bentobox.api.events.island.IslandDeleteChunksEvent; | ||
import world.bentobox.bentobox.database.objects.IslandDeletion; | ||
import xyz.xenondevs.nova.api.Nova; | ||
import xyz.xenondevs.nova.api.block.BlockManager; | ||
|
||
|
||
/** | ||
* This listener checks when island chunks are removed and at that point, remove all Nova blocks | ||
* from the island. Resource intensive thing. May require rewriting :) | ||
*/ | ||
public class IslandDeleteListener implements Listener | ||
{ | ||
@EventHandler | ||
public void onIslandDeletion(IslandDeleteChunksEvent event) | ||
{ | ||
final IslandDeletion info = event.getDeletedIslandInfo(); | ||
final World world = event.getDeletedIslandInfo().getWorld(); | ||
final BlockManager blockManager = Nova.getNova().getBlockManager(); | ||
|
||
if (world == null) | ||
{ | ||
return; | ||
} | ||
|
||
final int maxX = info.getMaxX(); | ||
final int maxZ = info.getMaxZ(); | ||
|
||
for (int x = info.getMinX(); x < maxX; x++) | ||
{ | ||
for (int z = info.getMinZ(); z < maxZ; z++) | ||
{ | ||
for (int y = world.getMinHeight(); y < world.getMaxHeight(); y++) | ||
{ | ||
Location location = new Location(world, x, y, z); | ||
|
||
if (blockManager.hasBlock(location)) | ||
{ | ||
blockManager.removeBlock(location); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |