From 8134005ac60145f0ea0cfdfb78d5ed3154d6b740 Mon Sep 17 00:00:00 2001 From: filoghost Date: Fri, 31 Aug 2018 18:02:18 +0200 Subject: [PATCH] Add option for precise hologram teleport When moving holograms quickly (for example, a chat message over a player's head) lines may not be aligned correctly after moving for a while. Precise hologram teleporting prevents this issue. Some people won't need it, and disabling it may slightly improve the performance (depending on the number of holograms). --- .../holographicdisplays/disk/ConfigNode.java | 1 + .../disk/Configuration.java | 7 +-- NMS/v1_10_R1/pom.xml | 6 +++ .../nms/v1_10_R1/EntityNMSArmorStand.java | 33 +++++++------ NMS/v1_11_R1/pom.xml | 6 +++ .../nms/v1_11_R1/EntityNMSArmorStand.java | 33 +++++++------ NMS/v1_12_R1/pom.xml | 6 +++ .../nms/v1_12_R1/EntityNMSArmorStand.java | 33 +++++++------ NMS/v1_13_R1/pom.xml | 6 +++ .../nms/v1_13_R1/EntityNMSArmorStand.java | 33 +++++++------ NMS/v1_13_R2/pom.xml | 6 +++ .../nms/v1_13_R2/EntityNMSArmorStand.java | 33 +++++++------ NMS/v1_8_R1/pom.xml | 6 +++ .../nms/v1_8_R1/EntityNMSArmorStand.java | 49 ++++++++++--------- NMS/v1_8_R2/pom.xml | 6 +++ .../nms/v1_8_R2/EntityNMSArmorStand.java | 49 ++++++++++--------- NMS/v1_8_R3/pom.xml | 6 +++ .../nms/v1_8_R3/EntityNMSArmorStand.java | 49 ++++++++++--------- NMS/v1_9_R1/pom.xml | 6 +++ .../nms/v1_9_R1/EntityNMSArmorStand.java | 33 +++++++------ NMS/v1_9_R2/pom.xml | 6 +++ .../nms/v1_9_R2/EntityNMSArmorStand.java | 33 +++++++------ Plugin/src/main/resources/config.yml | 1 + 23 files changed, 280 insertions(+), 167 deletions(-) diff --git a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/ConfigNode.java b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/ConfigNode.java index 5cfb9737..c1ef47b7 100644 --- a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/ConfigNode.java +++ b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/ConfigNode.java @@ -5,6 +5,7 @@ import java.util.Arrays; public enum ConfigNode { SPACE_BETWEEN_LINES("space-between-lines", 0.02), + PRECISE_HOLOGRAM_MOVEMENT("precise-hologram-movement", true), IMAGES_SYMBOL("images.symbol", "[x]"), TRANSPARENCY_SPACE("images.transparency.space", " [|] "), TRANSPARENCY_COLOR("images.transparency.color", "&7"), diff --git a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java index 57497aca..70ae5c1e 100644 --- a/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java +++ b/Config/src/main/java/com/gmail/filoghost/holographicdisplays/disk/Configuration.java @@ -24,6 +24,7 @@ import com.gmail.filoghost.holographicdisplays.util.Utils; public class Configuration { public static double spaceBetweenLines; + public static boolean preciseHologramMovement; public static String imageSymbol; public static String transparencySymbol; public static boolean updateNotification; @@ -41,9 +42,7 @@ public class Configuration { public static String pingerStatusOffline; public static boolean pingerTrimMotd; public static Map pingerServers; - - //public static boolean debug; update DebugHandler instead - + public static void load(Plugin plugin) { File configFile = new File(plugin.getDataFolder(), "config.yml"); @@ -115,6 +114,8 @@ public class Configuration { } spaceBetweenLines = config.getDouble(ConfigNode.SPACE_BETWEEN_LINES.getPath()); + preciseHologramMovement = config.getBoolean(ConfigNode.PRECISE_HOLOGRAM_MOVEMENT.getPath()); + updateNotification = config.getBoolean(ConfigNode.UPDATE_NOTIFICATION.getPath()); imageSymbol = StringConverter.toReadableFormat(config.getString(ConfigNode.IMAGES_SYMBOL.getPath())); diff --git a/NMS/v1_10_R1/pom.xml b/NMS/v1_10_R1/pom.xml index 7aa6f71a..b999ef83 100644 --- a/NMS/v1_10_R1/pom.xml +++ b/NMS/v1_10_R1/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java index 2aa20430..6b5aab3a 100644 --- a/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java +++ b/NMS/v1_10_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_10_R1; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectionUtils; @@ -127,10 +128,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { - // Then this method is being called when creating a new movement packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { + // Then this method is being called when creating a new movement packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -189,16 +192,18 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); - - for (Object obj : super.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); + + for (Object obj : super.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_11_R1/pom.xml b/NMS/v1_11_R1/pom.xml index 4c520ae7..2a4a4e91 100644 --- a/NMS/v1_11_R1/pom.xml +++ b/NMS/v1_11_R1/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java index 8b0a599a..6a0cf533 100644 --- a/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java +++ b/NMS/v1_11_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_11_R1; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectionUtils; @@ -136,10 +137,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { - // Then this method is being called when creating a new movement packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { + // Then this method is being called when creating a new movement packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -198,16 +201,18 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); - - for (Object obj : super.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); + + for (Object obj : super.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_12_R1/pom.xml b/NMS/v1_12_R1/pom.xml index 997bb1a2..de50b49f 100644 --- a/NMS/v1_12_R1/pom.xml +++ b/NMS/v1_12_R1/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java index 08fc2474..d9cf3785 100644 --- a/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java +++ b/NMS/v1_12_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_12_R1; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectionUtils; @@ -136,10 +137,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { - // Then this method is being called when creating a new movement packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { + // Then this method is being called when creating a new movement packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -198,16 +201,18 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); - - for (Object obj : super.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); + + for (Object obj : super.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_13_R1/pom.xml b/NMS/v1_13_R1/pom.xml index 3ffef6b4..214dd48e 100644 --- a/NMS/v1_13_R1/pom.xml +++ b/NMS/v1_13_R1/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java index 25fc2b8d..22ea85f8 100644 --- a/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java +++ b/NMS/v1_13_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java @@ -4,6 +4,7 @@ import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_13_R1.util.CraftChatMessage; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectionUtils; @@ -138,10 +139,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { - // Then this method is being called when creating a new movement packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { + // Then this method is being called when creating a new movement packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -200,16 +203,18 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); - - for (Object obj : super.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); + + for (Object obj : super.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_13_R2/pom.xml b/NMS/v1_13_R2/pom.xml index 5965b75c..6460c532 100644 --- a/NMS/v1_13_R2/pom.xml +++ b/NMS/v1_13_R2/pom.xml @@ -33,6 +33,12 @@ 2.3.0-SNAPSHOT + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + + org.spigotmc spigot diff --git a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java index 88cd5e1c..b85de6d2 100644 --- a/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java +++ b/NMS/v1_13_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java @@ -4,6 +4,7 @@ import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_13_R2.util.CraftChatMessage; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectionUtils; @@ -138,10 +139,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { - // Then this method is being called when creating a new movement packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && 158 < element.getLineNumber() && element.getLineNumber() < 168) { + // Then this method is being called when creating a new movement packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -200,16 +203,18 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); - - for (Object obj : super.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); + + for (Object obj : super.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_8_R1/pom.xml b/NMS/v1_8_R1/pom.xml index 5a99695d..e43b9d1a 100644 --- a/NMS/v1_8_R1/pom.xml +++ b/NMS/v1_8_R1/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java index 128fbea7..8c062f85 100644 --- a/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java +++ b/NMS/v1_8_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R1/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_8_R1; import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField; @@ -116,10 +117,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 137 && element.getLineNumber() < 147) { - // Then this method is being called when creating a new packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 137 && element.getLineNumber() < 147) { + // Then this method is being called when creating a new packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -179,24 +182,26 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport( - getIdNMS(), - MathHelper.floor(this.locX * 32.0D), - MathHelper.floor(this.locY * 32.0D), - MathHelper.floor(this.locZ * 32.0D), - (byte) (int) (this.yaw * 256.0F / 360.0F), - (byte) (int) (this.pitch * 256.0F / 360.0F), - this.onGround - ); - - for (Object obj : this.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport( + getIdNMS(), + MathHelper.floor(this.locX * 32.0D), + MathHelper.floor(this.locY * 32.0D), + MathHelper.floor(this.locZ * 32.0D), + (byte) (int) (this.yaw * 256.0F / 360.0F), + (byte) (int) (this.pitch * 256.0F / 360.0F), + this.onGround + ); + + for (Object obj : this.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_8_R2/pom.xml b/NMS/v1_8_R2/pom.xml index 746cfb04..fb05da22 100644 --- a/NMS/v1_8_R2/pom.xml +++ b/NMS/v1_8_R2/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java index 87926e5a..4920622d 100644 --- a/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java +++ b/NMS/v1_8_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_8_R2; import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger; import com.gmail.filoghost.holographicdisplays.util.Utils; @@ -124,10 +125,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 137 && element.getLineNumber() < 147) { - // Then this method is being called when creating a new packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 137 && element.getLineNumber() < 147) { + // Then this method is being called when creating a new packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -187,24 +190,26 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport( - getIdNMS(), - MathHelper.floor(this.locX * 32.0D), - MathHelper.floor(this.locY * 32.0D), - MathHelper.floor(this.locZ * 32.0D), - (byte) (int) (this.yaw * 256.0F / 360.0F), - (byte) (int) (this.pitch * 256.0F / 360.0F), - this.onGround - ); - - for (Object obj : this.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport( + getIdNMS(), + MathHelper.floor(this.locX * 32.0D), + MathHelper.floor(this.locY * 32.0D), + MathHelper.floor(this.locZ * 32.0D), + (byte) (int) (this.yaw * 256.0F / 360.0F), + (byte) (int) (this.pitch * 256.0F / 360.0F), + this.onGround + ); + + for (Object obj : this.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_8_R3/pom.xml b/NMS/v1_8_R3/pom.xml index 6e6e4df4..e085b189 100644 --- a/NMS/v1_8_R3/pom.xml +++ b/NMS/v1_8_R3/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java index 9e99df2b..ab0821fd 100644 --- a/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java +++ b/NMS/v1_8_R3/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_8_R3; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger; import com.gmail.filoghost.holographicdisplays.util.Utils; @@ -124,10 +125,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 137 && element.getLineNumber() < 147) { - // Then this method is being called when creating a new packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 137 && element.getLineNumber() < 147) { + // Then this method is being called when creating a new packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -187,24 +190,26 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport( - getIdNMS(), - MathHelper.floor(this.locX * 32.0D), - MathHelper.floor(this.locY * 32.0D), - MathHelper.floor(this.locZ * 32.0D), - (byte) (int) (this.yaw * 256.0F / 360.0F), - (byte) (int) (this.pitch * 256.0F / 360.0F), - this.onGround - ); - - for (Object obj : this.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport( + getIdNMS(), + MathHelper.floor(this.locX * 32.0D), + MathHelper.floor(this.locY * 32.0D), + MathHelper.floor(this.locZ * 32.0D), + (byte) (int) (this.yaw * 256.0F / 360.0F), + (byte) (int) (this.pitch * 256.0F / 360.0F), + this.onGround + ); + + for (Object obj : this.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - this.locX) + Utils.square(nmsPlayer.locZ - this.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_9_R1/pom.xml b/NMS/v1_9_R1/pom.xml index 8ba54029..203c9f42 100644 --- a/NMS/v1_9_R1/pom.xml +++ b/NMS/v1_9_R1/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java index 151243ea..2c54ea11 100644 --- a/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java +++ b/NMS/v1_9_R1/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_9_R1; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectField; @@ -134,10 +135,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 142 && element.getLineNumber() < 152) { - // Then this method is being called when creating a new packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 142 && element.getLineNumber() < 152) { + // Then this method is being called when creating a new packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -196,16 +199,18 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); - - for (Object obj : super.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); + + for (Object obj : super.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/NMS/v1_9_R2/pom.xml b/NMS/v1_9_R2/pom.xml index 6337af1a..92eac6d1 100644 --- a/NMS/v1_9_R2/pom.xml +++ b/NMS/v1_9_R2/pom.xml @@ -32,6 +32,12 @@ holographicdisplays-utils 2.3.0-SNAPSHOT + + + ${project.groupId} + holographicdisplays-config + 2.3.0-SNAPSHOT + org.spigotmc diff --git a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java index 03c11e5f..d9735e9b 100644 --- a/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java +++ b/NMS/v1_9_R2/src/main/java/com/gmail/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_9_R2; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; import com.gmail.filoghost.holographicdisplays.api.line.HologramLine; +import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand; import com.gmail.filoghost.holographicdisplays.util.Utils; import com.gmail.filoghost.holographicdisplays.util.reflection.ReflectionUtils; @@ -127,10 +128,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta @Override public int getId() { - StackTraceElement element = ReflectionUtils.getStackTraceElement(2); - if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 142 && element.getLineNumber() < 152) { - // Then this method is being called when creating a new packet, we return a fake ID! - return -1; + if (Configuration.preciseHologramMovement) { + StackTraceElement element = ReflectionUtils.getStackTraceElement(2); + if (element != null && element.getFileName() != null && element.getFileName().equals("EntityTrackerEntry.java") && element.getLineNumber() > 142 && element.getLineNumber() < 152) { + // Then this method is being called when creating a new packet, we return a fake ID! + return -1; + } } return super.getId(); @@ -189,16 +192,18 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); - // Send a packet near to update the position. - PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); - - for (Object obj : super.world.players) { - if (obj instanceof EntityPlayer) { - EntityPlayer nmsPlayer = (EntityPlayer) obj; - - double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); - if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { - nmsPlayer.playerConnection.sendPacket(teleportPacket); + if (Configuration.preciseHologramMovement) { + // Send a packet near to update the position. + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this); + + for (Object obj : super.world.players) { + if (obj instanceof EntityPlayer) { + EntityPlayer nmsPlayer = (EntityPlayer) obj; + + double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ); + if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) { + nmsPlayer.playerConnection.sendPacket(teleportPacket); + } } } } diff --git a/Plugin/src/main/resources/config.yml b/Plugin/src/main/resources/config.yml index 4cc84d6c..0fa74af8 100644 --- a/Plugin/src/main/resources/config.yml +++ b/Plugin/src/main/resources/config.yml @@ -4,6 +4,7 @@ #. Plugin created by filoghost. #. space-between-lines: 0.02 +precise-hologram-movement: true images: symbol: '[x]' transparency: