Skip to content

Commit

Permalink
Implement border updating on island range change. (#15)
Browse files Browse the repository at this point in the history
Add WorldBorderAPI as softdepend to Border addon.
  • Loading branch information
BONNe committed Feb 7, 2020
1 parent 7b761d9 commit 6e4d168
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@
<powermock.version>1.7.4</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.13.2-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.6.0</bentobox.version>
<bentobox.version>1.11.0</bentobox.version>
<worldborderapi.version>1.0.3</worldborderapi.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.0.4</build.version>
<build.version>1.0.6</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down Expand Up @@ -153,7 +154,7 @@
<dependency>
<groupId>com.github.yannicklamprecht</groupId>
<artifactId>WorldBorderAPI</artifactId>
<version>1.0.2</version>
<version>${worldborderapi.version}</version>
</dependency>
</dependencies>

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;

import world.bentobox.bentobox.api.events.island.IslandEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandDeleteEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandEnterEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandExitEvent;
Expand Down Expand Up @@ -67,4 +69,21 @@ public void onIslandDeleteEvent(IslandDeleteEvent e) {
}
addon.removeBorder(player);
}


/**
* Monitor island range change event.
* If island protection range is changed, then update border.
* @param e instance of IslandProtectionRangeChangeEvent.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onIslandRangeChange(IslandEvent.IslandProtectionRangeChangeEvent e) {
Player player = this.addon.getServer().getPlayer(e.getPlayerUUID());

if (player == null) {
return;
}

this.addon.updateBorder(player, e.getLocation());
}
}
4 changes: 3 additions & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Border
main: world.bentobox.border.Border
version: ${version}${build.number}
api-version: ${bentobox.version}
icon: BEDROCK

prefix: Border

softdepend: BSkyBlock, AcidIsland, SkyGrid, CaveBlock
# depend: WorldBorderAPI
softdepend: BSkyBlock, AcidIsland, SkyGrid, CaveBlock, WorldBorderAPI

authors: [tastybento]

0 comments on commit 6e4d168

Please sign in to comment.