Skip to content

Commit

Permalink
If border is off, then don't move player back.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Sep 1, 2024
1 parent b0abf59 commit 4a91752
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
<bentobox.version>2.5.0-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/world/bentobox/border/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,20 @@ public void onPlayerRespawn(PlayerRespawnEvent e) {
show.showBorder(e.getPlayer(), i)));
}

private boolean isOn(Player player) {
// Check if border is off
User user = User.getInstance(player);
return user.getMetaData(BorderShower.BORDER_STATE_META_DATA).map(MetaDataValue::asBoolean)
.orElse(addon.getSettings().isShowByDefault());

}

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent e) {
Player player = e.getPlayer();
if (!isOn(player)) {
return;
}
Location to = e.getTo();

show.clearUser(User.getInstance(player));
Expand Down Expand Up @@ -145,6 +156,9 @@ public void onPlayerTeleport(PlayerTeleportEvent e) {
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerLeaveIsland(PlayerMoveEvent e) {
Player p = e.getPlayer();
if (!isOn(p)) {
return;
}
Location from = e.getFrom();
if (!addon.getSettings().isReturnTeleport() || !outsideCheck(e.getPlayer(), from, e.getTo())) {
return;
Expand Down

0 comments on commit 4a91752

Please sign in to comment.