diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 565f368f..1d1e6362 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -121,19 +121,4 @@ public class BauSystem extends JavaPlugin implements Listener { } })); } - - private void createLink(String source, String destination) { - try { - Bukkit.getLogger().log(Level.INFO, "Executing: ln -s /home/minecraft/server/Bau15/{0} {1}", new String[]{source, destination}); - ProcessBuilder processBuilder = new ProcessBuilder("ln", "-s", "/home/minecraft/server/Bau15/" + source, destination); - processBuilder.directory(world.getWorldFolder()); - processBuilder.inheritIO(); - - Process process = processBuilder.start(); - process.waitFor(); - } catch (IOException | InterruptedException e) { - Thread.currentThread().interrupt(); - Bukkit.shutdown(); - } - } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java index 0dcf1187..62eb765d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java @@ -113,8 +113,10 @@ public class EntityShowMode implements ShowMode { tntEntityMap.clear(); explodeEntityMap.clear(); updateEntityMap.clear(); - entityServer.close(); - entityServer = null; + if (entityServer != null) { + entityServer.close(); + entityServer = null; + } } private void generatePositions(TNTPosition position, boolean interpolateY, boolean interpolateXZ) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java index 2544a28b..d8e3a75f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java @@ -29,8 +29,8 @@ public class ShowModeParameter { private boolean sourceOnly = false; private boolean explodeOnly = false; private boolean ticks = false; - private boolean buildDestroyOnly = false; private boolean count = false; + private boolean buildDestroyOnly = false; public void enableWater() { this.water = true; @@ -56,11 +56,11 @@ public class ShowModeParameter { this.ticks = true; } - public void enableBuildDestroyOnly() { - this.buildDestroyOnly = true; - } - public void enableCount() { this.count = true; } + + public void enableBuildDestroyOnly() { + this.buildDestroyOnly = true; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index 82ca5673..856513ff 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -63,7 +63,7 @@ public class TraceShowManager implements Listener { if (regionalShowModes == null) { return; } - ShowMode showMode = regionalShowModes.get(player); + ShowMode showMode = regionalShowModes.remove(player); if (showMode == null) { return; } @@ -160,13 +160,10 @@ public class TraceShowManager implements Listener { @EventHandler public void onLeave(PlayerQuitEvent event) { - Region region = Region.getRegion(event.getPlayer().getLocation()); - if (!region.isGlobal()) { - Map> regionalShowModes = showModes.get(region); - if (regionalShowModes != null) { - regionalShowModes.remove(event.getPlayer()).hide(); - } - } + showModes.forEach((region, playerShowModeMap) -> { + ShowMode showMode = playerShowModeMap.remove(event.getPlayer()); + if (showMode != null) showMode.hide(); + }); StoredRecords.cleanup(event.getPlayer()); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java index 2145e442..463820f7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java @@ -71,4 +71,18 @@ public class RayTraceUtils { return entityHitDistanceSquared < blockHitDistance * blockHitDistance ? entities : blocks; } } + + public static boolean isOccluded(Vector a, Vector n, Vector b) { + // a = Head pos, n = View direction (normalized), b = entity center + // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line#Vector_formulation + + double abX = b.getX() - a.getX(); + double abY = b.getY() - a.getY(); + double abZ = b.getZ() - a.getZ(); + double lambda = abX * n.getX() + abY * n.getY() + abZ * n.getZ(); + double distX = abX - n.getX() * lambda; + double distY = abY - n.getY() * lambda; + double distZ = abZ - n.getZ() * lambda; + return Math.abs(distX) < 0.5 && Math.abs(distY) < 0.5 && Math.abs(distZ) < 0.5; + } }