Skip to content

Commit

Permalink
Merge pull request #1 from BONNePlayground/develop
Browse files Browse the repository at this point in the history
Release 1.1
  • Loading branch information
BONNe authored Feb 12, 2023
2 parents 171b6a9 + e8d6f84 commit 2f25b65
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<description>This is simple BentoBox addon that allows to hook into Nova Plugin.</description>

<url>https://github.com/BONNePlayground/NovaHook</url>
<inceptionYear>2021</inceptionYear>
<inceptionYear>2023</inceptionYear>

<scm>
<connection>scm:git:https://github.com/BONNePlayground/NovaHook.git</connection>
Expand Down Expand Up @@ -54,7 +54,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.0.0</build.version>
<build.version>1.1.0</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/lv/id/bonne/novahook/NovaHookAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import org.bukkit.Material;

import lv.id.bonne.novahook.listeners.IslandDeleteListener;
import lv.id.bonne.novahook.protection.NovaProtectionIntegration;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.flags.Flag;
Expand Down Expand Up @@ -55,6 +56,8 @@ public void onEnable()

// Register nova protection
Nova.getNova().registerProtectionIntegration(new NovaProtectionIntegration());

this.registerListener(new IslandDeleteListener());
}


Expand Down
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);
}
}
}
}
}
}

0 comments on commit 2f25b65

Please sign in to comment.