Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Apr 26, 2021
2 parents 8ce7e1c + d4d17b7 commit 3570c52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
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>3.1.0</build.version>
<build.version>3.1.1</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
Expand Down
24 changes: 18 additions & 6 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.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -85,17 +87,28 @@ public void onPlayerLeaveIsland(PlayerMoveEvent e) {
}
// Backtrack
addon.getIslands().getIslandAt(p.getLocation()).ifPresent(i -> {
Vector unitVector = i.getCenter().toVector().subtract(p.getLocation().toVector()).normalize()
Vector unitVector = i.getProtectionCenter().toVector().subtract(p.getLocation().toVector()).normalize()
.multiply(new Vector(1,0,1));
RayTraceResult r = i.getProtectionBoundingBox().rayTrace(p.getLocation().toVector(), unitVector, i.getRange());
if (r != null) {
inTeleport.add(p.getUniqueId());
Util.teleportAsync(p, r.getHitPosition().toLocation(p.getWorld(), p.getLocation().getYaw(), p.getLocation().getPitch()))
.thenRun(() -> inTeleport.remove(p.getUniqueId()));
Location targetPos = r.getHitPosition().toLocation(p.getWorld(), p.getLocation().getYaw(), p.getLocation().getPitch());
if (!addon.getIslands().isSafeLocation(targetPos)) {
switch (targetPos.getWorld().getEnvironment()) {
case NETHER:
targetPos.getBlock().getRelative(BlockFace.DOWN).setType(Material.NETHERRACK);
break;
case THE_END:
targetPos.getBlock().getRelative(BlockFace.DOWN).setType(Material.END_STONE);
break;
default:
targetPos.getBlock().getRelative(BlockFace.DOWN).setType(Material.STONE);
break;
}
}
Util.teleportAsync(p, targetPos).thenRun(() -> inTeleport.remove(p.getUniqueId()));
}
});


}

/**
Expand All @@ -110,7 +123,6 @@ private boolean outsideCheck(Player player, Location from, Location to) {

if ((from.getWorld() != null && from.getWorld().equals(to.getWorld())
&& from.toVector().multiply(XZ).equals(to.toVector().multiply(XZ)))
|| !addon.getSettings().isUseBarrierBlocks()
|| !addon.inGameWorld(player.getWorld())
|| !addon.getIslands().getIslandAt(to).filter(i -> addon.getIslands().locationIsOnIsland(player, i.getCenter())).isPresent()
|| !user.getMetaData(BorderShower.BORDER_STATE_META_DATA).map(MetaDataValue::asBoolean).orElse(addon.getSettings().isShowByDefault())) {
Expand Down

0 comments on commit 3570c52

Please sign in to comment.