From ae07fe0bb557216d9fe6c609c2f4948e12f68e99 Mon Sep 17 00:00:00 2001 From: filoghost Date: Sun, 20 Jun 2021 17:23:48 +0200 Subject: [PATCH] Remove trailing whitespace --- .../holographicdisplays/api/Hologram.java | 70 +++++++++---------- .../api/HolographicDisplaysAPI.java | 4 +- .../api/VisibilitySettings.java | 10 +-- .../api/handler/PickupHandler.java | 2 +- .../api/handler/TouchHandler.java | 2 +- .../HolographicDisplaysAPIProvider.java | 12 ++-- .../api/line/CollectableLine.java | 6 +- .../api/line/HologramLine.java | 4 +- .../api/line/ItemLine.java | 2 +- .../api/line/TextLine.java | 4 +- .../api/line/TouchableLine.java | 4 +- .../IndividualPlaceholderFactory.java | 2 +- .../api/placeholder/PlaceholderFactory.java | 2 +- .../common/DebugLogger.java | 8 +-- .../holographicdisplays/common/Utils.java | 6 +- .../common/hologram/StandardHologram.java | 8 +-- .../common/nms/NMSManager.java | 10 +-- .../common/nms/entity/NMSEntity.java | 14 ++-- .../common/nms/entity/NMSItem.java | 4 +- .../common/nms/entity/NMSSlime.java | 2 +- .../common/nms/entity/NMSVehicle.java | 2 +- example/death-holograms/pom.xml | 2 +- .../deathholograms/DeathHolograms.java | 12 ++-- example/pom.xml | 4 +- .../filoghost/example/powerups/PowerUps.java | 14 ++-- legacy-api/pom.xml | 2 +- legacy-api/v1/pom.xml | 2 +- .../filoghost/holograms/api/FloatingItem.java | 4 +- .../filoghost/holograms/api/Hologram.java | 24 +++---- .../holograms/api/HolographicDisplaysAPI.java | 12 ++-- .../holograms/api/ItemTouchHandler.java | 2 +- .../holograms/api/PickupHandler.java | 2 +- .../filoghost/holograms/api/TouchHandler.java | 2 +- .../holographicdisplays/api/Hologram.java | 18 ++--- .../holographicdisplays/api/HologramsAPI.java | 4 +- .../api/VisibilityManager.java | 14 ++-- .../api/handler/PickupHandler.java | 2 +- .../api/handler/TouchHandler.java | 2 +- .../api/internal/HologramsAPIProvider.java | 4 +- .../api/line/CollectableLine.java | 4 +- .../api/line/HologramLine.java | 2 +- .../api/line/ItemLine.java | 2 +- .../api/line/TextLine.java | 4 +- .../api/line/TouchableLine.java | 4 +- .../api/placeholder/PlaceholderReplacer.java | 2 +- nms/pom.xml | 2 +- nms/v1_10_r1/pom.xml | 2 +- .../nms/v1_10_R1/CraftNMSArmorStand.java | 8 +-- .../nms/v1_10_R1/CraftNMSItem.java | 6 +- .../nms/v1_10_R1/CraftNMSSlime.java | 8 +-- .../nms/v1_10_R1/EntityNMSArmorStand.java | 56 +++++++-------- .../nms/v1_10_R1/EntityNMSItem.java | 60 ++++++++-------- .../nms/v1_10_R1/EntityNMSSlime.java | 54 +++++++------- .../nms/v1_10_R1/NullBoundingBox.java | 4 +- .../nms/v1_10_R1/VersionNMSEntityHelper.java | 4 +- .../nms/v1_10_R1/VersionNMSManager.java | 30 ++++---- nms/v1_11_r1/pom.xml | 2 +- .../nms/v1_11_R1/CraftNMSArmorStand.java | 8 +-- .../nms/v1_11_R1/CraftNMSItem.java | 6 +- .../nms/v1_11_R1/CraftNMSSlime.java | 8 +-- .../nms/v1_11_R1/EntityNMSArmorStand.java | 56 +++++++-------- .../nms/v1_11_R1/EntityNMSItem.java | 52 +++++++------- .../nms/v1_11_R1/EntityNMSSlime.java | 52 +++++++------- .../nms/v1_11_R1/NullBoundingBox.java | 4 +- .../nms/v1_11_R1/VersionNMSEntityHelper.java | 2 +- .../nms/v1_11_R1/VersionNMSManager.java | 32 ++++----- nms/v1_12_r1/pom.xml | 2 +- .../nms/v1_12_R1/CraftNMSArmorStand.java | 10 +-- .../nms/v1_12_R1/CraftNMSItem.java | 6 +- .../nms/v1_12_R1/CraftNMSSlime.java | 8 +-- .../nms/v1_12_R1/EntityNMSArmorStand.java | 56 +++++++-------- .../nms/v1_12_R1/EntityNMSItem.java | 50 ++++++------- .../nms/v1_12_R1/EntityNMSSlime.java | 48 ++++++------- .../nms/v1_12_R1/NullBoundingBox.java | 4 +- .../nms/v1_12_R1/VersionNMSEntityHelper.java | 2 +- .../nms/v1_12_R1/VersionNMSManager.java | 34 ++++----- nms/v1_13_r1/pom.xml | 2 +- .../nms/v1_13_R1/CraftNMSArmorStand.java | 12 ++-- .../nms/v1_13_R1/CraftNMSItem.java | 6 +- .../nms/v1_13_R1/CraftNMSSlime.java | 10 +-- .../nms/v1_13_R1/EntityNMSArmorStand.java | 56 +++++++-------- .../nms/v1_13_R1/EntityNMSItem.java | 48 ++++++------- .../nms/v1_13_R1/EntityNMSSlime.java | 50 ++++++------- .../nms/v1_13_R1/NullBoundingBox.java | 4 +- .../nms/v1_13_R1/VersionNMSEntityHelper.java | 2 +- .../nms/v1_13_R1/VersionNMSManager.java | 34 ++++----- nms/v1_13_r2/pom.xml | 2 +- .../nms/v1_13_R2/CraftNMSArmorStand.java | 12 ++-- .../nms/v1_13_R2/CraftNMSItem.java | 6 +- .../nms/v1_13_R2/CraftNMSSlime.java | 10 +-- .../nms/v1_13_R2/EntityNMSArmorStand.java | 56 +++++++-------- .../nms/v1_13_R2/EntityNMSItem.java | 50 ++++++------- .../nms/v1_13_R2/EntityNMSSlime.java | 52 +++++++------- .../nms/v1_13_R2/NullBoundingBox.java | 4 +- .../nms/v1_13_R2/VersionNMSEntityHelper.java | 2 +- .../nms/v1_13_R2/VersionNMSManager.java | 34 ++++----- nms/v1_14_r1/pom.xml | 2 +- .../nms/v1_14_R1/CraftNMSArmorStand.java | 10 +-- .../nms/v1_14_R1/CraftNMSItem.java | 6 +- .../nms/v1_14_R1/CraftNMSSlime.java | 10 +-- .../nms/v1_14_R1/EntityNMSArmorStand.java | 54 +++++++------- .../nms/v1_14_R1/EntityNMSItem.java | 50 ++++++------- .../nms/v1_14_R1/EntityNMSSlime.java | 50 ++++++------- .../nms/v1_14_R1/NullBoundingBox.java | 8 +-- .../nms/v1_14_R1/VersionNMSEntityHelper.java | 2 +- .../nms/v1_14_R1/VersionNMSManager.java | 32 ++++----- nms/v1_15_r1/pom.xml | 2 +- .../nms/v1_15_R1/CraftNMSArmorStand.java | 10 +-- .../nms/v1_15_R1/CraftNMSItem.java | 6 +- .../nms/v1_15_R1/CraftNMSSlime.java | 10 +-- .../nms/v1_15_R1/EntityNMSArmorStand.java | 16 ++--- .../nms/v1_15_R1/EntityNMSItem.java | 10 +-- .../nms/v1_15_R1/EntityNMSSlime.java | 50 ++++++------- .../nms/v1_15_R1/NullBoundingBox.java | 2 +- .../nms/v1_15_R1/VersionNMSEntityHelper.java | 2 +- .../nms/v1_15_R1/VersionNMSManager.java | 32 ++++----- nms/v1_16_r1/pom.xml | 2 +- .../nms/v1_16_R1/CraftNMSArmorStand.java | 10 +-- .../nms/v1_16_R1/CraftNMSItem.java | 6 +- .../nms/v1_16_R1/CraftNMSSlime.java | 10 +-- .../nms/v1_16_R1/EntityNMSArmorStand.java | 16 ++--- .../nms/v1_16_R1/EntityNMSItem.java | 10 +-- .../nms/v1_16_R1/EntityNMSSlime.java | 50 ++++++------- .../nms/v1_16_R1/NullBoundingBox.java | 2 +- .../nms/v1_16_R1/VersionNMSEntityHelper.java | 2 +- .../nms/v1_16_R1/VersionNMSManager.java | 32 ++++----- nms/v1_16_r2/pom.xml | 2 +- .../nms/v1_16_R2/CraftNMSArmorStand.java | 10 +-- .../nms/v1_16_R2/CraftNMSItem.java | 6 +- .../nms/v1_16_R2/CraftNMSSlime.java | 10 +-- .../nms/v1_16_R2/EntityNMSArmorStand.java | 18 ++--- .../nms/v1_16_R2/EntityNMSItem.java | 10 +-- .../nms/v1_16_R2/EntityNMSSlime.java | 50 ++++++------- .../nms/v1_16_R2/NullBoundingBox.java | 2 +- .../nms/v1_16_R2/VersionNMSEntityHelper.java | 2 +- .../nms/v1_16_R2/VersionNMSManager.java | 30 ++++---- nms/v1_16_r3/pom.xml | 2 +- .../nms/v1_16_R3/CraftNMSArmorStand.java | 10 +-- .../nms/v1_16_R3/CraftNMSItem.java | 6 +- .../nms/v1_16_R3/CraftNMSSlime.java | 10 +-- .../nms/v1_16_R3/EntityNMSArmorStand.java | 18 ++--- .../nms/v1_16_R3/EntityNMSItem.java | 10 +-- .../nms/v1_16_R3/EntityNMSSlime.java | 50 ++++++------- .../nms/v1_16_R3/NullBoundingBox.java | 2 +- .../nms/v1_16_R3/VersionNMSEntityHelper.java | 2 +- .../nms/v1_16_R3/VersionNMSManager.java | 34 ++++----- nms/v1_8_r2/pom.xml | 2 +- .../nms/v1_8_R2/CraftNMSArmorStand.java | 8 +-- .../nms/v1_8_R2/CraftNMSItem.java | 4 +- .../nms/v1_8_R2/CraftNMSSlime.java | 10 +-- .../nms/v1_8_R2/EntityNMSArmorStand.java | 52 +++++++------- .../nms/v1_8_R2/EntityNMSItem.java | 48 ++++++------- .../nms/v1_8_R2/EntityNMSSlime.java | 44 ++++++------ .../nms/v1_8_R2/NullBoundingBox.java | 2 +- .../nms/v1_8_R2/VersionNMSEntityHelper.java | 2 +- .../nms/v1_8_R2/VersionNMSManager.java | 34 ++++----- nms/v1_8_r3/pom.xml | 2 +- .../nms/v1_8_R3/CraftNMSArmorStand.java | 8 +-- .../nms/v1_8_R3/CraftNMSItem.java | 4 +- .../nms/v1_8_R3/CraftNMSSlime.java | 10 +-- .../nms/v1_8_R3/EntityNMSArmorStand.java | 54 +++++++------- .../nms/v1_8_R3/EntityNMSItem.java | 52 +++++++------- .../nms/v1_8_R3/EntityNMSSlime.java | 46 ++++++------ .../nms/v1_8_R3/NullBoundingBox.java | 2 +- .../nms/v1_8_R3/VersionNMSEntityHelper.java | 2 +- .../nms/v1_8_R3/VersionNMSManager.java | 26 +++---- nms/v1_9_r1/pom.xml | 2 +- .../nms/v1_9_R1/CraftNMSArmorStand.java | 8 +-- .../nms/v1_9_R1/CraftNMSItem.java | 6 +- .../nms/v1_9_R1/CraftNMSSlime.java | 12 ++-- .../nms/v1_9_R1/EntityNMSArmorStand.java | 60 ++++++++-------- .../nms/v1_9_R1/EntityNMSItem.java | 60 ++++++++-------- .../nms/v1_9_R1/EntityNMSSlime.java | 54 +++++++------- .../nms/v1_9_R1/NullBoundingBox.java | 4 +- .../nms/v1_9_R1/VersionNMSEntityHelper.java | 2 +- .../nms/v1_9_R1/VersionNMSManager.java | 36 +++++----- nms/v1_9_r2/pom.xml | 2 +- .../nms/v1_9_R2/CraftNMSArmorStand.java | 8 +-- .../nms/v1_9_R2/CraftNMSItem.java | 6 +- .../nms/v1_9_R2/CraftNMSSlime.java | 12 ++-- .../nms/v1_9_R2/EntityNMSArmorStand.java | 58 +++++++-------- .../nms/v1_9_R2/EntityNMSItem.java | 62 ++++++++-------- .../nms/v1_9_R2/EntityNMSSlime.java | 56 +++++++-------- .../nms/v1_9_R2/NullBoundingBox.java | 4 +- .../nms/v1_9_R2/VersionNMSEntityHelper.java | 2 +- .../nms/v1_9_R2/VersionNMSManager.java | 32 ++++----- plugin/pom.xml | 30 ++++---- .../holographicdisplays/plugin/Colors.java | 10 +-- .../plugin/HolographicDisplays.java | 28 ++++---- .../DefaultHolographicDisplaysAPI.java | 12 ++-- ...DefaultHolographicDisplaysAPIProvider.java | 6 +- .../plugin/api/v2/V2HologramsAPIProvider.java | 24 +++---- .../plugin/api/v2/V2TouchableLineAdapter.java | 2 +- .../bridge/bungeecord/BungeeMessenger.java | 26 +++---- .../bungeecord/BungeeServerTracker.java | 12 ++-- .../plugin/bridge/bungeecord/ServerInfo.java | 6 +- .../bungeecord/pinger/PingResponse.java | 10 +-- .../bungeecord/pinger/ServerPinger.java | 8 +-- .../placeholderapi/PlaceholderAPIHook.java | 6 +- .../bridge/protocollib/DebugHelper.java | 38 +++++----- .../bridge/protocollib/MetadataHelper.java | 50 ++++++------- .../bridge/protocollib/PacketListener.java | 22 +++--- .../bridge/protocollib/PacketSender.java | 52 +++++++------- .../bridge/protocollib/ProtocolLibHook.java | 6 +- .../commands/HologramCommandManager.java | 14 ++-- .../commands/HologramCommandValidate.java | 8 +-- .../plugin/commands/HologramSubCommand.java | 4 +- .../plugin/commands/Messages.java | 12 ++-- .../plugin/commands/subs/AddlineCommand.java | 4 +- .../plugin/commands/subs/AlignCommand.java | 10 +-- .../plugin/commands/subs/CopyCommand.java | 12 ++-- .../plugin/commands/subs/CreateCommand.java | 24 +++---- .../plugin/commands/subs/DebugCommand.java | 20 +++--- .../plugin/commands/subs/DeleteCommand.java | 6 +- .../plugin/commands/subs/EditCommand.java | 6 +- .../plugin/commands/subs/HelpCommand.java | 4 +- .../plugin/commands/subs/InfoCommand.java | 6 +- .../commands/subs/InsertlineCommand.java | 12 ++-- .../plugin/commands/subs/ListCommand.java | 20 +++--- .../plugin/commands/subs/MovehereCommand.java | 6 +- .../plugin/commands/subs/NearCommand.java | 20 +++--- .../commands/subs/QuickEditCommand.java | 2 +- .../commands/subs/ReadimageCommand.java | 28 ++++---- .../plugin/commands/subs/ReadtextCommand.java | 24 +++---- .../plugin/commands/subs/ReloadCommand.java | 4 +- .../commands/subs/RemovelineCommand.java | 12 ++-- .../plugin/commands/subs/SetlineCommand.java | 8 +-- .../plugin/commands/subs/TeleportCommand.java | 6 +- .../plugin/disk/ConfigManager.java | 8 +-- .../plugin/disk/Configuration.java | 12 ++-- .../plugin/disk/ConfigurationFileModel.java | 18 ++--- .../plugin/disk/HologramConfig.java | 6 +- .../plugin/disk/HologramLineParser.java | 30 ++++---- .../plugin/disk/ServerAddress.java | 8 +-- .../plugin/disk/StaticReplacements.java | 16 ++--- .../plugin/disk/TextFormatter.java | 4 +- .../disk/upgrade/LegacySymbolsUpgrade.java | 6 +- .../event/HolographicDisplaysReloadEvent.java | 8 +-- .../event/InternalHologramEditEvent.java | 10 +-- .../plugin/hologram/api/APIHologram.java | 6 +- .../plugin/hologram/api/APIHologramLine.java | 2 +- .../hologram/api/APIHologramManager.java | 4 +- .../plugin/hologram/api/APIItemLine.java | 4 +- .../plugin/hologram/api/APITextLine.java | 2 +- .../api/DefaultVisibilitySettings.java | 38 +++++----- .../plugin/hologram/base/BaseHologram.java | 38 +++++----- .../hologram/base/BaseHologramComponent.java | 10 +-- .../hologram/base/BaseHologramLine.java | 10 +-- .../hologram/base/BaseHologramManager.java | 2 +- .../plugin/hologram/base/BaseItemLine.java | 30 ++++---- .../plugin/hologram/base/BaseTextLine.java | 20 +++--- .../hologram/base/BaseTouchableLine.java | 10 +-- .../hologram/internal/InternalHologram.java | 2 +- .../internal/InternalHologramLine.java | 2 +- .../internal/InternalHologramManager.java | 4 +- .../plugin/image/ImageMessage.java | 50 ++++++------- .../plugin/image/ImageReader.java | 8 +-- .../lib/packetwrapper/AbstractPacket.java | 4 +- .../WrapperPlayServerAttachEntity.java | 22 +++--- .../WrapperPlayServerEntityDestroy.java | 14 ++-- .../WrapperPlayServerEntityMetadata.java | 16 ++--- .../packetwrapper/WrapperPlayServerMount.java | 16 ++--- .../WrapperPlayServerSpawnEntity.java | 34 ++++----- .../WrapperPlayServerSpawnEntityLiving.java | 28 ++++---- .../plugin/listener/InteractListener.java | 12 ++-- .../listener/UpdateNotificationListener.java | 6 +- .../plugin/log/MessagePartJoiner.java | 2 +- .../plugin/log/PrintableErrorCollector.java | 6 +- .../placeholder/StandardPlaceholder.java | 2 +- .../plugin/placeholder/TickClock.java | 4 +- .../internal/AnimationPlaceholder.java | 4 +- .../internal/AnimationRegistry.java | 16 ++--- .../internal/DefaultPlaceholders.java | 4 +- .../OnlinePlayersPlaceholderFactory.java | 6 +- .../WorldPlayersPlaceholderFactory.java | 6 +- .../parsing/PlaceholderIdentifier.java | 2 +- .../parsing/PlaceholderOccurrence.java | 10 +-- .../parsing/PlaceholderReplaceFunction.java | 2 +- .../placeholder/parsing/PluginName.java | 2 +- .../parsing/StringWithPlaceholders.java | 46 ++++++------ .../registry/GlobalPlaceholderExpansion.java | 14 ++-- .../IndividualPlaceholderExpansion.java | 14 ++-- .../registry/PlaceholderExpansion.java | 6 +- .../registry/PlaceholderRegistry.java | 22 +++--- .../tracking/PlaceholderExceptionHandler.java | 6 +- .../tracking/PlaceholderTracker.java | 6 +- .../tracking/TrackedGlobalPlaceholder.java | 2 +- .../tracking/TrackedPlaceholder.java | 2 +- .../plugin/util/FileUtils.java | 2 +- .../plugin/util/NMSVersion.java | 12 ++-- .../plugin/util/VersionUtils.java | 14 ++-- .../api/v2/V2TouchableLineAdapterTest.java | 28 ++++---- .../parsing/StringWithPlaceholdersTest.java | 12 ++-- pom.xml | 58 +++++++-------- 294 files changed, 2293 insertions(+), 2293 deletions(-) diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java b/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java index a79cae78..cf0eb106 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; * @since 1 */ public interface Hologram { - + /** * Appends a text line to end of this hologram. * @@ -31,8 +31,8 @@ public interface Hologram { * @since 1 */ @NotNull TextLine appendTextLine(@Nullable String text); - - + + /** * Appends an item line to end of this hologram. * @@ -41,8 +41,8 @@ public interface Hologram { * @since 1 */ @NotNull ItemLine appendItemLine(@NotNull ItemStack itemStack); - - + + /** * Inserts a text line in this hologram. * @@ -53,8 +53,8 @@ public interface Hologram { * @since 1 */ @NotNull TextLine insertTextLine(int index, @Nullable String text); - - + + /** * Inserts an item line in this hologram. * @@ -65,8 +65,8 @@ public interface Hologram { * @since 1 */ @NotNull ItemLine insertItemLine(int index, @NotNull ItemStack itemStack); - - + + /** * Finds the element at a given index in the lines. * @@ -76,7 +76,7 @@ public interface Hologram { * @since 1 */ @NotNull HologramLine getLine(int index); - + /** * Removes a line at a given index. Since: v2.0.1 * @@ -85,8 +85,8 @@ public interface Hologram { * @since 1 */ void removeLine(int index); - - + + /** * Removes all the lines from this hologram. * @@ -94,7 +94,7 @@ public interface Hologram { */ void clearLines(); - + /** * Checks the amount of lines of the hologram. * @@ -102,8 +102,8 @@ public interface Hologram { * @since 1 */ int getLineCount(); - - + + /** * The physical height of the hologram, counting all the lines. Since: v2.1.4 * @@ -111,8 +111,8 @@ public interface Hologram { * @since 1 */ double getHeight(); - - + + /** * Teleports a hologram to the given location. * @@ -120,8 +120,8 @@ public interface Hologram { * @since 1 */ void teleport(@NotNull Location location); - - + + /** * Teleports a hologram to the given location. * @@ -132,7 +132,7 @@ public interface Hologram { * @since 1 */ void teleport(@NotNull World world, double x, double y, double z); - + /** * Returns the position of the hologram. * @@ -140,7 +140,7 @@ public interface Hologram { * @since 1 */ @NotNull Location getLocation(); - + /** * Returns the X coordinate. * @@ -148,8 +148,8 @@ public interface Hologram { * @since 1 */ double getX(); - - + + /** * Returns the Y coordinate. * @@ -157,8 +157,8 @@ public interface Hologram { * @since 1 */ double getY(); - - + + /** * Returns the Z coordinate. * @@ -166,8 +166,8 @@ public interface Hologram { * @since 1 */ double getZ(); - - + + /** * Returns the world. * @@ -175,8 +175,8 @@ public interface Hologram { * @since 1 */ @NotNull World getWorld(); - - + + /** * Returns the {@link VisibilitySettings} of this hologram. *
Note: the usage of the VisibilitySettings requires ProtocolLib. @@ -186,8 +186,8 @@ public interface Hologram { * @since 1 */ @NotNull VisibilitySettings getVisibilitySettings(); - - + + /** * Returns when the hologram was created. Useful for removing old holograms. * @@ -213,7 +213,7 @@ public interface Hologram { * @since 1 */ void setAllowPlaceholders(boolean allowPlaceholders); - + /** * Deletes this hologram. Editing or teleporting the hologram when deleted * will throw an exception. Lines will be automatically cleared. @@ -222,8 +222,8 @@ public interface Hologram { * @since 1 */ void delete(); - - + + /** * Checks if a hologram was deleted. * @@ -231,5 +231,5 @@ public interface Hologram { * @since 1 */ boolean isDeleted(); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java b/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java index 84a42e52..8c5609ab 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java @@ -39,7 +39,7 @@ public interface HolographicDisplaysAPI { static int getVersion() { return 1; } - + static @NotNull HolographicDisplaysAPI get(@NotNull Plugin plugin) { return HolographicDisplaysAPIProvider.getImplementation().getHolographicDisplaysAPI(plugin); } @@ -70,7 +70,7 @@ public interface HolographicDisplaysAPI { * @since 1 */ boolean isRegisteredPlaceholder(@NotNull String identifier); - + /** * Returns all the registered placeholder identifiers. * diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilitySettings.java b/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilitySettings.java index c2bbda43..b847dd57 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilitySettings.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilitySettings.java @@ -36,7 +36,7 @@ public interface VisibilitySettings { * @since 1 */ void setDefaultVisibility(@NotNull Visibility defaultVisibility); - + /** * Sets the visibility for a specific player, overriding the default value ({@link #getDefaultVisibility()}). * The individual visibility value can be reverted with {@link #resetIndividualVisibility(Player)}. @@ -58,7 +58,7 @@ public interface VisibilitySettings { * @since 1 */ void resetIndividualVisibilityAll(); - + /** * Checks if a hologram is visible to a player, taking into account the individual visibility for the specific * player and the default visibility. @@ -74,10 +74,10 @@ public interface VisibilitySettings { * The available statuses for the visibility of a hologram. */ enum Visibility { - + VISIBLE, HIDDEN - + } - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/handler/PickupHandler.java b/api/src/main/java/me/filoghost/holographicdisplays/api/handler/PickupHandler.java index 02af34dd..60364007 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/handler/PickupHandler.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/handler/PickupHandler.java @@ -22,5 +22,5 @@ public interface PickupHandler { * @since 1 */ void onPickup(@NotNull Player player); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/handler/TouchHandler.java b/api/src/main/java/me/filoghost/holographicdisplays/api/handler/TouchHandler.java index 5ba993c0..28eb95ad 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/handler/TouchHandler.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/handler/TouchHandler.java @@ -22,5 +22,5 @@ public interface TouchHandler { * @since 1 */ void onTouch(@NotNull Player player); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/internal/HolographicDisplaysAPIProvider.java b/api/src/main/java/me/filoghost/holographicdisplays/api/internal/HolographicDisplaysAPIProvider.java index edf9670a..c9ee3c29 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/internal/HolographicDisplaysAPIProvider.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/internal/HolographicDisplaysAPIProvider.java @@ -14,23 +14,23 @@ import org.jetbrains.annotations.ApiStatus.Internal; public abstract class HolographicDisplaysAPIProvider { public static final String ERROR_IMPLEMENTATION_NOT_SET = "Holographic Displays did not load properly (no API implementation was set)"; - + private static HolographicDisplaysAPIProvider implementation; - + public static void setImplementation(HolographicDisplaysAPIProvider implementation) { HolographicDisplaysAPIProvider.implementation = implementation; } - + public static HolographicDisplaysAPIProvider getImplementation() { if (implementation == null) { throw new IllegalStateException(ERROR_IMPLEMENTATION_NOT_SET); } - + return implementation; } - + public abstract HolographicDisplaysAPI getHolographicDisplaysAPI(Plugin plugin); - + public abstract boolean isHologramEntity(Entity entity); } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/line/CollectableLine.java b/api/src/main/java/me/filoghost/holographicdisplays/api/line/CollectableLine.java index 4a106754..5db1ec22 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/line/CollectableLine.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/line/CollectableLine.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable; * @since 1 */ public interface CollectableLine extends HologramLine { - + /** * Sets the PickupHandler for this line. * @@ -22,7 +22,7 @@ public interface CollectableLine extends HologramLine { * @since 1 */ void setPickupHandler(@Nullable PickupHandler pickupHandler); - + /** * Returns the current PickupHandler of this line. * @@ -30,5 +30,5 @@ public interface CollectableLine extends HologramLine { * @since 1 */ @Nullable PickupHandler getPickupHandler(); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/line/HologramLine.java b/api/src/main/java/me/filoghost/holographicdisplays/api/line/HologramLine.java index 817e0875..3bb8e053 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/line/HologramLine.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/line/HologramLine.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull; * @since 1 */ public interface HologramLine { - + /** * Returns the parent Hologram of this line. * @@ -22,7 +22,7 @@ public interface HologramLine { * @since 1 */ @NotNull Hologram getParent(); - + /** * Removes this line from the parent Hologram. Since: v2.0.1 * Do not call if the Hologram has been deleted, an exception will be thrown. diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/line/ItemLine.java b/api/src/main/java/me/filoghost/holographicdisplays/api/line/ItemLine.java index d530a259..3197ecca 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/line/ItemLine.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/line/ItemLine.java @@ -28,5 +28,5 @@ public interface ItemLine extends CollectableLine, TouchableLine { * @since 1 */ void setItemStack(@NotNull ItemStack itemStack); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/line/TextLine.java b/api/src/main/java/me/filoghost/holographicdisplays/api/line/TextLine.java index 76c56695..264b422f 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/line/TextLine.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/line/TextLine.java @@ -19,7 +19,7 @@ public interface TextLine extends TouchableLine { * @since 1 */ @Nullable String getText(); - + /** * Sets the text of this TextLine. * @@ -27,5 +27,5 @@ public interface TextLine extends TouchableLine { * @since 1 */ void setText(@Nullable String text); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/line/TouchableLine.java b/api/src/main/java/me/filoghost/holographicdisplays/api/line/TouchableLine.java index fa546152..c797722c 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/line/TouchableLine.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/line/TouchableLine.java @@ -22,7 +22,7 @@ public interface TouchableLine extends HologramLine { * @since 1 */ void setTouchHandler(@Nullable TouchHandler touchHandler); - + /** * Returns the current TouchHandler of this line. * @@ -30,5 +30,5 @@ public interface TouchableLine extends HologramLine { * @since 1 */ @Nullable TouchHandler getTouchHandler(); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/IndividualPlaceholderFactory.java b/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/IndividualPlaceholderFactory.java index 85d7fcc4..21baebad 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/IndividualPlaceholderFactory.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/IndividualPlaceholderFactory.java @@ -16,5 +16,5 @@ public interface IndividualPlaceholderFactory { * @since 1 */ @Nullable IndividualPlaceholder getPlaceholder(@Nullable String argument); - + } diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/PlaceholderFactory.java b/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/PlaceholderFactory.java index c3f5b086..578248ac 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/PlaceholderFactory.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/placeholder/PlaceholderFactory.java @@ -16,5 +16,5 @@ public interface PlaceholderFactory { * @since 1 */ @Nullable Placeholder getPlaceholder(@Nullable String argument); - + } diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/DebugLogger.java b/common/src/main/java/me/filoghost/holographicdisplays/common/DebugLogger.java index 2ac6367c..5de63160 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/DebugLogger.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/DebugLogger.java @@ -10,7 +10,7 @@ import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine; import me.filoghost.holographicdisplays.common.nms.SpawnFailedException; public class DebugLogger { - + private static boolean debug; private static final String PREFIX = "[Debug] "; @@ -27,7 +27,7 @@ public class DebugLogger { Log.info(PREFIX + msg, thrown); } } - + public static void warning(String msg) { warning(msg, null); } @@ -37,7 +37,7 @@ public class DebugLogger { Log.warning(PREFIX + msg, thrown); } } - + public static void severe(String msg) { severe(msg, null); } @@ -47,7 +47,7 @@ public class DebugLogger { Log.severe(PREFIX + msg, thrown); } } - + public static void handleSpawnFail(SpawnFailedException exception, StandardHologramLine parentHologramLine) { severe("Couldn't spawn entity for this hologram: " + parentHologramLine.getHologram(), exception); } diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/Utils.java b/common/src/main/java/me/filoghost/holographicdisplays/common/Utils.java index d83899b3..bd6f7195 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/Utils.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/Utils.java @@ -12,7 +12,7 @@ public class Utils { public static double distanceSquared(double locX1, double locX2, double locZ1, double locZ2) { return square(locX1 - locX2) + square(locZ1 - locZ2); } - + public static double square(double num) { return num * num; } @@ -20,12 +20,12 @@ public class Utils { public static String formatExceptionMessage(Throwable t) { return formatExceptionMessage(t.getMessage()); } - + public static String formatExceptionMessage(String message) { if (Strings.isEmpty(message)) { return message; } - + message = Strings.capitalizeFirst(message); char lastChar = message.charAt(message.length() - 1); if (Character.isLetterOrDigit(lastChar)) { diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologram.java b/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologram.java index af8a2b72..f84fb99c 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologram.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologram.java @@ -13,13 +13,13 @@ import org.bukkit.plugin.Plugin; import java.util.List; public interface StandardHologram { - + World getWorld(); - + double getX(); - + double getY(); - + double getZ(); boolean isInChunk(Chunk chunk); diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/NMSManager.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/NMSManager.java index 6d113c87..7cc39b9a 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/NMSManager.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/NMSManager.java @@ -16,23 +16,23 @@ import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; public interface NMSManager { - + /** * Register all the custom entities of the plugin. * * @throws Exception if anything during the process fails */ void setup() throws Exception; - + NMSArmorStand spawnNMSArmorStand(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException; - + NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, StandardItemLine parentHologramLine, ItemStack stack) throws SpawnFailedException; - + NMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, StandardHologramLine parentHologramLine) throws SpawnFailedException; - + boolean isNMSEntityBase(Entity bukkitEntity); NMSEntity getNMSEntityBase(Entity bukkitEntity); diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSEntity.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSEntity.java index 43faf939..64f5e897 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSEntity.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSEntity.java @@ -12,19 +12,19 @@ import org.bukkit.entity.Player; * A custom entity that is part of a hologram. */ public interface NMSEntity { - + StandardHologramLine getHologramLine(); - + void setLocationNMS(double x, double y, double z); - + boolean isDeadNMS(); - + void killEntityNMS(); - + int getIdNMS(); - + org.bukkit.entity.Entity getBukkitEntityNMS(); - + boolean isTrackedBy(Player bukkitPlayer); } diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSItem.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSItem.java index 77f10bc1..0f656dd7 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSItem.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSItem.java @@ -8,12 +8,12 @@ package me.filoghost.holographicdisplays.common.nms.entity; import org.bukkit.inventory.ItemStack; public interface NMSItem extends NMSEntity { - + void setItemStackNMS(ItemStack stack); /** * Returns the item stack NMS object. */ Object getRawItemStack(); - + } diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSSlime.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSSlime.java index 7a3d5848..7eaff379 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSSlime.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSSlime.java @@ -6,5 +6,5 @@ package me.filoghost.holographicdisplays.common.nms.entity; public interface NMSSlime extends NMSEntity { - + } diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSVehicle.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSVehicle.java index 1523f75f..a02a69a0 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSVehicle.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSVehicle.java @@ -8,5 +8,5 @@ package me.filoghost.holographicdisplays.common.nms.entity; public interface NMSVehicle extends NMSEntity { void setPassengerNMS(NMSEntity passenger); - + } diff --git a/example/death-holograms/pom.xml b/example/death-holograms/pom.xml index 66b6c3bb..1217b3e4 100644 --- a/example/death-holograms/pom.xml +++ b/example/death-holograms/pom.xml @@ -11,5 +11,5 @@ holographicdisplays-example-deathholograms HolographicDisplays Example DeathHolograms - + diff --git a/example/death-holograms/src/main/java/me/filoghost/example/deathholograms/DeathHolograms.java b/example/death-holograms/src/main/java/me/filoghost/example/deathholograms/DeathHolograms.java index 08fd5ae8..c50728e0 100644 --- a/example/death-holograms/src/main/java/me/filoghost/example/deathholograms/DeathHolograms.java +++ b/example/death-holograms/src/main/java/me/filoghost/example/deathholograms/DeathHolograms.java @@ -20,7 +20,7 @@ import java.time.format.DateTimeFormatter; public class DeathHolograms extends JavaPlugin implements Listener { private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("H:mm"); - + private HolographicDisplaysAPI holographicDisplaysAPI; @Override @@ -31,18 +31,18 @@ public class DeathHolograms extends JavaPlugin implements Listener { this.setEnabled(false); return; } - + holographicDisplaysAPI = HolographicDisplaysAPI.get(this); Bukkit.getPluginManager().registerEvents(this, this); } - - + + @EventHandler public void onPlayerDeath(PlayerDeathEvent event) { Hologram hologram = holographicDisplaysAPI.createHologram(event.getEntity().getEyeLocation()); - + hologram.appendTextLine(ChatColor.RED + "Player " + ChatColor.GOLD + event.getEntity().getName() + ChatColor.RED + " died here!"); hologram.appendTextLine(ChatColor.GRAY + "Time of death: " + TIME_FORMATTER.format(Instant.now())); } - + } diff --git a/example/pom.xml b/example/pom.xml index 7863311b..914488d6 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -17,13 +17,13 @@ death-holograms power-ups - + ${project.groupId} holographicdisplays-api - + org.spigotmc spigot-api diff --git a/example/power-ups/src/main/java/me/filoghost/example/powerups/PowerUps.java b/example/power-ups/src/main/java/me/filoghost/example/powerups/PowerUps.java index 0bdfafc4..fda7a292 100644 --- a/example/power-ups/src/main/java/me/filoghost/example/powerups/PowerUps.java +++ b/example/power-ups/src/main/java/me/filoghost/example/powerups/PowerUps.java @@ -38,31 +38,31 @@ public class PowerUps extends JavaPlugin implements Listener { holographicDisplaysAPI = HolographicDisplaysAPI.get(this); Bukkit.getPluginManager().registerEvents(this, this); } - - + + @EventHandler public void onEntityDeath(EntityDeathEvent event) { if (event.getEntityType() == EntityType.ZOMBIE) { // Remove normal drops and exp event.getDrops().clear(); event.setDroppedExp(0); - + // Spawn the floating item with a label Hologram hologram = holographicDisplaysAPI.createHologram(event.getEntity().getLocation().add(0.0, 0.9, 0.0)); hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp"); ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR)); - + icon.setPickupHandler((Player player) -> { // Play an effect player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null); - + // 30 seconds of speed II player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true); - + // Delete the hologram hologram.delete(); }); } } - + } diff --git a/legacy-api/pom.xml b/legacy-api/pom.xml index 506e468e..b3ece246 100644 --- a/legacy-api/pom.xml +++ b/legacy-api/pom.xml @@ -23,7 +23,7 @@ ${project.groupId} holographicdisplays-api - + org.spigotmc spigot-api diff --git a/legacy-api/v1/pom.xml b/legacy-api/v1/pom.xml index 93e8a2c7..cee0ebe5 100644 --- a/legacy-api/v1/pom.xml +++ b/legacy-api/v1/pom.xml @@ -11,5 +11,5 @@ holographicdisplays-legacy-api-v1 HolographicDisplays Legacy API v1 - + diff --git a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/FloatingItem.java b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/FloatingItem.java index 5a2a513d..13fd4a94 100644 --- a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/FloatingItem.java +++ b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/FloatingItem.java @@ -53,7 +53,7 @@ public interface FloatingItem { @Deprecated boolean hasTouchHandler(); - + @Deprecated void setPickupHandler(PickupHandler handler); @@ -71,5 +71,5 @@ public interface FloatingItem { @Deprecated boolean isDeleted(); - + } diff --git a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/Hologram.java b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/Hologram.java index c3d4155b..3fe9d355 100644 --- a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/Hologram.java +++ b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/Hologram.java @@ -19,7 +19,7 @@ public interface Hologram { @Deprecated void hide(); - + @Deprecated void addLine(String text); @@ -34,40 +34,40 @@ public interface Hologram { @Deprecated String[] getLines(); - + @Deprecated int getLinesLength(); - + @Deprecated void clearLines(); - + @Deprecated Location getLocation(); - + @Deprecated double getX(); - + @Deprecated double getY(); - + @Deprecated double getZ(); - + @Deprecated World getWorld(); @Deprecated void setLocation(Location location); - + @Deprecated void teleport(Location location); - + @Deprecated void setTouchHandler(TouchHandler handler); @Deprecated TouchHandler getTouchHandler(); - + @Deprecated boolean hasTouchHandler(); @@ -79,5 +79,5 @@ public interface Hologram { @Deprecated boolean isDeleted(); - + } diff --git a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java index f5270782..7b2d5cef 100644 --- a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java +++ b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/HolographicDisplaysAPI.java @@ -24,7 +24,7 @@ import java.util.Set; public class HolographicDisplaysAPI { private static final Set notifiedPlugins = new HashSet<>(); - + @Deprecated public static Hologram createHologram(Plugin plugin, Location source, String... lines) { throw removedAPIException(plugin); @@ -39,22 +39,22 @@ public class HolographicDisplaysAPI { public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) { throw removedAPIException(plugin); } - + @Deprecated public static Hologram createIndividualHologram(Plugin plugin, Location source, List whoCanSee, String... lines) { throw removedAPIException(plugin); } - + @Deprecated public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) { throw removedAPIException(plugin); } - + @Deprecated public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List whoCanSee, ItemStack itemstack) { throw removedAPIException(plugin); } - + @Deprecated public static Hologram[] getHolograms(Plugin plugin) { throw removedAPIException(plugin); @@ -64,7 +64,7 @@ public class HolographicDisplaysAPI { public static FloatingItem[] getFloatingItems(Plugin plugin) { throw removedAPIException(plugin); } - + private static RuntimeException removedAPIException(Plugin plugin) { if (plugin != null && notifiedPlugins.add(plugin.getName())) { Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Holographic Displays] The plugin \"" diff --git a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/ItemTouchHandler.java b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/ItemTouchHandler.java index 0d2b859b..242e79df 100644 --- a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/ItemTouchHandler.java +++ b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/ItemTouchHandler.java @@ -15,5 +15,5 @@ public interface ItemTouchHandler { @Deprecated void onTouch(FloatingItem floatingItem, Player player); - + } diff --git a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/PickupHandler.java b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/PickupHandler.java index 89b7cc01..52d601ca 100644 --- a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/PickupHandler.java +++ b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/PickupHandler.java @@ -15,5 +15,5 @@ public interface PickupHandler { @Deprecated void onPickup(FloatingItem floatingItem, Player player); - + } diff --git a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/TouchHandler.java b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/TouchHandler.java index 657e2874..eae27177 100644 --- a/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/TouchHandler.java +++ b/legacy-api/v1/src/main/java/com/gmail/filoghost/holograms/api/TouchHandler.java @@ -15,5 +15,5 @@ public interface TouchHandler { @Deprecated void onTouch(Hologram hologram, Player player); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/Hologram.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/Hologram.java index ac4f431a..6ecd13e3 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/Hologram.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/Hologram.java @@ -23,7 +23,7 @@ public interface Hologram { @Deprecated ItemLine appendItemLine(ItemStack itemStack); - + @Deprecated TextLine insertTextLine(int index, String text); @@ -32,7 +32,7 @@ public interface Hologram { @Deprecated HologramLine getLine(int index); - + @Deprecated void removeLine(int index); @@ -47,13 +47,13 @@ public interface Hologram { @Deprecated void teleport(Location location); - + @Deprecated void teleport(World world, double x, double y, double z); - + @Deprecated Location getLocation(); - + @Deprecated double getX(); @@ -62,7 +62,7 @@ public interface Hologram { @Deprecated double getZ(); - + @Deprecated World getWorld(); @@ -77,11 +77,11 @@ public interface Hologram { @Deprecated void setAllowPlaceholders(boolean allowPlaceholders); - + @Deprecated void delete(); - + @Deprecated boolean isDeleted(); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/HologramsAPI.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/HologramsAPI.java index 84dde9b8..bb7122df 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/HologramsAPI.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/HologramsAPI.java @@ -35,7 +35,7 @@ public class HologramsAPI { public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) { return HologramsAPIProvider.getImplementation().registerPlaceholder(plugin, textPlaceholder, refreshRate, replacer); } - + @Deprecated public static Collection getRegisteredPlaceholders(Plugin plugin) { return HologramsAPIProvider.getImplementation().getRegisteredPlaceholders(plugin); @@ -45,7 +45,7 @@ public class HologramsAPI { public static boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) { return HologramsAPIProvider.getImplementation().unregisterPlaceholder(plugin, textPlaceholder); } - + @Deprecated public static void unregisterPlaceholders(Plugin plugin) { HologramsAPIProvider.getImplementation().unregisterPlaceholders(plugin); diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/VisibilityManager.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/VisibilityManager.java index d0d6dc13..daccac27 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/VisibilityManager.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/VisibilityManager.java @@ -15,23 +15,23 @@ public interface VisibilityManager { @Deprecated boolean isVisibleByDefault(); - + @Deprecated void setVisibleByDefault(boolean visibleByDefault); - + @Deprecated void showTo(Player player); - + @Deprecated void hideTo(Player player); - + @Deprecated boolean isVisibleTo(Player player); - + @Deprecated void resetVisibility(Player player); - + @Deprecated void resetVisibilityAll(); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/PickupHandler.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/PickupHandler.java index d36ed2d7..103880c7 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/PickupHandler.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/PickupHandler.java @@ -15,5 +15,5 @@ public interface PickupHandler { @Deprecated void onPickup(Player player); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/TouchHandler.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/TouchHandler.java index bf60d28b..8293c8f7 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/TouchHandler.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/handler/TouchHandler.java @@ -15,5 +15,5 @@ public interface TouchHandler { @Deprecated void onTouch(Player player); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/internal/HologramsAPIProvider.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/internal/HologramsAPIProvider.java index 82241823..758a024d 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/internal/HologramsAPIProvider.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/internal/HologramsAPIProvider.java @@ -21,7 +21,7 @@ import java.util.Collection; @Deprecated @Internal public abstract class HologramsAPIProvider { - + private static HologramsAPIProvider implementation; @Deprecated @@ -34,7 +34,7 @@ public abstract class HologramsAPIProvider { if (implementation == null) { throw new IllegalStateException(HolographicDisplaysAPIProvider.ERROR_IMPLEMENTATION_NOT_SET); } - + return implementation; } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/CollectableLine.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/CollectableLine.java index 1c9b086f..105ec22a 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/CollectableLine.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/CollectableLine.java @@ -15,8 +15,8 @@ public interface CollectableLine extends HologramLine { @Deprecated void setPickupHandler(PickupHandler pickupHandler); - + @Deprecated PickupHandler getPickupHandler(); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/HologramLine.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/HologramLine.java index a8d36bce..bd0a3ce1 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/HologramLine.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/HologramLine.java @@ -15,7 +15,7 @@ public interface HologramLine { @Deprecated Hologram getParent(); - + @Deprecated void removeLine(); diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/ItemLine.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/ItemLine.java index b8602d4d..e13b2c1b 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/ItemLine.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/ItemLine.java @@ -18,5 +18,5 @@ public interface ItemLine extends CollectableLine, TouchableLine { @Deprecated void setItemStack(ItemStack itemStack); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TextLine.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TextLine.java index 0afbe2a6..554ee558 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TextLine.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TextLine.java @@ -13,8 +13,8 @@ public interface TextLine extends TouchableLine { @Deprecated String getText(); - + @Deprecated void setText(String text); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TouchableLine.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TouchableLine.java index d28cdd7f..5142cb6b 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TouchableLine.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/line/TouchableLine.java @@ -15,8 +15,8 @@ public interface TouchableLine extends HologramLine { @Deprecated void setTouchHandler(TouchHandler touchHandler); - + @Deprecated TouchHandler getTouchHandler(); - + } diff --git a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/placeholder/PlaceholderReplacer.java b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/placeholder/PlaceholderReplacer.java index 2aa9071c..cb98abd1 100644 --- a/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/placeholder/PlaceholderReplacer.java +++ b/legacy-api/v2/src/main/java/com/gmail/filoghost/holographicdisplays/api/placeholder/PlaceholderReplacer.java @@ -13,5 +13,5 @@ public interface PlaceholderReplacer { @Deprecated String update(); - + } diff --git a/nms/pom.xml b/nms/pom.xml index 0d867d47..51913cc0 100644 --- a/nms/pom.xml +++ b/nms/pom.xml @@ -29,7 +29,7 @@ v1_16_r2 v1_16_r3 - + me.filoghost.fcommons diff --git a/nms/v1_10_r1/pom.xml b/nms/v1_10_r1/pom.xml index f9246ec9..1985136f 100644 --- a/nms/v1_10_r1/pom.xml +++ b/nms/v1_10_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSArmorStand.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSArmorStand.java index 56b90f71..949fc9c5 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSArmorStand.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -60,7 +60,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setCollidable(boolean collidable) {} @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -81,5 +81,5 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + } diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSItem.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSItem.java index 72a36b1a..d6eeda5d 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSItem.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} - + } diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSSlime.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSSlime.java index 9af604c2..5c1e3d68 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSSlime.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/CraftNMSSlime.java @@ -22,14 +22,14 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @@ -64,5 +64,5 @@ public class CraftNMSSlime extends CraftSlime { // Methods from Slime @Override public void setSize(int size) {} - + } diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java index 506714d9..da4a9494 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSArmorStand.java @@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -57,32 +57,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void m() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -94,23 +94,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -120,17 +120,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -152,21 +152,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -180,22 +180,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static String createCustomNameNMSObject(String customName) { return customName != null ? Strings.truncate(customName, 256) : ""; } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public String getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -203,12 +203,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -236,7 +236,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -246,7 +246,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -256,5 +256,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java index b18a809a..8c01c05a 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSItem.java @@ -26,27 +26,27 @@ import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + private int resendMountPacketTicks; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = Integer.MAX_VALUE; } - + @Override public void m() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; - + if (resendMountPacketTicks++ > 20) { resendMountPacketTicks = 0; @@ -57,15 +57,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -73,18 +73,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -96,23 +96,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -122,17 +122,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -151,12 +151,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -165,32 +165,32 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null) { newItem = new ItemStack(Blocks.BEDROCK); } - + if (newItem.getTag() == null) { newItem.setTag(new NBTTagCompound()); } NBTTagCompound display = newItem.getTag().getCompound("display"); - + if (!newItem.getTag().hasKey("display")) { newItem.getTag().set("display", display); } - + NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -210,5 +210,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java index 93f94405..f85c7b02 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityNMSSlime.java @@ -23,17 +23,17 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + private int resendMountPacketTicks; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -41,14 +41,14 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void m() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; - + if (resendMountPacketTicks++ > 20) { resendMountPacketTicks = 0; @@ -59,29 +59,29 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -93,23 +93,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -122,7 +122,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -132,7 +132,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -142,22 +142,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -170,22 +170,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/NullBoundingBox.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/NullBoundingBox.java index 96497c7f..b9d9505a 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/NullBoundingBox.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/NullBoundingBox.java @@ -75,7 +75,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -105,7 +105,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB e(double arg0) { return this; } - + @Override public AxisAlignedBB g(double arg0) { return this; diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSEntityHelper.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSEntityHelper.java index 61079c85..a31ac257 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSEntityHelper.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); @@ -35,7 +35,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper return false; } } - + public void broadcastPacket(Packet packet) { EntityTrackerEntry tracker = getTracker(); if (tracker != null) { diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSManager.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSManager.java index 7910040d..63ddbced 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSManager.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionNMSManager.java @@ -30,14 +30,14 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class VersionNMSManager implements NMSManager { - + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken, String>>() {}, EntityTypes.class, "d"); private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken, Integer>>() {}, EntityTypes.class, "f"); private static final ReflectMethod REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - + private final ProtocolPacketSettings protocolPacketSettings; public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { @@ -50,12 +50,12 @@ public class VersionNMSManager implements NMSManager { registerCustomEntity(EntityNMSItem.class, "Item", 1); registerCustomEntity(EntityNMSSlime.class, "Slime", 55); } - + public void registerCustomEntity(Class entityClass, String name, int id) throws Exception { ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name); ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, id); } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -68,7 +68,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -79,7 +79,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -90,22 +90,22 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); nmsWorld.entityList.add(nmsEntity); - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -113,7 +113,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -122,19 +122,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { diff --git a/nms/v1_11_r1/pom.xml b/nms/v1_11_r1/pom.xml index c1ea2222..769a76b9 100644 --- a/nms/v1_11_r1/pom.xml +++ b/nms/v1_11_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSArmorStand.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSArmorStand.java index 34325f73..3434f5e3 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSArmorStand.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -60,7 +60,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setCollidable(boolean collidable) {} @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -81,5 +81,5 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + } diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSItem.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSItem.java index b9c56ad1..373a49e1 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSItem.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} - + } diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSSlime.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSSlime.java index 3b5d7987..901be493 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSSlime.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/CraftNMSSlime.java @@ -22,14 +22,14 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @@ -64,5 +64,5 @@ public class CraftNMSSlime extends CraftSlime { // Methods from Slime @Override public void setSize(int size) {} - + } diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java index cbed0dfa..49ef2ac5 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSArmorStand.java @@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -57,32 +57,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void A_() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -94,23 +94,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -120,17 +120,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -152,21 +152,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -180,22 +180,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static String createCustomNameNMSObject(String customName) { return customName != null ? Strings.truncate(customName, 256) : ""; } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public String getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -203,12 +203,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -236,7 +236,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -246,7 +246,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -256,5 +256,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java index 31c11903..eec7fc05 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSItem.java @@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } - + @Override public void A_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -108,17 +108,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid newItem = new ItemStack(Blocks.BEDROCK); } @@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -190,10 +190,10 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + @Override public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java index f7e78da2..d3a6a7f9 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityNMSSlime.java @@ -21,15 +21,15 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -37,37 +37,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void A_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -79,23 +79,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -108,7 +108,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -118,7 +118,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -128,22 +128,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -156,22 +156,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -186,5 +186,5 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/NullBoundingBox.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/NullBoundingBox.java index 57c4a180..68cbfafb 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/NullBoundingBox.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/NullBoundingBox.java @@ -60,7 +60,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -90,7 +90,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB e(double arg0) { return this; } - + @Override public AxisAlignedBB g(double arg0) { return this; diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSEntityHelper.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSEntityHelper.java index a4f7436d..0bd3636d 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSEntityHelper.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSManager.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSManager.java index bba4e494..65a797c9 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSManager.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionNMSManager.java @@ -30,7 +30,7 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity; import org.bukkit.inventory.ItemStack; public class VersionNMSManager implements NMSManager { - + private static final ReflectField>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken>>() {}, RegistryMaterials.class, "a"); private static final ReflectField ID_TO_CLASS_MAP_FIELD @@ -43,17 +43,17 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55); } - + public void registerCustomEntity(Class entityClass, int id) throws Exception { // Use reflection to get the RegistryID of entities RegistryID> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b); Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID); - + // Save the the ID -> entity class mapping before the registration Object oldValue = idToClassMap[id]; @@ -63,7 +63,7 @@ public class VersionNMSManager implements NMSManager { // Restore the ID -> entity class mapping idToClassMap[id] = oldValue; } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -76,7 +76,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -87,7 +87,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -98,22 +98,22 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); nmsWorld.entityList.add(nmsEntity); - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -121,7 +121,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -130,19 +130,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { diff --git a/nms/v1_12_r1/pom.xml b/nms/v1_12_r1/pom.xml index aebb05a8..fdcd9bed 100644 --- a/nms/v1_12_r1/pom.xml +++ b/nms/v1_12_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSArmorStand.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSArmorStand.java index 8d09f016..23ae80e5 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSArmorStand.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSArmorStand.java @@ -24,16 +24,16 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } // Methods from ArmorStand class - + @Override public void setArms(boolean arms) {} @Override public void setBasePlate(boolean basePlate) {} @Override public void setBodyPose(EulerAngle pose) {} @@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setCollidable(boolean collidable) {} @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -82,5 +82,5 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + } diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSItem.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSItem.java index e868f8ad..b58aba5e 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSItem.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} - + } diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSSlime.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSSlime.java index e585b088..f83dc414 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSSlime.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/CraftNMSSlime.java @@ -22,14 +22,14 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @@ -64,5 +64,5 @@ public class CraftNMSSlime extends CraftSlime { // Methods from Slime @Override public void setSize(int size) {} - + } diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java index b1703615..46975f35 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSArmorStand.java @@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -57,32 +57,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void B_() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -94,23 +94,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -120,17 +120,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -152,21 +152,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -180,22 +180,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static String createCustomNameNMSObject(String customName) { return customName != null ? Strings.truncate(customName, 256) : ""; } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public String getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -203,12 +203,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -236,7 +236,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -246,7 +246,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -256,5 +256,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java index 2d12341c..bff2348a 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSItem.java @@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } - + @Override public void B_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -108,17 +108,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid newItem = new ItemStack(Blocks.BEDROCK); } @@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -195,5 +195,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java index 7b33822f..f3ded9f4 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityNMSSlime.java @@ -21,15 +21,15 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -37,37 +37,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void B_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -79,23 +79,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -108,7 +108,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -118,7 +118,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -128,12 +128,12 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds @@ -143,7 +143,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -156,22 +156,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/NullBoundingBox.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/NullBoundingBox.java index b504190b..832c0788 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/NullBoundingBox.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/NullBoundingBox.java @@ -60,7 +60,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -90,7 +90,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB e(double arg0) { return this; } - + @Override public AxisAlignedBB g(double arg0) { return this; diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSEntityHelper.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSEntityHelper.java index 6f1c2030..ca8a19b3 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSEntityHelper.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSManager.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSManager.java index db73d721..91e93864 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSManager.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionNMSManager.java @@ -30,7 +30,7 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; import org.bukkit.inventory.ItemStack; public class VersionNMSManager implements NMSManager { - + private static final ReflectField>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken>>() {}, RegistryMaterials.class, "a"); private static final ReflectField ID_TO_CLASS_MAP_FIELD @@ -43,17 +43,17 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55); } - + public void registerCustomEntity(Class entityClass, int id) throws Exception { // Use reflection to get the RegistryID of entities RegistryID> registryID = REGISTRY_ID_FIELD.get(EntityTypes.b); Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID); - + // Save the the ID -> entity class mapping before the registration Object oldValue = idToClassMap[id]; @@ -63,7 +63,7 @@ public class VersionNMSManager implements NMSManager { // Restore the ID -> entity class mapping idToClassMap[id] = oldValue; } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -76,7 +76,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -87,7 +87,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -98,22 +98,22 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); nmsWorld.entityList.add(nmsEntity); - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -121,7 +121,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -130,19 +130,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -154,5 +154,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_13_r1/pom.xml b/nms/v1_13_r1/pom.xml index bcd37eda..2515922f 100644 --- a/nms/v1_13_r1/pom.xml +++ b/nms/v1_13_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSArmorStand.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSArmorStand.java index 861d93d8..04f863f0 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSArmorStand.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSArmorStand.java @@ -24,16 +24,16 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } // Methods from ArmorStand class - + @Override public void setArms(boolean arms) {} @Override public void setBasePlate(boolean basePlate) {} @Override public void setBodyPose(EulerAngle pose) {} @@ -62,7 +62,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } @Override public void setSwimming(boolean swimming) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -83,6 +83,6 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - - + + } diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSItem.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSItem.java index c63265b0..7c33e811 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSItem.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -48,9 +48,9 @@ public class CraftNMSItem extends CraftItem { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} - + } diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSSlime.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSSlime.java index c3cab8c4..74ed2663 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSSlime.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/CraftNMSSlime.java @@ -23,14 +23,14 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @@ -63,10 +63,10 @@ public class CraftNMSSlime extends CraftSlime { @Override public void setMomentum(Vector value) {} @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} - + // Methods from Slime @Override public void setSize(int size) {} @Override public void setTarget(LivingEntity target) {} - + } diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java index ff6c9d41..b367218b 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSArmorStand.java @@ -42,13 +42,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -59,32 +59,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -96,23 +96,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -122,17 +122,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -154,21 +154,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -182,22 +182,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static IChatBaseComponent createCustomNameNMSObject(String customName) { return CraftChatMessage.fromStringOrNull(Strings.truncate(customName, 300)); } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public IChatBaseComponent getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -205,12 +205,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -238,7 +238,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -248,7 +248,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -258,5 +258,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java index 987228b2..8c0b149c 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSItem.java @@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -108,7 +108,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -118,7 +118,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid newItem = new ItemStack(Blocks.BEDROCK); } @@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -195,5 +195,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java index 42e43721..d4fe6670 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/EntityNMSSlime.java @@ -22,15 +22,15 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -38,37 +38,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -80,23 +80,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -109,7 +109,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -119,7 +119,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -129,22 +129,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -157,22 +157,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/NullBoundingBox.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/NullBoundingBox.java index b24f7482..8e14df58 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/NullBoundingBox.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/NullBoundingBox.java @@ -46,7 +46,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -61,7 +61,7 @@ public class NullBoundingBox extends AxisAlignedBB { public boolean b(Vec3D arg0) { return false; } - + @Override public AxisAlignedBB g(double arg0) { return this; diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSEntityHelper.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSEntityHelper.java index 10070e49..5b8ba570 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSEntityHelper.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSManager.java b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSManager.java index dd8f4afa..36875af2 100644 --- a/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSManager.java +++ b/nms/v1_13_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R1/VersionNMSManager.java @@ -33,7 +33,7 @@ import org.bukkit.inventory.ItemStack; import java.util.List; public class VersionNMSManager implements NMSManager { - + private static final ReflectField>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken>>() {}, RegistryMaterials.class, "a"); private static final ReflectField ID_TO_CLASS_MAP_FIELD @@ -48,17 +48,17 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55); } - + public void registerCustomEntity(Class entityClass, int id) throws Exception { // Use reflection to get the RegistryID of entities RegistryID> registryID = REGISTRY_ID_FIELD.get(EntityTypes.REGISTRY); Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID); - + // Save the the ID -> EntityTypes mapping before the registration Object oldValue = idToClassMap[id]; @@ -68,7 +68,7 @@ public class VersionNMSManager implements NMSManager { // Restore the ID -> EntityTypes mapping idToClassMap[id] = oldValue; } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -81,7 +81,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -92,7 +92,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -103,19 +103,19 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); if (NMSCommons.IS_PAPER_SERVER) { try { @@ -129,7 +129,7 @@ public class VersionNMSManager implements NMSManager { } else { nmsWorld.entityList.add(nmsEntity); } - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -137,7 +137,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -146,19 +146,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -170,5 +170,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_13_r2/pom.xml b/nms/v1_13_r2/pom.xml index d8478228..bff5226d 100644 --- a/nms/v1_13_r2/pom.xml +++ b/nms/v1_13_r2/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSArmorStand.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSArmorStand.java index 0bbf65a3..5ff093b7 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSArmorStand.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSArmorStand.java @@ -24,16 +24,16 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } // Methods from ArmorStand class - + @Override public void setArms(boolean arms) {} @Override public void setBasePlate(boolean basePlate) {} @Override public void setBodyPose(EulerAngle pose) {} @@ -62,7 +62,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } @Override public void setSwimming(boolean swimming) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} - - + + } diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSItem.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSItem.java index fd7a62a9..adebba15 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSItem.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -49,9 +49,9 @@ public class CraftNMSItem extends CraftItem { @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} - + } diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSSlime.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSSlime.java index f5360bbe..34b7ff49 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSSlime.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/CraftNMSSlime.java @@ -24,14 +24,14 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @@ -65,7 +65,7 @@ public class CraftNMSSlime extends CraftSlime { @Override public void setSilent(boolean flag) {} @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} - + // Methods from Mob @Override public void setLootTable(LootTable table) {} @Override public void setSeed(long seed) {} @@ -73,5 +73,5 @@ public class CraftNMSSlime extends CraftSlime { // Methods from Slime @Override public void setSize(int size) {} @Override public void setTarget(LivingEntity target) {} - + } diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java index 338b4a91..64d0cc72 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSArmorStand.java @@ -42,13 +42,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -59,32 +59,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -96,23 +96,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -122,17 +122,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -154,21 +154,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -182,22 +182,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static IChatBaseComponent createCustomNameNMSObject(String customName) { return CraftChatMessage.fromStringOrNull(Strings.truncate(customName, 300)); } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public IChatBaseComponent getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -205,12 +205,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -238,7 +238,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -248,7 +248,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -258,5 +258,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java index 15894fad..7d930c97 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSItem.java @@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -108,17 +108,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -137,12 +137,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -151,7 +151,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid newItem = new ItemStack(Blocks.BEDROCK); } @@ -167,15 +167,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -195,5 +195,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java index 1afe46e0..e14006a7 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityNMSSlime.java @@ -22,15 +22,15 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -38,37 +38,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -80,23 +80,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -109,7 +109,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -119,32 +119,32 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -157,22 +157,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/NullBoundingBox.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/NullBoundingBox.java index 796632d1..d22b36dc 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/NullBoundingBox.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/NullBoundingBox.java @@ -46,7 +46,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -61,7 +61,7 @@ public class NullBoundingBox extends AxisAlignedBB { public boolean b(Vec3D arg0) { return false; } - + @Override public AxisAlignedBB g(double arg0) { return this; diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSEntityHelper.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSEntityHelper.java index 72f63ad1..532dfad2 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSEntityHelper.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSManager.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSManager.java index b677e98f..71b2a9a3 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSManager.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionNMSManager.java @@ -34,7 +34,7 @@ import org.bukkit.inventory.ItemStack; import java.util.List; public class VersionNMSManager implements NMSManager { - + private static final ReflectField>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken>>() {}, RegistryMaterials.class, "b"); private static final ReflectField ID_TO_CLASS_MAP_FIELD @@ -49,17 +49,17 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55); } - + public void registerCustomEntity(Class entityClass, int id) throws Exception { // Use reflection to get the RegistryID of entities RegistryID> registryID = REGISTRY_ID_FIELD.get(IRegistry.ENTITY_TYPE); Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID); - + // Save the the ID -> EntityTypes mapping before the registration Object oldValue = idToClassMap[id]; @@ -69,7 +69,7 @@ public class VersionNMSManager implements NMSManager { // Restore the ID -> EntityTypes mapping idToClassMap[id] = oldValue; } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -82,7 +82,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -93,7 +93,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -104,19 +104,19 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.isChunkLoaded(chunkX, chunkZ, true)) { // The boolean "true" is currently unused // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); if (NMSCommons.IS_PAPER_SERVER) { try { @@ -130,7 +130,7 @@ public class VersionNMSManager implements NMSManager { } else { nmsWorld.entityList.add(nmsEntity); } - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -138,7 +138,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -147,19 +147,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -171,5 +171,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_14_r1/pom.xml b/nms/v1_14_r1/pom.xml index 9cb114d0..0300a4c5 100644 --- a/nms/v1_14_r1/pom.xml +++ b/nms/v1_14_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSArmorStand.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSArmorStand.java index c8fce26f..940ab13d 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSArmorStand.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } @Override public void setSwimming(boolean swimming) {} - + // Methods from Entity class @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - - + + } diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSItem.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSItem.java index 1b1b98eb..765b26b4 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSItem.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSItem.java @@ -22,12 +22,12 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Item class @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} @@ -54,5 +54,5 @@ public class CraftNMSItem extends CraftItem { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - + } diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSSlime.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSSlime.java index d1d5b952..d7a02406 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSSlime.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/CraftNMSSlime.java @@ -24,22 +24,22 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Slime class @Override public void setSize(int size) {} @Override public void setTarget(LivingEntity target) {} - + // Methods from Mob class @Override public void setLootTable(LootTable table) {} @Override public void setSeed(long seed) {} - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSArmorStand.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSArmorStand.java index cdb3713e..f2ebfae8 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSArmorStand.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSArmorStand.java @@ -44,13 +44,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final VersionNMSEntityHelper helper; private CraftEntity customBukkitEntity; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(EntityTypes.ARMOR_STAND, world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -61,32 +61,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -98,23 +98,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -124,17 +124,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -156,21 +156,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -184,12 +184,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static IChatBaseComponent createCustomNameNMSObject(String customName) { return CraftChatMessage.fromStringOrNull(Strings.truncate(customName, 300)); } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public IChatBaseComponent getCustomNameObjectNMS() { return super.getCustomName(); @@ -199,7 +199,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (customBukkitEntity == null) { @@ -207,12 +207,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return customBukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -240,7 +240,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -250,7 +250,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -260,5 +260,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java index d6b54cc0..30f164f5 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSItem.java @@ -25,35 +25,35 @@ import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; private CraftEntity customBukkitEntity; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(EntityTypes.ITEM, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void pickup(EntityHuman human) { @@ -61,18 +61,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -84,23 +84,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -110,17 +110,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -139,12 +139,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -153,7 +153,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null || newItem == ItemStack.a) { // ItemStack.a is returned if the stack is not valid newItem = new ItemStack(Blocks.BEDROCK); } @@ -169,15 +169,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -197,5 +197,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java index 78097578..c8cdb923 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityNMSSlime.java @@ -23,16 +23,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; private CraftEntity customBukkitEntity; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(EntityTypes.SLIME, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -40,37 +40,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -111,7 +111,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,7 +121,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -131,22 +131,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (customBukkitEntity == null) { @@ -159,22 +159,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/NullBoundingBox.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/NullBoundingBox.java index f1841fde..72175746 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/NullBoundingBox.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/NullBoundingBox.java @@ -40,7 +40,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -50,7 +50,7 @@ public class NullBoundingBox extends AxisAlignedBB { public boolean a(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5) { return false; } - + @Override public AxisAlignedBB g(double arg0) { return this; @@ -85,7 +85,7 @@ public class NullBoundingBox extends AxisAlignedBB { public double a(EnumAxis arg0) { return 0.0; } - + @Override public double b(EnumAxis arg0) { return 0.0; @@ -105,7 +105,7 @@ public class NullBoundingBox extends AxisAlignedBB { public double c() { return 0.0; } - + @Override public double d() { return 0.0; diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSEntityHelper.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSEntityHelper.java index 7c03369c..683fe54c 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSEntityHelper.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper { public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTracker getTracker0() { return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId()); diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSManager.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSManager.java index 35b23788..ef3d9737 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSManager.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionNMSManager.java @@ -32,7 +32,7 @@ import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; import org.bukkit.inventory.ItemStack; public class VersionNMSManager implements NMSManager { - + private static final ReflectField>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken>>() {}, RegistryMaterials.class, "b"); private static final ReflectField ID_TO_CLASS_MAP_FIELD @@ -45,17 +45,17 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f); } - + public void registerCustomEntity(Class entityClass, int id, float sizeWidth, float sizeHeight) throws Exception { // Use reflection to get the RegistryID of entities RegistryID> registryID = REGISTRY_ID_FIELD.get(IRegistry.ENTITY_TYPE); Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID); - + // Save the the ID -> EntityTypes mapping before the registration Object oldValue = idToClassMap[id]; @@ -65,7 +65,7 @@ public class VersionNMSManager implements NMSManager { // Restore the ID -> EntityTypes mapping idToClassMap[id] = oldValue; } - + @Override public NMSItem spawnNMSItem( World bukkitWorld, double x, double y, double z, @@ -78,7 +78,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( World bukkitWorld, double x, double y, double z, @@ -89,7 +89,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( World world, double x, double y, double z, @@ -100,19 +100,19 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); @@ -121,7 +121,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -130,19 +130,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -154,5 +154,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_15_r1/pom.xml b/nms/v1_15_r1/pom.xml index 37cae0a2..e056877d 100644 --- a/nms/v1_15_r1/pom.xml +++ b/nms/v1_15_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSArmorStand.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSArmorStand.java index a00346a5..8cfd8b08 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSArmorStand.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } @Override public void setSwimming(boolean swimming) {} - + // Methods from Entity class @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - - + + } diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSItem.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSItem.java index 3677d7e1..b2b696c1 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSItem.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSItem.java @@ -22,12 +22,12 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Item class @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} @@ -54,5 +54,5 @@ public class CraftNMSItem extends CraftItem { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - + } diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSSlime.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSSlime.java index 18a0bb36..e1b3676c 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSSlime.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/CraftNMSSlime.java @@ -24,22 +24,22 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Slime class @Override public void setSize(int size) {} @Override public void setTarget(LivingEntity target) {} - + // Methods from Mob class @Override public void setLootTable(LootTable table) {} @Override public void setSeed(long seed) {} - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSArmorStand.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSArmorStand.java index 52ae1546..b04a3105 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSArmorStand.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSArmorStand.java @@ -50,7 +50,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -61,21 +61,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; @@ -165,7 +165,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds @@ -189,7 +189,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public String getCustomNameStringNMS() { return this.customName; } - + @Override public IChatBaseComponent getCustomNameObjectNMS() { return super.getCustomName(); @@ -260,5 +260,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSItem.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSItem.java index c5321986..787e39c2 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSItem.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSItem.java @@ -34,7 +34,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { super(EntityTypes.ITEM, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } @@ -45,11 +45,11 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } @@ -115,7 +115,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying @@ -197,5 +197,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSSlime.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSSlime.java index 93507669..0f4958da 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSSlime.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityNMSSlime.java @@ -23,16 +23,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; private CraftEntity customBukkitEntity; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(EntityTypes.SLIME, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -40,37 +40,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -111,7 +111,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,7 +121,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -131,22 +131,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (customBukkitEntity == null) { @@ -159,22 +159,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/NullBoundingBox.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/NullBoundingBox.java index ae491c88..c8856439 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/NullBoundingBox.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/NullBoundingBox.java @@ -120,5 +120,5 @@ public class NullBoundingBox extends AxisAlignedBB { public Vec3D f() { return Vec3D.a; } - + } diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSEntityHelper.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSEntityHelper.java index 397e3a8e..7df5782d 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSEntityHelper.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper { public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTracker getTracker0() { return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId()); diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSManager.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSManager.java index 0d1e7e5d..706192db 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSManager.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionNMSManager.java @@ -32,7 +32,7 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.inventory.ItemStack; public class VersionNMSManager implements NMSManager { - + private static final ReflectField>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken>>() {}, RegistryMaterials.class, "b"); private static final ReflectField ID_TO_CLASS_MAP_FIELD @@ -45,17 +45,17 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f); } - + public void registerCustomEntity(Class entityClass, int id, float sizeWidth, float sizeHeight) throws Exception { // Use reflection to get the RegistryID of entities RegistryID> registryID = REGISTRY_ID_FIELD.get(IRegistry.ENTITY_TYPE); Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID); - + // Save the the ID -> EntityTypes mapping before the registration Object oldValue = idToClassMap[id]; @@ -65,7 +65,7 @@ public class VersionNMSManager implements NMSManager { // Restore the ID -> EntityTypes mapping idToClassMap[id] = oldValue; } - + @Override public NMSItem spawnNMSItem( World bukkitWorld, double x, double y, double z, @@ -78,7 +78,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( World bukkitWorld, double x, double y, double z, @@ -89,7 +89,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( World world, double x, double y, double z, @@ -100,19 +100,19 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX() / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ() / 16.0); - + if (!nmsWorld.isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); @@ -121,7 +121,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -130,19 +130,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -154,5 +154,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_16_r1/pom.xml b/nms/v1_16_r1/pom.xml index a879f54c..88c2ca4c 100644 --- a/nms/v1_16_r1/pom.xml +++ b/nms/v1_16_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSArmorStand.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSArmorStand.java index bf4b42ae..4b2b8eb3 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSArmorStand.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } @Override public void setSwimming(boolean swimming) {} - + // Methods from Entity class @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - - + + } diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSItem.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSItem.java index 8c6f1b09..7d20041d 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSItem.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSItem.java @@ -22,12 +22,12 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Item class @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} @@ -54,5 +54,5 @@ public class CraftNMSItem extends CraftItem { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - + } diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSSlime.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSSlime.java index 7a007244..7f48e772 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSSlime.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/CraftNMSSlime.java @@ -24,22 +24,22 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Slime class @Override public void setSize(int size) {} @Override public void setTarget(LivingEntity target) {} - + // Methods from Mob class @Override public void setLootTable(LootTable table) {} @Override public void setSeed(long seed) {} - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSArmorStand.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSArmorStand.java index 7f8bfd91..56945590 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSArmorStand.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSArmorStand.java @@ -50,7 +50,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -61,21 +61,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; @@ -165,7 +165,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void playSound(SoundEffect soundeffect, float f, float f1) { // Remove sounds @@ -189,7 +189,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public String getCustomNameStringNMS() { return this.customName; } - + @Override public IChatBaseComponent getCustomNameObjectNMS() { return super.getCustomName(); @@ -260,5 +260,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSItem.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSItem.java index 5a3e4dbc..23b3e3b8 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSItem.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSItem.java @@ -34,7 +34,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { super(EntityTypes.ITEM, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } @@ -45,11 +45,11 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } @@ -115,7 +115,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying @@ -197,5 +197,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSSlime.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSSlime.java index 2b23edf1..db7dbf16 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSSlime.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityNMSSlime.java @@ -23,16 +23,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; private CraftEntity customBukkitEntity; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(EntityTypes.SLIME, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -40,37 +40,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void saveData(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean a_(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void load(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void loadData(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -111,7 +111,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,7 +121,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -131,22 +131,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void playSound(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (customBukkitEntity == null) { @@ -159,22 +159,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/NullBoundingBox.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/NullBoundingBox.java index 67827025..0761918b 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/NullBoundingBox.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/NullBoundingBox.java @@ -120,5 +120,5 @@ public class NullBoundingBox extends AxisAlignedBB { public Vec3D f() { return Vec3D.a; } - + } diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSEntityHelper.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSEntityHelper.java index a35a8164..a9a808e0 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSEntityHelper.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper { public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTracker getTracker0() { return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId()); diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSManager.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSManager.java index 4859329e..a149ed6b 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSManager.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionNMSManager.java @@ -32,7 +32,7 @@ import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity; import org.bukkit.inventory.ItemStack; public class VersionNMSManager implements NMSManager { - + private static final ReflectField>> REGISTRY_ID_FIELD = ReflectField.lookup(new ClassToken>>() {}, RegistryMaterials.class, "b"); private static final ReflectField ID_TO_CLASS_MAP_FIELD @@ -45,17 +45,17 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f); } - + public void registerCustomEntity(Class entityClass, int id, float sizeWidth, float sizeHeight) throws Exception { // Use reflection to get the RegistryID of entities RegistryID> registryID = REGISTRY_ID_FIELD.get(IRegistry.ENTITY_TYPE); Object[] idToClassMap = ID_TO_CLASS_MAP_FIELD.get(registryID); - + // Save the the ID -> EntityTypes mapping before the registration Object oldValue = idToClassMap[id]; @@ -65,7 +65,7 @@ public class VersionNMSManager implements NMSManager { // Restore the ID -> EntityTypes mapping idToClassMap[id] = oldValue; } - + @Override public NMSItem spawnNMSItem( World bukkitWorld, double x, double y, double z, @@ -78,7 +78,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( World bukkitWorld, double x, double y, double z, @@ -89,7 +89,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( World world, double x, double y, double z, @@ -100,19 +100,19 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX() / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ() / 16.0); - + if (!nmsWorld.isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); @@ -121,7 +121,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -130,19 +130,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -154,5 +154,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_16_r2/pom.xml b/nms/v1_16_r2/pom.xml index ccf50bd6..d8854bf3 100644 --- a/nms/v1_16_r2/pom.xml +++ b/nms/v1_16_r2/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSArmorStand.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSArmorStand.java index b044733d..9aaa37b6 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSArmorStand.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } @Override public void setSwimming(boolean swimming) {} - + // Methods from Entity class @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - - + + } diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSItem.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSItem.java index b3c3541e..67eab596 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSItem.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSItem.java @@ -22,12 +22,12 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Item class @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} @@ -54,5 +54,5 @@ public class CraftNMSItem extends CraftItem { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - + } diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSSlime.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSSlime.java index a16bc441..9e47b5cc 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSSlime.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/CraftNMSSlime.java @@ -24,22 +24,22 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Slime class @Override public void setSize(int size) {} @Override public void setTarget(LivingEntity target) {} - + // Methods from Mob class @Override public void setLootTable(LootTable table) {} @Override public void setSeed(long seed) {} - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSArmorStand.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSArmorStand.java index 3ad1784f..a0175f56 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSArmorStand.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSArmorStand.java @@ -50,7 +50,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -61,21 +61,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; @@ -165,7 +165,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void playSound(SoundEffect soundeffect, float f, float f1) { // Remove sounds @@ -184,12 +184,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static IChatBaseComponent createCustomNameNMSObject(String customName) { return CraftChatMessage.fromStringOrNull(Strings.truncate(customName, 300)); } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public IChatBaseComponent getCustomNameObjectNMS() { return super.getCustomName(); @@ -260,5 +260,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSItem.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSItem.java index 55a97693..99681cec 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSItem.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSItem.java @@ -34,7 +34,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { super(EntityTypes.ITEM, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } @@ -45,11 +45,11 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } @@ -115,7 +115,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying @@ -197,5 +197,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSSlime.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSSlime.java index 0823cc6b..1952e4ec 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSSlime.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityNMSSlime.java @@ -23,16 +23,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; private CraftEntity customBukkitEntity; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(EntityTypes.SLIME, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -40,37 +40,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void saveData(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean a_(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void load(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void loadData(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -111,7 +111,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,7 +121,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -131,22 +131,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void playSound(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (customBukkitEntity == null) { @@ -159,22 +159,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/NullBoundingBox.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/NullBoundingBox.java index e19d1660..64b72cfe 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/NullBoundingBox.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/NullBoundingBox.java @@ -120,5 +120,5 @@ public class NullBoundingBox extends AxisAlignedBB { public Vec3D f() { return Vec3D.a; } - + } diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSEntityHelper.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSEntityHelper.java index 22ff7867..de26754d 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSEntityHelper.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper { public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTracker getTracker0() { return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId()); diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSManager.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSManager.java index 4d22541a..719da9da 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSManager.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionNMSManager.java @@ -33,7 +33,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class VersionNMSManager implements NMSManager { - + private static final ReflectField, Integer>> REGISTRY_TO_ID_FIELD = ReflectField.lookup(new ClassToken, Integer>>() {}, RegistryMaterials.class, "bg"); private static final ReflectMethod REGISTER_ENTITY_METHOD @@ -44,19 +44,19 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f); } - + public void registerCustomEntity(Class entityClass, int id, float sizeWidth, float sizeHeight) throws Exception { // Use reflection to map the custom entity to the correct ID Map, Integer> entityTypesToId = REGISTRY_TO_ID_FIELD.get(IRegistry.ENTITY_TYPE); EntityTypes customEntityTypes = EntityTypes.Builder.a(EnumCreatureType.MONSTER).a(sizeWidth, sizeHeight).b().a((String) null); entityTypesToId.put(customEntityTypes, id); } - + @Override public NMSItem spawnNMSItem( World bukkitWorld, double x, double y, double z, @@ -69,7 +69,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( World bukkitWorld, double x, double y, double z, @@ -80,7 +80,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( World world, double x, double y, double z, @@ -91,19 +91,19 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX() / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ() / 16.0); - + if (!nmsWorld.isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); @@ -112,7 +112,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -121,19 +121,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -145,5 +145,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_16_r3/pom.xml b/nms/v1_16_r3/pom.xml index 52b9b756..3d4e7f50 100644 --- a/nms/v1_16_r3/pom.xml +++ b/nms/v1_16_r3/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSArmorStand.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSArmorStand.java index 11961301..e79a066d 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSArmorStand.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -61,7 +61,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setGliding(boolean gliding) {} @Override public boolean setLeashHolder(Entity holder) { return false; } @Override public void setSwimming(boolean swimming) {} - + // Methods from Entity class @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -84,6 +84,6 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - - + + } diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSItem.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSItem.java index d674df2e..bd849c52 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSItem.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSItem.java @@ -22,12 +22,12 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Item class @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} @@ -54,5 +54,5 @@ public class CraftNMSItem extends CraftItem { @Override public void setTicksLived(int value) {} @Override public void setPersistent(boolean flag) {} @Override public void setRotation(float yaw, float pitch) {} - + } diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSSlime.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSSlime.java index cc7a28c6..302f1410 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSSlime.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/CraftNMSSlime.java @@ -24,22 +24,22 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from Slime class @Override public void setSize(int size) {} @Override public void setTarget(LivingEntity target) {} - + // Methods from Mob class @Override public void setLootTable(LootTable table) {} @Override public void setSeed(long seed) {} - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSArmorStand.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSArmorStand.java index 95fe2674..186ad0fa 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSArmorStand.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSArmorStand.java @@ -38,7 +38,7 @@ import java.util.Objects; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - + private final StandardHologramLine parentHologramLine; private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; @@ -50,7 +50,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -61,21 +61,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; @@ -165,7 +165,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void playSound(SoundEffect soundeffect, float f, float f1) { // Remove sounds @@ -189,7 +189,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public String getCustomNameStringNMS() { return this.customName; } - + @Override public IChatBaseComponent getCustomNameObjectNMS() { return super.getCustomName(); @@ -260,5 +260,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSItem.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSItem.java index 38b7cd1a..9af0803e 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSItem.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSItem.java @@ -34,7 +34,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { super(EntityTypes.ITEM, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item } @@ -45,11 +45,11 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } @@ -115,7 +115,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying @@ -197,5 +197,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSSlime.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSSlime.java index de3f2553..7d8ec1f5 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSSlime.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityNMSSlime.java @@ -23,16 +23,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; private CraftEntity customBukkitEntity; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(EntityTypes.SLIME, world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -40,37 +40,37 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void tick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void saveData(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean a_(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,23 +82,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound save(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void load(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void loadData(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -111,7 +111,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,7 +121,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -131,22 +131,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(IChatBaseComponent ichatbasecomponent) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void playSound(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (customBukkitEntity == null) { @@ -159,22 +159,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/NullBoundingBox.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/NullBoundingBox.java index ac635190..ac2763b6 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/NullBoundingBox.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/NullBoundingBox.java @@ -120,5 +120,5 @@ public class NullBoundingBox extends AxisAlignedBB { public Vec3D f() { return Vec3D.ORIGIN; } - + } diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSEntityHelper.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSEntityHelper.java index 9aa608d8..965d208f 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSEntityHelper.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper { public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTracker getTracker0() { return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId()); diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSManager.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSManager.java index 0e8fc59e..72e5d541 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSManager.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionNMSManager.java @@ -33,10 +33,10 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class VersionNMSManager implements NMSManager { - - private static final ReflectField, Integer>> REGISTRY_TO_ID_FIELD + + private static final ReflectField, Integer>> REGISTRY_TO_ID_FIELD = ReflectField.lookup(new ClassToken, Integer>>() {}, RegistryMaterials.class, "bg"); - private static final ReflectMethod REGISTER_ENTITY_METHOD + private static final ReflectMethod REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class); private final ProtocolPacketSettings protocolPacketSettings; @@ -44,19 +44,19 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSSlime.class, 55, 2.04f, 2.04f); } - + public void registerCustomEntity(Class entityClass, int id, float sizeWidth, float sizeHeight) throws Exception { // Use reflection to map the custom entity to the correct ID Map, Integer> entityTypesToId = REGISTRY_TO_ID_FIELD.get(IRegistry.ENTITY_TYPE); EntityTypes customEntityTypes = EntityTypes.Builder.a(EnumCreatureType.MONSTER).a(sizeWidth, sizeHeight).b().a((String) null); entityTypesToId.put(customEntityTypes, id); } - + @Override public NMSItem spawnNMSItem( World bukkitWorld, double x, double y, double z, @@ -69,7 +69,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( World bukkitWorld, double x, double y, double z, @@ -80,7 +80,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( World world, double x, double y, double z, @@ -91,19 +91,19 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX() / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ() / 16.0); - + if (!nmsWorld.isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); @@ -112,7 +112,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -121,19 +121,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -145,5 +145,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_8_r2/pom.xml b/nms/v1_8_r2/pom.xml index 1cb5d5d3..98fd99f5 100644 --- a/nms/v1_8_r2/pom.xml +++ b/nms/v1_8_r2/pom.xml @@ -12,7 +12,7 @@ holographicdisplays-nms-v1_8_r2 HolographicDisplays NMS v1_8_R2 - + ${project.groupId} holographicdisplays-common diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSArmorStand.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSArmorStand.java index a2bb087f..82175272 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSArmorStand.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -55,7 +55,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -70,5 +70,5 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + } diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSItem.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSItem.java index c50e0be8..b213fc3f 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSItem.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -42,7 +42,7 @@ public class CraftNMSItem extends CraftItem { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSSlime.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSSlime.java index 4a5d9d5c..2573d570 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSSlime.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/CraftNMSSlime.java @@ -22,20 +22,20 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -50,7 +50,7 @@ public class CraftNMSSlime extends CraftSlime { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Slime @Override public void setSize(int size) {} } diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java index 1f19bce3..750dbb90 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSArmorStand.java @@ -30,7 +30,7 @@ import org.bukkit.entity.Player; import java.util.Objects; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - + private static final ReflectMethod SET_MARKER_METHOD = ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class); private static final ReflectField PASSENGER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar"); @@ -46,7 +46,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -62,32 +62,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void t_() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -99,13 +99,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - - + + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -115,12 +115,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -142,21 +142,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setEquipment(int i, ItemStack item) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void makeSound(String sound, float f1, float f2) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -170,22 +170,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static String createCustomNameNMSObject(String customName) { return customName != null ? Strings.truncate(customName, 256) : ""; } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public String getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -193,12 +193,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -213,7 +213,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta Entity passengerEntity = (Entity) passenger; Preconditions.checkArgument(passengerEntity.vehicle == null); Preconditions.checkState(super.passenger == null); - + try { PASSENGER_PITCH_DELTA.set(passengerEntity, 0.0); PASSENGER_YAW_DELTA.set(passengerEntity, 0.0); @@ -229,7 +229,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return this.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -239,7 +239,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java index 2bc905b8..8bfa188e 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSItem.java @@ -24,7 +24,7 @@ import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; @@ -32,26 +32,26 @@ public class EntityNMSItem extends EntityItem implements NMSItem { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = Integer.MAX_VALUE; } - + @Override public void t_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,12 +82,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -102,7 +102,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -121,12 +121,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return this.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -135,32 +135,32 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null) { newItem = new ItemStack(Blocks.BEDROCK); } - + if (newItem.getTag() == null) { newItem.setTag(new NBTTagCompound()); } NBTTagCompound display = newItem.getTag().getCompound("display"); - + if (!newItem.getTag().hasKey("display")) { newItem.getTag().set("display", display); } - + NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -175,10 +175,10 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + @Override public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java index 10a2de1a..610d8d0c 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/EntityNMSSlime.java @@ -20,15 +20,15 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.noclip = true; super.a(0.0F, 0.0F); @@ -36,11 +36,11 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void t_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; @@ -49,29 +49,29 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { killEntityNMS(); } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -83,7 +83,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -101,7 +101,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -116,22 +116,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void makeSound(String sound, float volume, float pitch) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -144,22 +144,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -174,5 +174,5 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/NullBoundingBox.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/NullBoundingBox.java index ef2864e2..9acc25e9 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/NullBoundingBox.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/NullBoundingBox.java @@ -74,5 +74,5 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0, double arg1, double arg2) { return this; } - + } diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSEntityHelper.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSEntityHelper.java index 6056152e..f23afa40 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSEntityHelper.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSManager.java b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSManager.java index 6ee3b7a0..a0ab5dab 100644 --- a/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSManager.java +++ b/nms/v1_8_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R2/VersionNMSManager.java @@ -31,7 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class VersionNMSManager implements NMSManager { - + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken, String>>() {}, EntityTypes.class, "d"); private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD @@ -44,19 +44,19 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30); registerCustomEntity(EntityNMSItem.class, "Item", 1); registerCustomEntity(EntityNMSSlime.class, "Slime", 55); } - + public void registerCustomEntity(Class entityClass, String name, int id) throws Exception { ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name); ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, id); } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -69,7 +69,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -80,7 +80,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -91,10 +91,10 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + if (!REGISTER_ENTITY_METHOD.isValid()) { boolean added = nmsWorld.addEntity(nmsEntity, SpawnReason.CUSTOM); if (!added) { @@ -102,19 +102,19 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.ADD_ENTITY_FAILED); } } - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.chunkProviderServer.isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); nmsWorld.entityList.add(nmsEntity); - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -122,7 +122,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -131,19 +131,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.a(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -155,5 +155,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_8_r3/pom.xml b/nms/v1_8_r3/pom.xml index 424172cd..d8f45a4d 100644 --- a/nms/v1_8_r3/pom.xml +++ b/nms/v1_8_r3/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSArmorStand.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSArmorStand.java index 7dfe6f92..82c8597f 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSArmorStand.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -55,7 +55,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -70,5 +70,5 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + } diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSItem.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSItem.java index 14ea237d..1bd5a9bf 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSItem.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -42,7 +42,7 @@ public class CraftNMSItem extends CraftItem { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSSlime.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSSlime.java index 865cf28b..52f89e15 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSSlime.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/CraftNMSSlime.java @@ -22,20 +22,20 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -50,7 +50,7 @@ public class CraftNMSSlime extends CraftSlime { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Slime @Override public void setSize(int size) {} } diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java index 54344ac3..0b098a13 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java @@ -30,7 +30,7 @@ import org.bukkit.entity.Player; import java.util.Objects; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - + private static final ReflectMethod SET_MARKER_METHOD = ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class); private static final ReflectField PASSENGER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar"); @@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -62,32 +62,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void t_() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -99,13 +99,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - - + + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -115,12 +115,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -142,21 +142,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setEquipment(int i, ItemStack item) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void makeSound(String sound, float f1, float f2) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -170,22 +170,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static String createCustomNameNMSObject(String customName) { return customName != null ? Strings.truncate(customName, 256) : ""; } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public String getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -193,12 +193,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -229,7 +229,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return this.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -239,7 +239,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -249,5 +249,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java index 6ab4cc2f..b6f41bf3 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSItem.java @@ -24,34 +24,34 @@ import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = Integer.MAX_VALUE; } - + @Override public void t_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -59,18 +59,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -82,12 +82,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -97,12 +97,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -121,12 +121,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return this.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -135,32 +135,32 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null) { newItem = new ItemStack(Blocks.BEDROCK); } - + if (newItem.getTag() == null) { newItem.setTag(new NBTTagCompound()); } NBTTagCompound display = newItem.getTag().getCompound("display"); - + if (!newItem.getTag().hasKey("display")) { newItem.getTag().set("display", display); } - + NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -175,10 +175,10 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + @Override public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java index 0e5fe2d5..82f767e4 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSSlime.java @@ -20,15 +20,15 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.noclip = true; super.a(0.0F, 0.0F); @@ -36,11 +36,11 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void t_() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; @@ -49,29 +49,29 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { killEntityNMS(); } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -83,12 +83,12 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -101,7 +101,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -116,22 +116,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void makeSound(String sound, float volume, float pitch) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -144,22 +144,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -174,5 +174,5 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/NullBoundingBox.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/NullBoundingBox.java index 7bd55def..e524a5b4 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/NullBoundingBox.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/NullBoundingBox.java @@ -74,5 +74,5 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0, double arg1, double arg2) { return this; } - + } diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSEntityHelper.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSEntityHelper.java index a5f189c0..9e8c13e8 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSEntityHelper.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSManager.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSManager.java index 62e2e45f..3c0fa6fc 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSManager.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionNMSManager.java @@ -31,7 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class VersionNMSManager implements NMSManager { - + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken, String>>() {}, EntityTypes.class, "d"); private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD @@ -44,14 +44,14 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30); registerCustomEntity(EntityNMSItem.class, "Item", 1); registerCustomEntity(EntityNMSSlime.class, "Slime", 55); } - + public void registerCustomEntity(Class entityClass, String name, int id) throws Exception { ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name); ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, id); @@ -91,10 +91,10 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + if (!REGISTER_ENTITY_METHOD.isValid()) { boolean added = nmsWorld.addEntity(nmsEntity, SpawnReason.CUSTOM); if (!added) { @@ -102,19 +102,19 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.ADD_ENTITY_FAILED); } } - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.chunkProviderServer.isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); nmsWorld.entityList.add(nmsEntity); - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -122,7 +122,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -131,19 +131,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.a(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { diff --git a/nms/v1_9_r1/pom.xml b/nms/v1_9_r1/pom.xml index ca155ec9..b62c2767 100644 --- a/nms/v1_9_r1/pom.xml +++ b/nms/v1_9_r1/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSArmorStand.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSArmorStand.java index c3fac4b6..fd35074d 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSArmorStand.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -56,7 +56,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -71,5 +71,5 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + } diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSItem.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSItem.java index e0c576a7..491695fa 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSItem.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -42,9 +42,9 @@ public class CraftNMSItem extends CraftItem { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} - + } diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSSlime.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSSlime.java index 21297a21..0f10252d 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSSlime.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/CraftNMSSlime.java @@ -22,20 +22,20 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -50,8 +50,8 @@ public class CraftNMSSlime extends CraftSlime { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Slime @Override public void setSize(int size) {} - + } diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java index adb62eb6..17bfa3c7 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSArmorStand.java @@ -33,7 +33,7 @@ import org.bukkit.entity.Player; import java.util.Objects; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - + private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "as"); private final StandardHologramLine parentHologramLine; @@ -41,13 +41,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -58,32 +58,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void m() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -95,23 +95,23 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - - + + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,17 +121,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -153,21 +153,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -181,22 +181,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static String createCustomNameNMSObject(String customName) { return customName != null ? Strings.truncate(customName, 256) : ""; } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public String getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -204,12 +204,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -237,7 +237,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -247,7 +247,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -257,5 +257,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java index 556a5bd4..97c0f843 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSItem.java @@ -26,27 +26,27 @@ import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + private int resendMountPacketTicks; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = Integer.MAX_VALUE; } - + @Override public void m() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; - + if (resendMountPacketTicks++ > 20) { resendMountPacketTicks = 0; @@ -57,15 +57,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -73,18 +73,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -96,22 +96,22 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,17 +121,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -150,12 +150,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -164,32 +164,32 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null) { newItem = new ItemStack(Blocks.BEDROCK); } - + if (newItem.getTag() == null) { newItem.setTag(new NBTTagCompound()); } NBTTagCompound display = newItem.getTag().getCompound("display"); - + if (!newItem.getTag().hasKey("display")) { newItem.getTag().set("display", display); } - + NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -209,5 +209,5 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java index 7fbe4eaf..3bf4a83d 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/EntityNMSSlime.java @@ -26,14 +26,14 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + private int resendMountPacketTicks; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -41,14 +41,14 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void m() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; - + if (resendMountPacketTicks++ > 20) { resendMountPacketTicks = 0; @@ -59,29 +59,29 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -93,22 +93,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public void e(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -121,7 +121,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -131,7 +131,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -141,22 +141,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -169,22 +169,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -199,5 +199,5 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/NullBoundingBox.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/NullBoundingBox.java index d314844d..90110ead 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/NullBoundingBox.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/NullBoundingBox.java @@ -75,7 +75,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -105,7 +105,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB e(double arg0) { return this; } - + @Override public AxisAlignedBB g(double arg0) { return this; diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSEntityHelper.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSEntityHelper.java index db92ec43..7e6050f5 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSEntityHelper.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSManager.java b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSManager.java index 7908ca4b..a5139bb6 100644 --- a/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSManager.java +++ b/nms/v1_9_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R1/VersionNMSManager.java @@ -30,10 +30,10 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class VersionNMSManager implements NMSManager { - - private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD + + private static final ReflectField, String>> ENTITY_NAMES_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken, String>>() {}, EntityTypes.class, "d"); - private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD + private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken, Integer>>() {}, EntityTypes.class, "f"); private static final ReflectMethod REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); @@ -43,19 +43,19 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30); registerCustomEntity(EntityNMSItem.class, "Item", 1); registerCustomEntity(EntityNMSSlime.class, "Slime", 55); } - + public void registerCustomEntity(Class entityClass, String name, int id) throws Exception { ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name); ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, id); } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -68,7 +68,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -79,7 +79,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -90,22 +90,22 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.getChunkProviderServer().isChunkLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); nmsWorld.entityList.add(nmsEntity); - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -113,7 +113,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -122,19 +122,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -146,5 +146,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/nms/v1_9_r2/pom.xml b/nms/v1_9_r2/pom.xml index 4321c042..24d6e8ae 100644 --- a/nms/v1_9_r2/pom.xml +++ b/nms/v1_9_r2/pom.xml @@ -17,7 +17,7 @@ ${project.groupId} holographicdisplays-common - + org.spigotmc spigot diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSArmorStand.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSArmorStand.java index 89cab1ec..63b34dba 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSArmorStand.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSArmorStand.java @@ -24,9 +24,9 @@ public class CraftNMSArmorStand extends CraftArmorStand { public CraftNMSArmorStand(CraftServer server, EntityNMSArmorStand entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -56,7 +56,7 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -71,5 +71,5 @@ public class CraftNMSArmorStand extends CraftArmorStand { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + } diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSItem.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSItem.java index fba2e8d3..fc78fc37 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSItem.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSItem.java @@ -22,7 +22,7 @@ public class CraftNMSItem extends CraftItem { } // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override @@ -42,9 +42,9 @@ public class CraftNMSItem extends CraftItem { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Item @Override public void setItemStack(ItemStack stack) {} @Override public void setPickupDelay(int delay) {} - + } diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSSlime.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSSlime.java index 260e67bb..7cc4ca43 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSSlime.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/CraftNMSSlime.java @@ -22,20 +22,20 @@ public class CraftNMSSlime extends CraftSlime { public CraftNMSSlime(CraftServer server, EntityNMSSlime entity) { super(server, entity); } - + // Disallow all the bukkit methods - + @Override public void remove() { // Cannot be removed, this is the most important to override } - + // Methods from LivingEntity class @Override public boolean addPotionEffect(PotionEffect effect) { return false; } @Override public boolean addPotionEffect(PotionEffect effect, boolean param) { return false; } @Override public boolean addPotionEffects(Collection effects) { return false; } @Override public void setRemoveWhenFarAway(boolean remove) {} - + // Methods from Entity @Override public void setVelocity(Vector vel) {} @Override public boolean teleport(Location loc) { return false; } @@ -50,8 +50,8 @@ public class CraftNMSSlime extends CraftSlime { @Override public void setCustomName(String name) {} @Override public void setCustomNameVisible(boolean flag) {} @Override public void setLastDamageCause(EntityDamageEvent event) {} - + // Methods from Slime @Override public void setSize(int size) {} - + } diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java index defcb943..07acd261 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSArmorStand.java @@ -40,13 +40,13 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private final ProtocolPacketSettings protocolPacketSettings; private final VersionNMSEntityHelper helper; private String customName; - + public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) { super(world); this.parentHologramLine = parentHologramLine; this.protocolPacketSettings = protocolPacketSettings; this.helper = new VersionNMSEntityHelper(this); - + super.setInvisible(true); super.setSmall(true); super.setArms(false); @@ -57,32 +57,32 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta super.onGround = true; // Workaround to force EntityTrackerEntry to send a teleport packet forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void m() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity if (super.onGround) { super.onGround = false; } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -94,24 +94,24 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - - + + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -121,17 +121,17 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility @@ -153,21 +153,21 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { // Prevent armor stand from being equipped } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void setCustomNameNMS(String customName) { if (Objects.equals(this.customName, customName)) { @@ -181,22 +181,22 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta protected static String createCustomNameNMSObject(String customName) { return customName != null ? Strings.truncate(customName, 256) : ""; } - + @Override public String getCustomNameStringNMS() { return this.customName; } - + @Override public Object getCustomNameObjectNMS() { return super.getCustomName(); } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -204,12 +204,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } return super.bukkitEntity; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -237,7 +237,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isDeadNMS() { return super.dead; } - + @Override public int getIdNMS() { return super.getId(); @@ -247,7 +247,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public StandardHologramLine getHologramLine() { return parentHologramLine; } - + @Override public org.bukkit.entity.Entity getBukkitEntityNMS() { return getBukkitEntity(); @@ -257,5 +257,5 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java index 19e44365..2032ec0e 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSItem.java @@ -26,27 +26,27 @@ import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { - + private final StandardItemLine parentHologramLine; private final VersionNMSEntityHelper helper; - + private int resendMountPacketTicks; - + public EntityNMSItem(World world, StandardItemLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.pickupDelay = Integer.MAX_VALUE; } - + @Override public void m() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; - + if (resendMountPacketTicks++ > 20) { resendMountPacketTicks = 0; @@ -57,15 +57,15 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + // Method called when a player is near @Override public void d(EntityHuman human) { @@ -73,18 +73,18 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Too low or too high, it's a bit weird return; } - + if (human instanceof EntityPlayer) { parentHologramLine.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory } } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -96,23 +96,23 @@ public class EntityNMSItem extends EntityItem implements NMSItem { // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -122,17 +122,17 @@ public class EntityNMSItem extends EntityItem implements NMSItem { */ return true; } - + @Override public boolean isCollidable() { return false; } - + @Override public void die() { // Prevent entity from dying } - + @Override public boolean isAlive() { // This override prevents items from being picked up by hoppers (should have no side effects) @@ -151,12 +151,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); @@ -165,32 +165,32 @@ public class EntityNMSItem extends EntityItem implements NMSItem { @Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); - + if (newItem == null) { newItem = new ItemStack(Blocks.BEDROCK); } - + if (newItem.getTag() == null) { newItem.setTag(new NBTTagCompound()); } NBTTagCompound display = newItem.getTag().getCompound("display"); - + if (!newItem.getTag().hasKey("display")) { newItem.getTag().set("display", display); } - + NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(NMSCommons.ANTI_STACK_LORE)); display.set("Lore", tagList); - + super.setItemStack(newItem); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -205,10 +205,10 @@ public class EntityNMSItem extends EntityItem implements NMSItem { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + @Override public Object getRawItemStack() { return super.getItemStack(); } - + } diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java index 82ca7fa7..729c263c 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityNMSSlime.java @@ -23,17 +23,17 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEntityEvent; public class EntityNMSSlime extends EntitySlime implements NMSSlime { - + private final StandardHologramLine parentHologramLine; private final VersionNMSEntityHelper helper; - + private int resendMountPacketTicks; - + public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) { super(world); this.parentHologramLine = parentHologramLine; this.helper = new VersionNMSEntityHelper(this); - + super.persistent = true; super.collides = false; super.a(0.0F, 0.0F); @@ -41,14 +41,14 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { super.setInvisible(true); forceSetBoundingBox(new NullBoundingBox()); } - + @Override public void m() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; - + if (resendMountPacketTicks++ > 20) { resendMountPacketTicks = 0; @@ -59,29 +59,29 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } } } - + @Override public void inactiveTick() { // Disable normal ticking for this entity - + // So it won't get removed ticksLived = 0; } - + @Override public void a(AxisAlignedBB boundingBox) { // Prevent changes to bounding box } - + public void forceSetBoundingBox(AxisAlignedBB boundingBox) { super.a(boundingBox); } - + @Override public void b(NBTTagCompound nbttagcompound) { // Do not save NBT } - + @Override public boolean c(NBTTagCompound nbttagcompound) { // Do not save NBT @@ -93,23 +93,23 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { // Do not save NBT return false; } - + @Override public NBTTagCompound e(NBTTagCompound nbttagcompound) { // Do not save NBT return nbttagcompound; } - + @Override public void f(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public void a(NBTTagCompound nbttagcompound) { // Do not load NBT } - + @Override public boolean damageEntity(DamageSource damageSource, float amount) { if (damageSource instanceof EntityDamageSource) { @@ -122,7 +122,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } return false; } - + @Override public boolean isInvulnerable(DamageSource source) { /* @@ -132,7 +132,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { */ return true; } - + @Override public boolean isCollidable() { return false; @@ -142,22 +142,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public void setCustomName(String customName) { // Prevents changes to custom name } - + @Override public void setCustomNameVisible(boolean visible) { // Prevents changes to custom name visibility } - + @Override public void a(SoundEffect soundeffect, float f, float f1) { // Remove sounds } - + @Override public void die() { // Prevent entity from dying } - + @Override public CraftEntity getBukkitEntity() { if (super.bukkitEntity == null) { @@ -170,22 +170,22 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isDeadNMS() { return super.dead; } - + @Override public void killEntityNMS() { super.dead = true; } - + @Override public void setLocationNMS(double x, double y, double z) { super.setPosition(x, y, z); } - + @Override public int getIdNMS() { return super.getId(); } - + @Override public StandardHologramLine getHologramLine() { return parentHologramLine; @@ -200,5 +200,5 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { public boolean isTrackedBy(Player bukkitPlayer) { return helper.isTrackedBy(bukkitPlayer); } - + } diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/NullBoundingBox.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/NullBoundingBox.java index ff3e857d..b61ac006 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/NullBoundingBox.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/NullBoundingBox.java @@ -75,7 +75,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB shrink(double arg0) { return this; } - + @Override public AxisAlignedBB a(BlockPosition arg0) { return this; @@ -105,7 +105,7 @@ public class NullBoundingBox extends AxisAlignedBB { public AxisAlignedBB e(double arg0) { return this; } - + @Override public AxisAlignedBB g(double arg0) { return this; diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSEntityHelper.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSEntityHelper.java index 2ef439b5..6d412a7c 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSEntityHelper.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSEntityHelper.java @@ -20,7 +20,7 @@ public class VersionNMSEntityHelper extends NMSEntityHelper public VersionNMSEntityHelper(Entity entity) { this.entity = entity; } - + @Override protected EntityTrackerEntry getTracker0() { return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId()); diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSManager.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSManager.java index bb0f7c89..637e3767 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSManager.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionNMSManager.java @@ -35,7 +35,7 @@ public class VersionNMSManager implements NMSManager { = ReflectField.lookup(new ClassToken, String>>() {}, EntityTypes.class, "d"); private static final ReflectField, Integer>> ENTITY_IDS_BY_CLASS_FIELD = ReflectField.lookup(new ClassToken, Integer>>() {}, EntityTypes.class, "f"); - + private static final ReflectMethod REGISTER_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); private final ProtocolPacketSettings protocolPacketSettings; @@ -43,19 +43,19 @@ public class VersionNMSManager implements NMSManager { public VersionNMSManager(ProtocolPacketSettings protocolPacketSettings) { this.protocolPacketSettings = protocolPacketSettings; } - + @Override public void setup() throws Exception { registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30); registerCustomEntity(EntityNMSItem.class, "Item", 1); registerCustomEntity(EntityNMSSlime.class, "Slime", 55); } - + public void registerCustomEntity(Class entityClass, String name, int id) throws Exception { ENTITY_NAMES_BY_CLASS_FIELD.getStatic().put(entityClass, name); ENTITY_IDS_BY_CLASS_FIELD.getStatic().put(entityClass, id); } - + @Override public NMSItem spawnNMSItem( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -68,7 +68,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, item); return item; } - + @Override public EntityNMSSlime spawnNMSSlime( org.bukkit.World bukkitWorld, double x, double y, double z, @@ -79,7 +79,7 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, slime); return slime; } - + @Override public NMSArmorStand spawnNMSArmorStand( org.bukkit.World world, double x, double y, double z, @@ -90,22 +90,22 @@ public class VersionNMSManager implements NMSManager { addEntityToWorld(nmsWorld, armorStand); return armorStand; } - + private void addEntityToWorld(WorldServer nmsWorld, Entity nmsEntity) throws SpawnFailedException { Preconditions.checkState(Bukkit.isPrimaryThread(), "Async entity add"); - + final int chunkX = MathHelper.floor(nmsEntity.locX / 16.0); final int chunkZ = MathHelper.floor(nmsEntity.locZ / 16.0); - + if (!nmsWorld.getChunkProviderServer().isLoaded(chunkX, chunkZ)) { // This should never happen nmsEntity.dead = true; throw new SpawnFailedException(SpawnFailedException.CHUNK_NOT_LOADED); } - + nmsWorld.getChunkAt(chunkX, chunkZ).a(nmsEntity); nmsWorld.entityList.add(nmsEntity); - + try { REGISTER_ENTITY_METHOD.invoke(nmsWorld, nmsEntity); } catch (ReflectiveOperationException e) { @@ -113,7 +113,7 @@ public class VersionNMSManager implements NMSManager { throw new SpawnFailedException(SpawnFailedException.REGISTER_ENTITY_FAIL, e); } } - + @Override public boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { return ((CraftEntity) bukkitEntity).getHandle() instanceof NMSEntity; @@ -122,19 +122,19 @@ public class VersionNMSManager implements NMSManager { @Override public NMSEntity getNMSEntityBase(org.bukkit.entity.Entity bukkitEntity) { Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle(); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { return null; } } - + @Override public NMSEntity getNMSEntityBaseFromID(org.bukkit.World bukkitWorld, int entityID) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); Entity nmsEntity = nmsWorld.getEntity(entityID); - + if (nmsEntity instanceof NMSEntity) { return (NMSEntity) nmsEntity; } else { @@ -146,5 +146,5 @@ public class VersionNMSManager implements NMSManager { public Object createCustomNameNMSObject(String customName) { return EntityNMSArmorStand.createCustomNameNMSObject(customName); } - + } diff --git a/plugin/pom.xml b/plugin/pom.xml index 8e237bed..c83a3fa8 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -33,52 +33,52 @@ ${project.groupId} holographicdisplays-legacy-api-v2 - + ${project.groupId} holographicdisplays-nms-v1_8_r2 - + ${project.groupId} holographicdisplays-nms-v1_8_r3 - + ${project.groupId} holographicdisplays-nms-v1_9_r1 - + ${project.groupId} holographicdisplays-nms-v1_9_r2 - + ${project.groupId} holographicdisplays-nms-v1_10_r1 - + ${project.groupId} holographicdisplays-nms-v1_11_r1 - + ${project.groupId} holographicdisplays-nms-v1_12_r1 - + ${project.groupId} holographicdisplays-nms-v1_13_r1 - + ${project.groupId} holographicdisplays-nms-v1_13_r2 - + ${project.groupId} holographicdisplays-nms-v1_14_r1 @@ -123,12 +123,12 @@ org.bstats bstats-bukkit-lite - + me.filoghost.updatechecker updatechecker - + me.filoghost.fcommons fcommons @@ -149,7 +149,7 @@ - + org.codehaus.mojo @@ -185,7 +185,7 @@ - + org.apache.maven.plugins maven-jar-plugin @@ -200,7 +200,7 @@ - + org.apache.maven.plugins maven-shade-plugin diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/Colors.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/Colors.java index cfac4c65..957113cf 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/Colors.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/Colors.java @@ -8,15 +8,15 @@ package me.filoghost.holographicdisplays.plugin; import org.bukkit.ChatColor; public class Colors { - + public static final String PRIMARY = "" + ChatColor.AQUA; public static final String PRIMARY_SHADOW = "" + ChatColor.DARK_AQUA; - + public static final String SECONDARY = "" + ChatColor.WHITE; public static final String SECONDARY_SHADOW = "" + ChatColor.GRAY; - + public static final String BOLD = "" + ChatColor.BOLD; - + public static final String ERROR = "" + ChatColor.RED; - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/HolographicDisplays.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/HolographicDisplays.java index 6f1b8a4b..98549599 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/HolographicDisplays.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/HolographicDisplays.java @@ -48,7 +48,7 @@ import java.io.IOException; import java.util.concurrent.TimeUnit; public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacketSettings { - + private static HolographicDisplays instance; private ConfigManager configManager; @@ -63,11 +63,11 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke // Warn about plugin reloaders and the /reload command if (instance != null || System.getProperty("HolographicDisplaysLoaded") != null) { Bukkit.getConsoleSender().sendMessage( - ChatColor.RED + "[HolographicDisplays] Please do not use /reload or plugin reloaders." - + " Use the command \"/holograms reload\" instead." + ChatColor.RED + "[HolographicDisplays] Please do not use /reload or plugin reloaders." + + " Use the command \"/holograms reload\" instead." + " You will receive no support for doing this operation."); } - + System.setProperty("HolographicDisplaysLoaded", "true"); instance = this; @@ -89,7 +89,7 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke "Holographic Displays was unable to register the command \"holograms\".", "This can be caused by edits to plugin.yml or other plugins."); } - + NMSManager nmsManager; try { nmsManager = NMSVersion.createNMSManager(this); @@ -97,7 +97,7 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke } catch (Exception e) { throw new PluginEnableException(e, "Couldn't initialize the NMS manager."); } - + configManager = new ConfigManager(getDataFolder().toPath()); bungeeServerTracker = new BungeeServerTracker(this); animationRegistry = new AnimationRegistry(); @@ -124,16 +124,16 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke TickingTask tickingTask = new TickingTask(tickClock, placeholderLineTracker); Bukkit.getScheduler().scheduleSyncRepeatingTask(this, tickingTask, 0, 1); - + HologramCommandManager commandManager = new HologramCommandManager(configManager, internalHologramManager, nmsManager); commandManager.register(this); - + registerListener(new InteractListener(nmsManager)); registerListener(new SpawnListener(nmsManager)); registerListener(new ChunkListener(nmsManager, internalHologramManager, apiHologramManager)); UpdateNotificationListener updateNotificationListener = new UpdateNotificationListener(); registerListener(updateNotificationListener); - + // Enable the APIs HolographicDisplaysAPIProvider.setImplementation( new DefaultHolographicDisplaysAPIProvider(apiHologramManager, nmsManager, placeholderRegistry)); @@ -142,7 +142,7 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke // Register bStats metrics int pluginID = 3123; new MetricsLite(this, pluginID); - + updateNotificationListener.runAsyncUpdateCheck(); if (errorCollector.hasErrors()) { @@ -161,7 +161,7 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke public void load(boolean deferHologramsCreation, ErrorCollector errorCollector) { DefaultPlaceholders.resetAndRegister(placeholderRegistry, animationRegistry, bungeeServerTracker); - + internalHologramManager.clearAll(); configManager.reloadStaticReplacements(errorCollector); @@ -172,9 +172,9 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke } catch (IOException | ConfigException e) { errorCollector.add(e, "failed to load animation files"); } - + bungeeServerTracker.restart(Configuration.bungeeRefreshSeconds, TimeUnit.SECONDS); - + if (deferHologramsCreation) { // For the initial load: holograms are loaded later, when the worlds are ready Bukkit.getScheduler().runTask(this, () -> hologramDatabase.createHolograms(internalHologramManager, errorCollector)); @@ -200,7 +200,7 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke public static HolographicDisplays getInstance() { return instance; } - + @Override public boolean sendAccurateLocationPackets() { return ProtocolLibHook.isEnabled(); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java index e14079ee..78490283 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java @@ -35,10 +35,10 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI { Preconditions.notNull(source, "source"); Preconditions.notNull(source.getWorld(), "source's world"); Preconditions.checkState(Bukkit.isPrimaryThread(), "Async hologram creation"); - + return apiHologramManager.createHologram(source, plugin); } - + @Override public void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull PlaceholderReplacer replacer) { Preconditions.notEmpty(identifier, "identifier"); @@ -47,10 +47,10 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI { } Preconditions.checkArgument(refreshIntervalTicks >= 0, "refreshIntervalTicks should be positive"); Preconditions.notNull(replacer, "replacer"); - + placeholderRegistry.registerGlobalPlaceholderReplacer(plugin, identifier, refreshIntervalTicks, replacer); } - + private boolean isValidIdentifierCharacter(char c) { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') @@ -62,7 +62,7 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI { @Override public boolean isRegisteredPlaceholder(@NotNull String identifier) { Preconditions.notNull(identifier, "identifier"); - + return placeholderRegistry.isRegisteredIdentifier(plugin, identifier); } @@ -79,7 +79,7 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI { @Override public void unregisterPlaceholder(@NotNull String identifier) { Preconditions.notNull(identifier, "identifier"); - + placeholderRegistry.unregister(plugin, identifier); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPIProvider.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPIProvider.java index 74f40792..1ce0540f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPIProvider.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPIProvider.java @@ -22,7 +22,7 @@ public class DefaultHolographicDisplaysAPIProvider extends HolographicDisplaysAP private final APIHologramManager apiHologramManager; private final NMSManager nmsManager; private final PlaceholderRegistry placeholderRegistry; - + // Optimization: avoid creating a new instance every time a plugin requires it, in case it never stores a reference private final Map apiInstanceCache; @@ -39,7 +39,7 @@ public class DefaultHolographicDisplaysAPIProvider extends HolographicDisplaysAP @Override public HolographicDisplaysAPI getHolographicDisplaysAPI(Plugin plugin) { Preconditions.notNull(plugin, "plugin"); - + return apiInstanceCache.computeIfAbsent(plugin, pluginKey -> new DefaultHolographicDisplaysAPI(pluginKey, apiHologramManager, placeholderRegistry)); } @@ -47,7 +47,7 @@ public class DefaultHolographicDisplaysAPIProvider extends HolographicDisplaysAP @Override public boolean isHologramEntity(Entity entity) { Preconditions.notNull(entity, "entity"); - + return nmsManager.isNMSEntityBase(entity); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramsAPIProvider.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramsAPIProvider.java index 578d51e9..9f9b4d0f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramsAPIProvider.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramsAPIProvider.java @@ -45,7 +45,7 @@ public class V2HologramsAPIProvider extends HologramsAPIProvider { return apiHologramManager.createHologram(source, plugin).getV2Adapter(); } - + @Override public Collection getHolograms(Plugin plugin) { Preconditions.notNull(plugin, "plugin"); @@ -59,17 +59,17 @@ public class V2HologramsAPIProvider extends HologramsAPIProvider { return Collections.unmodifiableList(ownedHolograms); } - + @Override public boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer) { Preconditions.notNull(plugin, "plugin"); Preconditions.notNull(textPlaceholder, "textPlaceholder"); Preconditions.checkArgument(refreshRate >= 0, "refreshRate should be positive"); Preconditions.notNull(replacer, "replacer"); - + int refreshIntervalTicks = Math.min((int) (refreshRate * 20.0), 1); boolean alreadyRegistered = placeholderRegistry.isRegisteredIdentifier(plugin, textPlaceholder); - + if (!alreadyRegistered) { placeholderRegistry.registerGlobalPlaceholderReplacer( plugin, @@ -81,21 +81,21 @@ public class V2HologramsAPIProvider extends HologramsAPIProvider { return false; } } - + @Override public Collection getRegisteredPlaceholders(Plugin plugin) { Preconditions.notNull(plugin, "plugin"); - + return placeholderRegistry.getRegisteredIdentifiers(plugin); } - + @Override public boolean unregisterPlaceholder(Plugin plugin, String textPlaceholder) { Preconditions.notNull(plugin, "plugin"); Preconditions.notNull(textPlaceholder, "textPlaceholder"); - + boolean registered = placeholderRegistry.isRegisteredIdentifier(plugin, textPlaceholder); - + if (registered) { placeholderRegistry.unregister(plugin, textPlaceholder); return true; @@ -103,14 +103,14 @@ public class V2HologramsAPIProvider extends HologramsAPIProvider { return false; } } - + @Override public void unregisterPlaceholders(Plugin plugin) { Preconditions.notNull(plugin, "plugin"); - + placeholderRegistry.unregisterAll(plugin); } - + @Override public boolean isHologramEntity(Entity bukkitEntity) { Preconditions.notNull(bukkitEntity, "bukkitEntity"); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java index 34e87f9c..de04c311 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java @@ -52,7 +52,7 @@ abstract class V2TouchableLineAdapter extends V2HologramLineAdapter implements T // Lazy initialization if (v2TouchHandler == null) { me.filoghost.holographicdisplays.api.handler.TouchHandler newTouchHandler = newTouchableLine.getTouchHandler(); - + if (newTouchHandler == null) { // Keep it null } else if (newTouchHandler instanceof NewTouchHandlerAdapter) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeMessenger.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeMessenger.java index 7bd14846..d89077d1 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeMessenger.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeMessenger.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.util.Collection; public class BungeeMessenger implements PluginMessageListener { - + private static final String BUNGEECORD_CHANNEL = "BungeeCord"; private static final String REDISBUNGEE_CHANNEL = "legacy:redisbungee"; @@ -31,25 +31,25 @@ public class BungeeMessenger implements PluginMessageListener { this.plugin = plugin; this.playerCountCallback = playerCountCallback; } - + public static BungeeMessenger registerNew(Plugin plugin, PlayerCountCallback playerCountCallback) { BungeeMessenger bungeeMessenger = new BungeeMessenger(plugin, playerCountCallback); - + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, BUNGEECORD_CHANNEL); Bukkit.getMessenger().registerIncomingPluginChannel(plugin, BUNGEECORD_CHANNEL, bungeeMessenger); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, REDISBUNGEE_CHANNEL); Bukkit.getMessenger().registerIncomingPluginChannel(plugin, REDISBUNGEE_CHANNEL, bungeeMessenger); - + return bungeeMessenger; } - + @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { if (Configuration.pingerEnabled || !channel.equals(getTargetChannel())) { return; } - + DataInputStream in = new DataInputStream(new ByteArrayInputStream(message)); try { @@ -57,7 +57,7 @@ public class BungeeMessenger implements PluginMessageListener { if (!subChannel.equals("PlayerCount")) { return; } - + String server = in.readUTF(); int online = in.readInt(); playerCountCallback.onReceive(server, online); @@ -76,7 +76,7 @@ public class BungeeMessenger implements PluginMessageListener { } catch (IOException e) { Log.warning("Error while encoding player count message for server \"" + server + "\".", e); } - + // Send the message through a random player (BungeeCord will not forward it to them) Collection players = Bukkit.getOnlinePlayers(); if (players.size() > 0) { @@ -92,12 +92,12 @@ public class BungeeMessenger implements PluginMessageListener { return BUNGEECORD_CHANNEL; } } - - + + public interface PlayerCountCallback { - + void onReceive(String serverName, int playerCount); - + } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeServerTracker.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeServerTracker.java index e577ff73..d4a4b33a 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeServerTracker.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/BungeeServerTracker.java @@ -29,7 +29,7 @@ public class BungeeServerTracker { private final ConcurrentMap trackedServers; private final BungeeMessenger bungeeMessenger; - + private int taskID = -1; public BungeeServerTracker(Plugin plugin) { @@ -39,12 +39,12 @@ public class BungeeServerTracker { public void restart(int updateInterval, TimeUnit timeUnit) { trackedServers.clear(); - + if (taskID != -1) { Bukkit.getScheduler().cancelTask(taskID); } - taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(HolographicDisplays.getInstance(), + taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(HolographicDisplays.getInstance(), this::runPeriodicUpdateTask, 1, timeUnit.toSeconds(updateInterval) * 20L); } @@ -103,13 +103,13 @@ public class BungeeServerTracker { } catch (IOException e) { Log.warning("Couldn't fetch data from " + serverAddress + ".", e); } - + return ServerInfo.offline(Configuration.pingerOfflineMotd); } private void removeUnusedServers() { long now = System.currentTimeMillis(); - + trackedServers.values().removeIf(trackedServer -> { if (now - trackedServer.lastRequest > UNTRACK_AFTER_TIME_WITHOUT_REQUESTS) { DebugLogger.info("Untracked unused server \"" + trackedServer.serverName + "\"."); @@ -130,7 +130,7 @@ public class BungeeServerTracker { this.serverName = serverName; this.serverInfo = ServerInfo.offline(Configuration.pingerOfflineMotd); } - + private void updateLastRequest() { this.lastRequest = System.currentTimeMillis(); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/ServerInfo.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/ServerInfo.java index 6a5bb2b9..082fadb1 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/ServerInfo.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/ServerInfo.java @@ -9,7 +9,7 @@ import me.filoghost.fcommons.Strings; import me.filoghost.holographicdisplays.plugin.disk.Configuration; public class ServerInfo { - + private final boolean online; private final int onlinePlayers; private final int maxPlayers; @@ -27,7 +27,7 @@ public class ServerInfo { this.online = online; this.onlinePlayers = onlinePlayers; this.maxPlayers = maxPlayers; - + if (Strings.isEmpty(motd)) { motdLine1 = ""; motdLine2 = ""; @@ -54,7 +54,7 @@ public class ServerInfo { public int getOnlinePlayers() { return onlinePlayers; } - + public int getMaxPlayers() { return maxPlayers; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/PingResponse.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/PingResponse.java index a465e7f5..8aa009bd 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/PingResponse.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/PingResponse.java @@ -11,7 +11,7 @@ import org.json.simple.JSONObject; import org.json.simple.JSONValue; public class PingResponse { - + private final String motd; private final int onlinePlayers; private final int maxPlayers; @@ -30,7 +30,7 @@ public class PingResponse { } JSONObject json = (JSONObject) jsonObject; - + Object descriptionObject = json.get("description"); String motd; @@ -41,7 +41,7 @@ public class PingResponse { logInvalidResponse(jsonString, address); return errorResponse("Invalid ping response (description not found)"); } - + if (descriptionObject instanceof JSONObject) { Object text = ((JSONObject) descriptionObject).get("text"); if (text == null) { @@ -68,7 +68,7 @@ public class PingResponse { maxPlayers = ((Number) maxObject).intValue(); } } - + return new PingResponse(motd, onlinePlayers, maxPlayers); } @@ -85,7 +85,7 @@ public class PingResponse { this.onlinePlayers = onlinePlayers; this.maxPlayers = maxPlayers; } - + public String getMotd() { return motd; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/ServerPinger.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/ServerPinger.java index b3d25c02..2c74adb8 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/ServerPinger.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/bungeecord/pinger/ServerPinger.java @@ -21,7 +21,7 @@ public class ServerPinger { socket.setSoTimeout(timeout); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); DataInputStream in = new DataInputStream(socket.getInputStream()); - + // Handshake packet ByteArrayOutputStream handshakeBytes = new ByteArrayOutputStream(); DataOutputStream handshakeOut = new DataOutputStream(handshakeBytes); @@ -31,15 +31,15 @@ public class ServerPinger { handshakeOut.writeShort(serverAddress.getPort()); writeVarInt(handshakeOut, 1); // Next state: status request writeByteArray(out, handshakeBytes.toByteArray()); - + // Status request packet writeByteArray(out, new byte[]{0x00}); // Packet ID - + // Response packet readVarInt(in); // Packet size readVarInt(in); // Packet ID String responseJson = readString(in); - + return PingResponse.fromJson(responseJson, serverAddress); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/placeholderapi/PlaceholderAPIHook.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/placeholderapi/PlaceholderAPIHook.java index dbcb5f90..871bebb6 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/placeholderapi/PlaceholderAPIHook.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/placeholderapi/PlaceholderAPIHook.java @@ -10,21 +10,21 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; public class PlaceholderAPIHook { - + private static boolean enabled; public static void setup() { if (!Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) { return; } - + enabled = true; } public static boolean containsPlaceholders(String text) { return PlaceholderAPI.containsPlaceholders(text); } - + public static String replacePlaceholders(Player player, String text) { return PlaceholderAPI.setPlaceholders(player, text); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/DebugHelper.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/DebugHelper.java index 096ee5bc..87d533d8 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/DebugHelper.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/DebugHelper.java @@ -17,21 +17,21 @@ import com.comphenix.protocol.wrappers.BukkitConverters; import java.util.Map; class DebugHelper { - + private static final int HEX_DUMP_THRESHOLD = 256; - + public static void printInformation(PacketEvent event) { String verb = event.isServerPacket() ? "Sent" : "Received"; - String format = event.isServerPacket() - ? "%s %s to %s" + String format = event.isServerPacket() + ? "%s %s to %s" : "%s %s from %s"; - + String shortDescription = String.format(format, event.isCancelled() ? "Cancelled" : verb, event.getPacketType(), event.getPlayer().getName() ); - + // Detailed will print the packet's content too try { System.out.println(shortDescription + ":\n" + getPacketDescription(event.getPacket())); @@ -40,23 +40,23 @@ class DebugHelper { System.out.println("Unable to use reflection."); } } - - + + private static String getPacketDescription(PacketContainer packetContainer) throws IllegalAccessException { Object packet = packetContainer.getHandle(); Class clazz = packet.getClass(); - + // Get the first Minecraft super class - while (clazz != null - && clazz != Object.class + while (clazz != null + && clazz != Object.class && (!MinecraftReflection.isMinecraftClass(clazz) || Factory.class.isAssignableFrom(clazz))) { clazz = clazz.getSuperclass(); } - + return PrettyPrinter.printObject( - packet, - clazz, - MinecraftReflection.getPacketClass(), + packet, + clazz, + MinecraftReflection.getPacketClass(), PrettyPrinter.RECURSE_DEPTH, (StringBuilder output, Object value) -> { // Special case @@ -80,14 +80,14 @@ class DebugHelper { return false; }); } - - + + private static EquivalentConverter findConverter(Class clazz) { Map, EquivalentConverter> converters = BukkitConverters.getConvertersForGeneric(); - + while (clazz != null) { EquivalentConverter result = converters.get(clazz); - + if (result != null) { return result; } else { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/MetadataHelper.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/MetadataHelper.java index 85c7f286..7ede1ec1 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/MetadataHelper.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/MetadataHelper.java @@ -17,7 +17,7 @@ import java.util.List; import java.util.Optional; class MetadataHelper { - + private final int itemSlotIndex; private final int entityStatusIndex; private final int airLevelIndex; @@ -47,20 +47,20 @@ class MetadataHelper { } else { itemSlotIndex = 10; } - + if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_15_R1)) { armorStandStatusIndex = 14; } else { armorStandStatusIndex = 11; } - + entityStatusIndex = 0; airLevelIndex = 1; customNameIndex = 2; customNameVisibleIndex = 3; noGravityIndex = 5; slimeSizeIndex = 15; - + if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) { itemSerializer = Registry.get(MinecraftReflection.getItemStackClass()); intSerializer = Registry.get(Integer.class); @@ -68,7 +68,7 @@ class MetadataHelper { stringSerializer = Registry.get(String.class); booleanSerializer = Registry.get(Boolean.class); } - + if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_13_R1)) { customNameUsesChatComponents = true; chatComponentSerializer = Registry.get(MinecraftReflection.getIChatBaseComponentClass(), true); @@ -76,53 +76,53 @@ class MetadataHelper { customNameUsesChatComponents = false; } } - - + + public void setEntityStatus(WrappedDataWatcher dataWatcher, byte statusBitmask) { requireMinimumVersion(NMSVersion.v1_9_R1); dataWatcher.setObject(new WrappedDataWatcherObject(entityStatusIndex, byteSerializer), statusBitmask); } - + public WrappedWatchableObject getCustomNameWatchableObject(WrappedDataWatcher metadata) { return metadata.getWatchableObject(customNameIndex); } - - + + public WrappedWatchableObject getCustomNameWatchableObject(List dataWatcherValues) { for (WrappedWatchableObject watchableObject : dataWatcherValues) { if (watchableObject.getIndex() == customNameIndex) { return watchableObject; } } - + return null; } - - + + public Object getCustomNameNMSObject(WrappedWatchableObject customNameWatchableObject) { Object customNameNMSObject = customNameWatchableObject.getRawValue(); if (customNameNMSObject == null) { return null; } - + if (customNameUsesChatComponents) { if (!(customNameNMSObject instanceof Optional)) { throw new IllegalArgumentException("Expected custom name of type " + Optional.class); } - + return ((Optional) customNameNMSObject).orElse(null); - + } else { if (!(customNameNMSObject instanceof String)) { throw new IllegalArgumentException("Expected custom name of type " + String.class); } - + return customNameNMSObject; } } - - + + public void setCustomNameNMSObject(WrappedWatchableObject customNameWatchableObject, Object customNameNMSObject) { if (customNameUsesChatComponents) { customNameWatchableObject.setValue(Optional.ofNullable(customNameNMSObject)); @@ -131,17 +131,17 @@ class MetadataHelper { } } - + public void setCustomNameNMSObject(WrappedDataWatcher dataWatcher, Object customNameNMSObject) { requireMinimumVersion(NMSVersion.v1_9_R1); - + if (customNameUsesChatComponents) { dataWatcher.setObject( - new WrappedDataWatcherObject(customNameIndex, chatComponentSerializer), + new WrappedDataWatcherObject(customNameIndex, chatComponentSerializer), Optional.ofNullable(customNameNMSObject)); } else { dataWatcher.setObject( - new WrappedDataWatcherObject(customNameIndex, stringSerializer), + new WrappedDataWatcherObject(customNameIndex, stringSerializer), customNameNMSObject); } } @@ -168,11 +168,11 @@ class MetadataHelper { if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) { if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_11_R1)) { dataWatcher.setObject( - new WrappedDataWatcherObject(itemSlotIndex, itemSerializer), + new WrappedDataWatcherObject(itemSlotIndex, itemSerializer), nmsItemStack); } else { dataWatcher.setObject( - new WrappedDataWatcherObject(itemSlotIndex, itemSerializer), + new WrappedDataWatcherObject(itemSlotIndex, itemSerializer), com.google.common.base.Optional.of(nmsItemStack)); } dataWatcher.setObject(new WrappedDataWatcherObject(airLevelIndex, intSerializer), 300); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketListener.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketListener.java index e171b620..3e8486cb 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketListener.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketListener.java @@ -29,7 +29,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; class PacketListener extends PacketAdapter { - + private final NMSManager nmsManager; private final MetadataHelper metadataHelper; private final ProtocolPacketSettings packetSettings; @@ -67,7 +67,7 @@ class PacketListener extends PacketAdapter { if (event.isPlayerTemporary()) { return; } - + PacketContainer packet = event.getPacket(); PacketType packetType = packet.getType(); Player player = event.getPlayer(); @@ -90,7 +90,7 @@ class PacketListener extends PacketAdapter { } StandardHologramLine hologramLine = nmsEntity.getHologramLine(); - + if (!hologramLine.getHologram().isVisibleTo(player)) { event.setCancelled(true); return; @@ -100,27 +100,27 @@ class PacketListener extends PacketAdapter { // There's no metadata field in 1.15+ on the spawn entity packet, ignore it return; } - + if (packetType == PacketType.Play.Server.SPAWN_ENTITY_LIVING || packetType == PacketType.Play.Server.ENTITY_METADATA) { if (!(hologramLine instanceof StandardTextLine) || !(nmsEntity instanceof NMSArmorStand)) { return; } - + StandardTextLine textLine = (StandardTextLine) hologramLine; - + if (!textLine.isAllowPlaceholders()) { return; } NMSArmorStand nmsArmorStand = (NMSArmorStand) nmsEntity; String customName = nmsArmorStand.getCustomNameStringNMS(); - + if (customName == null || customName.isEmpty()) { return; } - + String customNameWithIndividualPlaceholders = replaceIndividualPlaceholders(textLine, customName, player); - + if (customNameWithIndividualPlaceholders.equals(customName)) { return; // No need to modify packets, custom name doesn't need changes } @@ -137,7 +137,7 @@ class PacketListener extends PacketAdapter { packetWrapper = spawnEntityPacket; customNameWatchableObject = metadataHelper.getCustomNameWatchableObject(spawnEntityPacket.getMetadata()); } - + if (customNameWatchableObject == null) { return; } @@ -153,7 +153,7 @@ class PacketListener extends PacketAdapter { if (trackedLine == null) { return text; } - + text = trackedLine.replaceIndividualPlaceholders(player); if (PlaceholderAPIHook.isEnabled() && PlaceholderAPIHook.containsPlaceholders(text)) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketSender.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketSender.java index 3181f63b..9a36c028 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketSender.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/PacketSender.java @@ -30,9 +30,9 @@ import java.util.ArrayList; import java.util.List; class PacketSender { - + private final MetadataHelper metadataHelper; - + PacketSender(MetadataHelper metadataHelper) { this.metadataHelper = metadataHelper; } @@ -85,7 +85,7 @@ class PacketSender { StandardTouchableLine touchableLine = (StandardTouchableLine) line; NMSArmorStand slimeVehicle = touchableLine.getNMSSlimeVehicle(); NMSSlime slime = touchableLine.getNMSSlime(); - + if (slimeVehicle != null && slimeVehicle.isTrackedBy(player)) { sendSpawnArmorStandPacket(player, slimeVehicle); } @@ -95,7 +95,7 @@ class PacketSender { sendVehicleAttachPacket(player, slimeVehicle, slime); } } - + private void sendSpawnArmorStandPacket(Player receiver, NMSArmorStand armorStand) { if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_11_R1)) { AbstractPacket spawnPacket; @@ -103,14 +103,14 @@ class PacketSender { spawnPacket = new WrapperPlayServerSpawnEntityLiving(armorStand.getBukkitEntityNMS()); } else { spawnPacket = new WrapperPlayServerSpawnEntity( - armorStand.getBukkitEntityNMS(), + armorStand.getBukkitEntityNMS(), WrapperPlayServerSpawnEntity.ObjectTypes.ARMOR_STAND, 1); } spawnPacket.sendPacket(receiver); - + WrapperPlayServerEntityMetadata dataPacket = new WrapperPlayServerEntityMetadata(); WrappedDataWatcher dataWatcher = new WrappedDataWatcher(); - + metadataHelper.setEntityStatus(dataWatcher, (byte) 0x20); // Invisible String customName = armorStand.getCustomNameStringNMS(); @@ -118,57 +118,57 @@ class PacketSender { metadataHelper.setCustomNameNMSObject(dataWatcher, armorStand.getCustomNameObjectNMS()); metadataHelper.setCustomNameVisible(dataWatcher, true); } - + metadataHelper.setNoGravity(dataWatcher, true); metadataHelper.setArmorStandStatus(dataWatcher, (byte) (0x01 | 0x08 | 0x10)); // Small, no base plate, marker - + dataPacket.setEntityMetadata(dataWatcher.getWatchableObjects()); dataPacket.setEntityID(armorStand.getIdNMS()); dataPacket.sendPacket(receiver); - + } else { WrapperPlayServerSpawnEntityLiving spawnPacket = new WrapperPlayServerSpawnEntityLiving(armorStand.getBukkitEntityNMS()); spawnPacket.sendPacket(receiver); } } - - + + private void sendSpawnItemPacket(Player receiver, NMSItem item) { AbstractPacket packet = new WrapperPlayServerSpawnEntity(item.getBukkitEntityNMS(), ObjectTypes.ITEM_STACK, 1); packet.sendPacket(receiver); } - - + + private void sendSpawnSlimePacket(Player receiver, NMSSlime slime) { AbstractPacket spawnPacket = new WrapperPlayServerSpawnEntityLiving(slime.getBukkitEntityNMS()); spawnPacket.sendPacket(receiver); - + if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_15_R1)) { WrapperPlayServerEntityMetadata dataPacket = new WrapperPlayServerEntityMetadata(); WrappedDataWatcher dataWatcher = new WrappedDataWatcher(); - + metadataHelper.setEntityStatus(dataWatcher, (byte) 0x20); // Invisible metadataHelper.setSlimeSize(dataWatcher, 1); // Size 1 = small - + dataPacket.setEntityMetadata(dataWatcher.getWatchableObjects()); dataPacket.setEntityID(slime.getIdNMS()); dataPacket.sendPacket(receiver); } } - - + + private void sendItemMetadataPacket(Player receiver, NMSItem item) { WrapperPlayServerEntityMetadata packet = new WrapperPlayServerEntityMetadata(); - + WrappedDataWatcher dataWatcher = new WrappedDataWatcher(); metadataHelper.setItemMetadata(dataWatcher, item.getRawItemStack()); packet.setEntityMetadata(dataWatcher.getWatchableObjects()); - + packet.setEntityID(item.getIdNMS()); packet.sendPacket(receiver); } - - + + private void sendVehicleAttachPacket(Player receiver, NMSEntity vehicle, NMSEntity passenger) { if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_9_R1)) { WrapperPlayServerMount packet = new WrapperPlayServerMount(); @@ -182,13 +182,13 @@ class PacketSender { packet.sendPacket(receiver); } } - - + + private void sendDestroyEntitiesPacket(Player player, List ids) { WrapperPlayServerEntityDestroy packet = new WrapperPlayServerEntityDestroy(); packet.setEntities(ids); packet.sendPacket(player); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/ProtocolLibHook.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/ProtocolLibHook.java index 16ca6c2b..69925015 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/ProtocolLibHook.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/bridge/protocollib/ProtocolLibHook.java @@ -67,13 +67,13 @@ public class ProtocolLibHook { errorCollector.add(e, "failed to load ProtocolLib support, is it updated?"); return; } - + enabled = true; } public static void sendDestroyEntitiesPacket(Player player, StandardHologram hologram) { checkState(); - + if (shouldReceivePacket(player, hologram)) { packetSender.sendDestroyEntitiesPacket(player, hologram); } @@ -91,7 +91,7 @@ public class ProtocolLibHook { if (!player.isOnline()) { return false; } - + if (!player.getWorld().equals(hologram.getWorld())) { return false; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java index 20fbb40c..3eb5e3b9 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandManager.java @@ -99,7 +99,7 @@ public class HologramCommandManager extends SubCommandManager { } } } - + return null; } @@ -117,7 +117,7 @@ public class HologramCommandManager extends SubCommandManager { if (!(subCommand instanceof QuickEditCommand)) { continue; } - + QuickEditCommand quickEditCommand = (QuickEditCommand) subCommand; // Assume first argument is always "" and remove it @@ -149,7 +149,7 @@ public class HologramCommandManager extends SubCommandManager { protected void sendNoArgsMessage(CommandContext context) { CommandSender sender = context.getSender(); String version = HolographicDisplays.getInstance().getDescription().getVersion(); - sender.sendMessage(Colors.PRIMARY_SHADOW + "Server is running " + Colors.PRIMARY + "Holographic Displays " + sender.sendMessage(Colors.PRIMARY_SHADOW + "Server is running " + Colors.PRIMARY + "Holographic Displays " + Colors.PRIMARY_SHADOW + "v" + version + " by " + Colors.PRIMARY + "filoghost"); if (helpCommand.hasPermission(sender)) { sender.sendMessage(Colors.PRIMARY_SHADOW + "Commands: " + Colors.PRIMARY + helpCommand.getFullUsageText(context)); @@ -163,13 +163,13 @@ public class HologramCommandManager extends SubCommandManager { @Override protected void sendUnknownSubCommandMessage(SubCommandContext context) { - context.getSender().sendMessage(Colors.ERROR + "Unknown sub-command." + context.getSender().sendMessage(Colors.ERROR + "Unknown sub-command." + " Type \"" + helpCommand.getFullUsageText(context) + "\" for a list of commands."); } @Override protected void sendSubCommandUsage(SubCommandContext context) { - context.getSender().sendMessage(Colors.ERROR + "Usage: /" + context.getRootLabel() + " " + context.getSender().sendMessage(Colors.ERROR + "Usage: /" + context.getRootLabel() + " " + context.getSubLabel() + " " + context.getSubCommand().getUsageArgs()); } @@ -181,8 +181,8 @@ public class HologramCommandManager extends SubCommandManager { @Override protected void handleUnexpectedException(CommandContext context, Throwable t) { Bukkit.getLogger().log(Level.SEVERE, "Unhandled exception while executing /" + context.getRootLabel(), t); - context.getSender().sendMessage(Colors.ERROR + "Internal error while executing command." + context.getSender().sendMessage(Colors.ERROR + "Internal error while executing command." + " Please look on the console for more details."); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandValidate.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandValidate.java index 8a0a2391..a43922d1 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandValidate.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramCommandValidate.java @@ -19,7 +19,7 @@ import java.nio.file.Files; import java.nio.file.Path; public class HologramCommandValidate { - + public static InternalHologramLine parseHologramLine(InternalHologram hologram, String serializedLine) throws CommandException { try { return HologramLineParser.parseLine(hologram, serializedLine); @@ -28,7 +28,7 @@ public class HologramCommandValidate { } } - public static InternalHologram getInternalHologram(InternalHologramManager internalHologramManager, String hologramName) + public static InternalHologram getInternalHologram(InternalHologramManager internalHologramManager, String hologramName) throws CommandException { InternalHologram hologram = internalHologramManager.getHologramByName(hologramName); CommandValidate.notNull(hologram, "Cannot find a hologram named \"" + hologramName + "\"."); @@ -37,9 +37,9 @@ public class HologramCommandValidate { public static Path getUserReadableFile(Path dataFolder, String fileName) throws CommandException { Path targetFile = dataFolder.resolve(fileName); - CommandValidate.check(FileUtils.isInsideDirectory(targetFile, dataFolder), + CommandValidate.check(FileUtils.isInsideDirectory(targetFile, dataFolder), "The specified file must be inside HolographicDisplays' folder."); - CommandValidate.check(Files.exists(targetFile), + CommandValidate.check(Files.exists(targetFile), "The specified file \"" + fileName + "\" does not exist inside HolographicDisplays' folder."); CommandValidate.check(!Files.isDirectory(targetFile), "The file cannot be a folder."); CommandValidate.check(!isConfigFile(targetFile), "Cannot read YML configuration files."); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java index cadeb5d9..0130bba6 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/HologramSubCommand.java @@ -21,7 +21,7 @@ public abstract class HologramSubCommand implements SubCommand { private String usageArgs; private int minArgs; - + private List description; private boolean showInHelpCommand; @@ -29,7 +29,7 @@ public abstract class HologramSubCommand implements SubCommand { this.name = name; this.aliases = aliases != null ? Arrays.asList(aliases) : Collections.emptyList(); this.permission = Permissions.COMMAND_BASE + name.toLowerCase(); - + this.showInHelpCommand = true; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/Messages.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/Messages.java index a89c625b..40c6f684 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/Messages.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/Messages.java @@ -10,19 +10,19 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; public class Messages { - + public static void sendTitle(CommandSender recipient, String title) { - recipient.sendMessage("" + Colors.PRIMARY_SHADOW + ChatColor.BOLD + "----- " + recipient.sendMessage("" + Colors.PRIMARY_SHADOW + ChatColor.BOLD + "----- " + title + Colors.PRIMARY_SHADOW + ChatColor.BOLD + " -----"); } - + public static void sendTip(CommandSender recipient, String tip) { recipient.sendMessage("" + ChatColor.YELLOW + ChatColor.BOLD + "TIP:" + Colors.SECONDARY_SHADOW + " " + tip); } - + public static void sendWarning(CommandSender recipient, String warning) { - recipient.sendMessage(ChatColor.RED + "( " + ChatColor.DARK_RED + ChatColor.BOLD + "!" + ChatColor.RED + " ) " + recipient.sendMessage(ChatColor.RED + "( " + ChatColor.DARK_RED + ChatColor.BOLD + "!" + ChatColor.RED + " ) " + Colors.SECONDARY_SHADOW + warning); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddlineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddlineCommand.java index 78b058d7..283c31fe 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddlineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AddlineCommand.java @@ -43,13 +43,13 @@ public class AddlineCommand extends LineEditingCommand implements QuickEditComma public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); String serializedLine = Strings.joinFrom(" ", args, 1); - + InternalHologramLine line = HologramCommandValidate.parseHologramLine(hologram, serializedLine); hologram.addLine(line); configManager.saveHologramDatabase(internalHologramManager); Bukkit.getPluginManager().callEvent(new InternalHologramEditEvent(hologram)); - + sender.sendMessage(Colors.PRIMARY + "Line added."); commandManager.sendQuickEditCommands(context, hologram); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AlignCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AlignCommand.java index 6abcc2a3..8415e3d6 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AlignCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/AlignCommand.java @@ -36,7 +36,7 @@ public class AlignCommand extends HologramSubCommand { public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[1]); InternalHologram referenceHologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[2]); - + CommandValidate.check(hologram != referenceHologram, "The holograms must not be the same."); Location loc = hologram.getLocation(); @@ -56,11 +56,11 @@ public class AlignCommand extends HologramSubCommand { } hologram.teleport(loc); - + configManager.saveHologramDatabase(internalHologramManager); - sender.sendMessage(Colors.PRIMARY + "Hologram \"" + hologram.getName() + "\"" - + " aligned to the hologram \"" + referenceHologram.getName() + "\"" + sender.sendMessage(Colors.PRIMARY + "Hologram \"" + hologram.getName() + "\"" + + " aligned to the hologram \"" + referenceHologram.getName() + "\"" + " on the " + axis.toUpperCase() + " axis."); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CopyCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CopyCommand.java index 17dc4460..3353c65a 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CopyCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CopyCommand.java @@ -23,7 +23,7 @@ public class CopyCommand extends HologramSubCommand { private final InternalHologramManager internalHologramManager; private final ConfigManager configManager; - + public CopyCommand(InternalHologramManager internalHologramManager, ConfigManager configManager) { super("copy"); setMinArgs(2); @@ -33,7 +33,7 @@ public class CopyCommand extends HologramSubCommand { this.internalHologramManager = internalHologramManager; this.configManager = configManager; } - + @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram fromHologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); @@ -43,12 +43,12 @@ public class CopyCommand extends HologramSubCommand { for (InternalHologramLine line : fromHologram.getLines()) { clonedLines.add(HologramCommandValidate.parseHologramLine(toHologram, line.getSerializedConfigValue())); } - + toHologram.setLines(clonedLines); - + configManager.saveHologramDatabase(internalHologramManager); - - sender.sendMessage(Colors.PRIMARY + "Hologram \"" + fromHologram.getName() + "\"" + + sender.sendMessage(Colors.PRIMARY + "Hologram \"" + fromHologram.getName() + "\"" + " copied into hologram \"" + toHologram.getName() + "\"."); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java index 776e2e1d..3d21f730 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/CreateCommand.java @@ -46,9 +46,9 @@ public class CreateCommand extends HologramSubCommand { Player player = CommandValidate.getPlayerSender(sender); String hologramName = args[0]; - CommandValidate.check(hologramName.matches("[a-zA-Z0-9_\\-]+"), + CommandValidate.check(hologramName.matches("[a-zA-Z0-9_\\-]+"), "The name must contain only alphanumeric chars, underscores and hyphens."); - CommandValidate.check(!internalHologramManager.isExistingHologram(hologramName), + CommandValidate.check(!internalHologramManager.isExistingHologram(hologramName), "A hologram with that name already exists."); Location spawnLoc = player.getLocation(); @@ -57,25 +57,25 @@ public class CreateCommand extends HologramSubCommand { if (moveUp) { spawnLoc.add(0.0, 1.2, 0.0); } - + InternalHologram hologram = internalHologramManager.createHologram(spawnLoc, hologramName); InternalHologramLine line; if (args.length > 1) { String text = Strings.joinFrom(" ", args, 1); CommandValidate.check(!text.equalsIgnoreCase("{empty}"), "The first line should not be empty."); - + line = HologramCommandValidate.parseHologramLine(hologram, text); - player.sendMessage(Colors.SECONDARY_SHADOW + "(Change the lines with /" + context.getRootLabel() + player.sendMessage(Colors.SECONDARY_SHADOW + "(Change the lines with /" + context.getRootLabel() + " edit " + hologram.getName() + ")"); } else { - String defaultText = "Default hologram. Change it with " + String defaultText = "Default hologram. Change it with " + Colors.PRIMARY + "/" + context.getRootLabel() + " edit " + hologram.getName(); line = hologram.createTextLine(defaultText, defaultText.replace(ChatColor.COLOR_CHAR, '&')); } - + hologram.addLine(line); - + configManager.saveHologramDatabase(internalHologramManager); Location look = player.getLocation(); look.setPitch(90); @@ -83,11 +83,11 @@ public class CreateCommand extends HologramSubCommand { player.sendMessage(Colors.PRIMARY + "You created a hologram named '" + hologram.getName() + "'."); if (moveUp) { - player.sendMessage(Colors.SECONDARY_SHADOW + "(You were on the ground," - + " the hologram was automatically moved up." - + " If you use /" + context.getRootLabel() + " movehere " + hologram.getName() + "," + player.sendMessage(Colors.SECONDARY_SHADOW + "(You were on the ground," + + " the hologram was automatically moved up." + + " If you use /" + context.getRootLabel() + " movehere " + hologram.getName() + "," + " the hologram will be moved to your feet)"); } } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DebugCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DebugCommand.java index 216a9074..7789b8a8 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DebugCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DebugCommand.java @@ -24,12 +24,12 @@ import java.util.Map.Entry; public class DebugCommand extends HologramSubCommand { private final NMSManager nmsManager; - + public DebugCommand(NMSManager nmsManager) { super("debug"); setShowInHelpCommand(false); setDescription("Displays information useful for debugging."); - + this.nmsManager = nmsManager; } @@ -66,9 +66,9 @@ public class DebugCommand extends HologramSubCommand { for (Entry entry : hologramsDebugInfo.entrySet()) { StandardHologram hologram = entry.getKey(); HologramDebugInfo debugInfo = entry.getValue(); - sender.sendMessage(Colors.PRIMARY_SHADOW + "- '" + hologram.toFormattedString() + "':" - + " " + hologram.getLineCount() + " lines," - + " " + debugInfo.getTotalEntities() + " entities" + sender.sendMessage(Colors.PRIMARY_SHADOW + "- '" + hologram.toFormattedString() + "':" + + " " + hologram.getLineCount() + " lines," + + " " + debugInfo.getTotalEntities() + " entities" + " (" + debugInfo.aliveEntities + " alive, " + debugInfo.deadEntities + " dead)"); } } @@ -78,17 +78,17 @@ public class DebugCommand extends HologramSubCommand { sender.sendMessage(Colors.ERROR + "Couldn't find any loaded hologram (holograms may be in unloaded chunks)."); } } - + private static class HologramDebugInfo { - + private int aliveEntities; private int deadEntities; - + public int getTotalEntities() { return aliveEntities + deadEntities; } - + } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DeleteCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DeleteCommand.java index e8ec4c82..cc133df0 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DeleteCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/DeleteCommand.java @@ -33,11 +33,11 @@ public class DeleteCommand extends HologramSubCommand { @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); - + internalHologramManager.deleteHologram(hologram); - + configManager.saveHologramDatabase(internalHologramManager); - + sender.sendMessage(Colors.PRIMARY + "You deleted the hologram '" + hologram.getName() + "'."); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java index 9b92c3b0..422965c2 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/EditCommand.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.List; public class EditCommand extends HologramSubCommand { - + private final HologramCommandManager commandManager; private final InternalHologramManager internalHologramManager; @@ -43,7 +43,7 @@ public class EditCommand extends HologramSubCommand { @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); - + sender.sendMessage(""); Messages.sendTitle(sender, "How to edit the hologram '" + hologram.getName() + "'"); for (HologramSubCommand subCommand : commandManager.getSubCommands()) { @@ -62,7 +62,7 @@ public class EditCommand extends HologramSubCommand { .event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage)) .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help)))) .create()); - + } else { sender.sendMessage(Colors.PRIMARY + usage); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java index 130eb5f7..8f8ea11f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/HelpCommand.java @@ -30,7 +30,7 @@ public class HelpCommand extends HologramSubCommand { super("help"); setShowInHelpCommand(false); setDescription("Show the list of commands."); - + this.commandManager = commandManager; } @@ -54,7 +54,7 @@ public class HelpCommand extends HologramSubCommand { .event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage)) .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(String.join("\n", help)))) .create()); - + } else { sender.sendMessage(Colors.PRIMARY + usage); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java index b066b49a..43acc538 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InfoCommand.java @@ -34,14 +34,14 @@ public class InfoCommand extends LineEditingCommand implements QuickEditCommand @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); - + sender.sendMessage(""); Messages.sendTitle(sender, "Lines of the hologram '" + hologram.getName() + "'"); int index = 0; - + for (InternalHologramLine line : hologram.getLines()) { index++; - sender.sendMessage(Colors.SECONDARY + Colors.BOLD + index + sender.sendMessage(Colors.SECONDARY + Colors.BOLD + index + Colors.SECONDARY_SHADOW + ". " + Colors.SECONDARY + line.getSerializedConfigValue()); } commandManager.sendQuickEditCommands(context, hologram); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertlineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertlineCommand.java index 8cb64881..b3e4b031 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertlineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/InsertlineCommand.java @@ -49,19 +49,19 @@ public class InsertlineCommand extends LineEditingCommand implements QuickEditCo InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); int insertAfterIndex = CommandValidate.parseInteger(args[1]); String serializedLine = Strings.joinFrom(" ", args, 2); - + int oldLinesAmount = hologram.getLineCount(); - - CommandValidate.check(insertAfterIndex >= 0 && insertAfterIndex <= oldLinesAmount, + + CommandValidate.check(insertAfterIndex >= 0 && insertAfterIndex <= oldLinesAmount, "The number must be between 0 and " + hologram.getLineCount() + "(amount of lines of the hologram)."); InternalHologramLine line = HologramCommandValidate.parseHologramLine(hologram, serializedLine); hologram.insertLine(insertAfterIndex, line); - + configManager.saveHologramDatabase(internalHologramManager); - + Bukkit.getPluginManager().callEvent(new InternalHologramEditEvent(hologram)); - + if (insertAfterIndex == 0) { sender.sendMessage(Colors.PRIMARY + "Line inserted before first line."); } else if (insertAfterIndex == oldLinesAmount) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java index 1d13683d..ab6f340d 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ListCommand.java @@ -20,7 +20,7 @@ import java.util.List; public class ListCommand extends HologramSubCommand { private static final int HOLOGRAMS_PER_PAGE = 10; - + private final InternalHologramManager internalHologramManager; public ListCommand(InternalHologramManager internalHologramManager) { @@ -28,7 +28,7 @@ public class ListCommand extends HologramSubCommand { setMinArgs(0); setUsageArgs("[page]"); setDescription("Lists all the existing holograms."); - + this.internalHologramManager = internalHologramManager; } @@ -42,26 +42,26 @@ public class ListCommand extends HologramSubCommand { if (holograms.size() % HOLOGRAMS_PER_PAGE != 0) { totalPages++; } - - CommandValidate.check(holograms.size() > 0, + + CommandValidate.check(holograms.size() > 0, "There are no holograms yet. Create one with /" + context.getRootLabel() + " create."); sender.sendMessage(""); Messages.sendTitle(sender, "Holograms list " + Colors.SECONDARY + "(Page " + page + " of " + totalPages + ")"); int fromIndex = (page - 1) * HOLOGRAMS_PER_PAGE; int toIndex = fromIndex + HOLOGRAMS_PER_PAGE; - + for (int i = fromIndex; i < toIndex; i++) { if (i < holograms.size()) { InternalHologram hologram = holograms.get(i); - sender.sendMessage(Colors.SECONDARY_SHADOW + "- " + Colors.SECONDARY + Colors.BOLD + hologram.getName() - + " " + Colors.SECONDARY_SHADOW + "at x: " + (int) hologram.getX() - + ", y: " + (int) hologram.getY() - + ", z: " + (int) hologram.getZ() + sender.sendMessage(Colors.SECONDARY_SHADOW + "- " + Colors.SECONDARY + Colors.BOLD + hologram.getName() + + " " + Colors.SECONDARY_SHADOW + "at x: " + (int) hologram.getX() + + ", y: " + (int) hologram.getY() + + ", z: " + (int) hologram.getZ() + " (lines: " + hologram.getLineCount() + ", world: \"" + hologram.getWorld().getName() + "\")"); } } - + if (page < totalPages) { Messages.sendTip(sender, "See the next page with /" + context.getRootLabel() + " list " + (page + 1)); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MovehereCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MovehereCommand.java index d2eb498d..f3ebc689 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MovehereCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/MovehereCommand.java @@ -38,14 +38,14 @@ public class MovehereCommand extends HologramSubCommand { public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { Player player = CommandValidate.getPlayerSender(sender); InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); - + hologram.teleport(player.getLocation()); - + configManager.saveHologramDatabase(internalHologramManager); Location to = player.getLocation(); to.setPitch(90); player.teleport(to, TeleportCause.PLUGIN); player.sendMessage(Colors.PRIMARY + "You moved the hologram '" + hologram.getName() + "' near to you."); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java index ed40e3bc..be260b08 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/NearCommand.java @@ -29,7 +29,7 @@ public class NearCommand extends HologramSubCommand { setMinArgs(1); setUsageArgs(""); setDescription("Get a list of near holograms."); - + this.internalHologramManager = internalHologramManager; } @@ -38,28 +38,28 @@ public class NearCommand extends HologramSubCommand { Player player = CommandValidate.getPlayerSender(sender); int radius = CommandValidate.parseInteger(args[0]); CommandValidate.check(radius > 0, "Radius must be at least 1."); - + World world = player.getWorld(); int radiusSquared = radius * radius; List nearHolograms = new ArrayList<>(); - + for (InternalHologram hologram : internalHologramManager.getHolograms()) { if (hologram.getWorld().equals(world) && hologram.getLocation().distanceSquared(player.getLocation()) <= radiusSquared) { nearHolograms.add(hologram); } } - + CommandValidate.check(!nearHolograms.isEmpty(), "There are no holograms in the given radius."); - + Messages.sendTitle(player, "Near holograms"); for (InternalHologram nearHologram : nearHolograms) { - player.sendMessage(Colors.SECONDARY_SHADOW + "- " - + Colors.SECONDARY + Colors.BOLD + nearHologram.getName() + " " + Colors.SECONDARY_SHADOW + "at" - + " x: " + (int) nearHologram.getX() + "," - + " y: " + (int) nearHologram.getY() + "," + player.sendMessage(Colors.SECONDARY_SHADOW + "- " + + Colors.SECONDARY + Colors.BOLD + nearHologram.getName() + " " + Colors.SECONDARY_SHADOW + "at" + + " x: " + (int) nearHologram.getX() + "," + + " y: " + (int) nearHologram.getY() + "," + " z: " + (int) nearHologram.getZ() + " (lines: " + nearHologram.getLineCount() + ")"); } } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/QuickEditCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/QuickEditCommand.java index 647c3edc..81ab73d3 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/QuickEditCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/QuickEditCommand.java @@ -8,5 +8,5 @@ package me.filoghost.holographicdisplays.plugin.commands.subs; public interface QuickEditCommand { String getActionName(); - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadimageCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadimageCommand.java index 2815f6a8..fac76f6f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadimageCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadimageCommand.java @@ -39,7 +39,7 @@ public class ReadimageCommand extends LineEditingCommand { private final InternalHologramManager internalHologramManager; private final ConfigManager configManager; - + public ReadimageCommand(InternalHologramManager internalHologramManager, ConfigManager configManager) { super("readimage", "image"); setMinArgs(3); @@ -67,7 +67,7 @@ public class ReadimageCommand extends LineEditingCommand { "", "The symbols used to create the image are taken from the config.yml."); } - + @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { boolean append = false; @@ -80,25 +80,25 @@ public class ReadimageCommand extends LineEditingCommand { newArgs.add(arg); } } - + args = newArgs.toArray(new String[0]); - + InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); - + int width = CommandValidate.parseInteger(args[2]); CommandValidate.check(width >= 2, "The width of the image must be 2 or greater."); boolean isUrl = false; - + try { String fileName = args[1]; BufferedImage image; - + if (fileName.startsWith("http://") || fileName.startsWith("https://")) { isUrl = true; image = ImageReader.readImage(new URL(fileName)); } else { - + if (fileName.matches(".*[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-]{1,4}/.+")) { Messages.sendWarning(sender, "The image path seems to be an URL. If so, please use http:// or https:// in the path."); } @@ -112,26 +112,26 @@ public class ReadimageCommand extends LineEditingCommand { for (String newLine : imageMessage.getLines()) { newLines.add(hologram.createTextLine(newLine, newLine)); } - + if (!append) { hologram.clearLines(); } hologram.addLines(newLines); - + if (newLines.size() < 5) { - Messages.sendTip(sender, "The image has a very low height." + Messages.sendTip(sender, "The image has a very low height." + " You can increase it by increasing the width, it will scale automatically."); } - + configManager.saveHologramDatabase(internalHologramManager); - + if (append) { sender.sendMessage(Colors.PRIMARY + "The image was appended int the end of the hologram."); } else { sender.sendMessage(Colors.PRIMARY + "The image was drawn in the hologram."); } Bukkit.getPluginManager().callEvent(new InternalHologramEditEvent(hologram)); - + } catch (MalformedURLException e) { throw new CommandException("The provided URL was not valid."); } catch (ImageTooWideException e) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadtextCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadtextCommand.java index de506ae2..bc199897 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadtextCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReadtextCommand.java @@ -34,7 +34,7 @@ public class ReadtextCommand extends LineEditingCommand { private final InternalHologramManager internalHologramManager; private final ConfigManager configManager; - + public ReadtextCommand(InternalHologramManager internalHologramManager, ConfigManager configManager) { super("readtext", "readlines"); setMinArgs(2); @@ -57,22 +57,22 @@ public class ReadtextCommand extends LineEditingCommand { "to paste it in the hologram named 'test'. In this case you", "would execute " + ChatColor.YELLOW + "/" + context.getRootLabel() + " " + getName() + " test info.txt"); } - + @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); String fileName = args[1]; - + try { Path targetFile = HologramCommandValidate.getUserReadableFile(configManager.getRootDataFolder(), fileName); List serializedLines = Files.readAllLines(targetFile); - + int linesAmount = serializedLines.size(); if (linesAmount > 40) { Messages.sendWarning(sender, "The file contained more than 40 lines, that have been limited."); linesAmount = 40; } - + List linesToAdd = new ArrayList<>(); for (int i = 0; i < linesAmount; i++) { try { @@ -82,26 +82,26 @@ public class ReadtextCommand extends LineEditingCommand { throw new CommandException("Error at line " + (i + 1) + ": " + e.getMessage()); } } - + hologram.setLines(linesToAdd); configManager.saveHologramDatabase(internalHologramManager); - + if (isImageExtension(FileUtils.getExtension(fileName))) { - Messages.sendWarning(sender, "The read file has an image's extension." + Messages.sendWarning(sender, "The read file has an image's extension." + " If it is an image, you should use /" + context.getRootLabel() + " readimage."); } - + sender.sendMessage(Colors.PRIMARY + "The lines were pasted into the hologram."); Bukkit.getPluginManager().callEvent(new InternalHologramEditEvent(hologram)); - + } catch (IOException e) { throw new CommandException("I/O exception while reading the file. Is it in use?"); } } - + private boolean isImageExtension(String extension) { return Arrays.asList("jpg", "png", "jpeg", "gif").contains(extension.toLowerCase()); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReloadCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReloadCommand.java index 4a09cec3..398b7205 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReloadCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/ReloadCommand.java @@ -21,7 +21,7 @@ public class ReloadCommand extends HologramSubCommand { super("reload"); setDescription("Reloads the holograms from the database."); } - + @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) { PrintableErrorCollector errorCollector = new PrintableErrorCollector(); @@ -36,7 +36,7 @@ public class ReloadCommand extends HologramSubCommand { sender.sendMessage(Colors.ERROR + "Check the console for the details."); } } - + Bukkit.getPluginManager().callEvent(new HolographicDisplaysReloadEvent()); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemovelineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemovelineCommand.java index f643959d..8d3f3600 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemovelineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/RemovelineCommand.java @@ -41,21 +41,21 @@ public class RemovelineCommand extends LineEditingCommand implements QuickEditCo @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); - + int lineNumber = CommandValidate.parseInteger(args[1]); - CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(), + CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(), "The line number must be between 1 and " + hologram.getLineCount() + "."); int index = lineNumber - 1; - - CommandValidate.check(hologram.getLineCount() > 1, + + CommandValidate.check(hologram.getLineCount() > 1, "The hologram should have at least 1 line. If you want to delete it, use /" + context.getRootLabel() + " delete."); hologram.removeLine(index); - + configManager.saveHologramDatabase(internalHologramManager); Bukkit.getPluginManager().callEvent(new InternalHologramEditEvent(hologram)); - + sender.sendMessage(Colors.PRIMARY + "Line " + lineNumber + " removed."); commandManager.sendQuickEditCommands(context, hologram); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetlineCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetlineCommand.java index d575bab8..2456056e 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetlineCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/SetlineCommand.java @@ -44,19 +44,19 @@ public class SetlineCommand extends LineEditingCommand implements QuickEditComma public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); String serializedLine = Strings.joinFrom(" ", args, 2); - + int lineNumber = CommandValidate.parseInteger(args[1]); - CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(), + CommandValidate.check(lineNumber >= 1 && lineNumber <= hologram.getLineCount(), "The line number must be between 1 and " + hologram.getLineCount() + "."); int index = lineNumber - 1; - + InternalHologramLine line = HologramCommandValidate.parseHologramLine(hologram, serializedLine); hologram.setLine(index, line); configManager.saveHologramDatabase(internalHologramManager); Bukkit.getPluginManager().callEvent(new InternalHologramEditEvent(hologram)); - + sender.sendMessage(Colors.PRIMARY + "Line " + lineNumber + " changed."); commandManager.sendQuickEditCommands(context, hologram); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/TeleportCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/TeleportCommand.java index 715a1da0..f3e4ca96 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/TeleportCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/commands/subs/TeleportCommand.java @@ -22,13 +22,13 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; public class TeleportCommand extends HologramSubCommand { private final InternalHologramManager internalHologramManager; - + public TeleportCommand(InternalHologramManager internalHologramManager) { super("teleport", "tp"); setMinArgs(1); setUsageArgs(""); setDescription("Teleports you to the given hologram."); - + this.internalHologramManager = internalHologramManager; } @@ -36,7 +36,7 @@ public class TeleportCommand extends HologramSubCommand { public void execute(CommandSender sender, String[] args, SubCommandContext context) throws CommandException { Player player = CommandValidate.getPlayerSender(sender); InternalHologram hologram = HologramCommandValidate.getInternalHologram(internalHologramManager, args[0]); - + Location loc = hologram.getLocation(); loc.setPitch(90); player.teleport(loc, TeleportCause.PLUGIN); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigManager.java index dbf63586..b42fdc2d 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigManager.java @@ -40,7 +40,7 @@ public class ConfigManager extends BaseConfigManager { logConfigInitException(errorCollector, mainConfigLoader.getFile(), e); mainConfig = new ConfigurationFileModel(); // Fallback: use default values } - + Configuration.load(mainConfig, errorCollector); } @@ -69,21 +69,21 @@ public class ConfigManager extends BaseConfigManager { public void reloadStaticReplacements(ErrorCollector errorCollector) { FileConfig staticReplacementsConfig; - + try { staticReplacementsConfig = staticReplacementsConfigLoader.init(); } catch (ConfigException e) { logConfigInitException(errorCollector, staticReplacementsConfigLoader.getFile(), e); staticReplacementsConfig = new FileConfig(staticReplacementsConfigLoader.getFile()); // Fallback: empty config } - + StaticReplacements.load(staticReplacementsConfig, errorCollector); } public Path getAnimationsFolder() { return getRootDataFolder().resolve("animations"); } - + public ConfigLoader getExampleAnimationLoader() { return getConfigLoader(getAnimationsFolder().resolve("example.txt")); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/Configuration.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/Configuration.java index b023495e..94ed9a56 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/Configuration.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/Configuration.java @@ -18,7 +18,7 @@ import java.util.HashMap; import java.util.Map; public class Configuration { - + public static double spaceBetweenLines; public static boolean quickEditCommands; public static DateTimeFormatter timeFormat; @@ -37,17 +37,17 @@ public class Configuration { public static String pingerStatusOffline; public static boolean pingerTrimMotd; public static Map pingerServerAddresses; - + public static void load(ConfigurationFileModel config, ErrorCollector errorCollector) { spaceBetweenLines = config.spaceBetweenLines; quickEditCommands = config.quickEditCommands; timeFormat = parseTimeFormatter(config.timeFormat, config.timeZone, errorCollector); updateNotification = config.updateNotification; - + imageSymbol = TextFormatter.toDisplayFormat(config.imageSymbol); transparencySymbol = TextFormatter.toDisplayFormat(config.transparencySymbol); transparencyColor = parseTransparencyColor(config.transparencyColor, errorCollector); - + bungeeRefreshSeconds = parseBungeeRefreshInterval(config.bungeeRefreshSeconds, errorCollector); useRedisBungee = config.useRedisBungee; pingerEnabled = config.pingerEnable; @@ -129,7 +129,7 @@ public class Configuration { private static ServerAddress parseServerAddress(String singleServer, ErrorCollector errorCollector) { String[] nameAndAddress = Strings.splitAndTrim(singleServer, ":", 2); if (nameAndAddress.length < 2) { - errorCollector.add("the server info \"" + singleServer + "\" is not valid." + errorCollector.add("the server info \"" + singleServer + "\" is not valid." + " There should be a name and an address, separated by a colon"); return null; } @@ -153,7 +153,7 @@ public class Configuration { ip = address; port = 25565; // Default Minecraft server port } - + return new ServerAddress(name, ip, port); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigurationFileModel.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigurationFileModel.java index c08cef6f..2fb82479 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigurationFileModel.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ConfigurationFileModel.java @@ -13,19 +13,19 @@ import java.util.Arrays; import java.util.List; public class ConfigurationFileModel implements MappedConfig { - + @Path("space-between-lines") double spaceBetweenLines = 0.02; - + @Path("quick-edit-commands") boolean quickEditCommands = true; - + @Path("images.symbol") String imageSymbol = "[x]"; - + @Path("images.transparency.space") String transparencySymbol = " [|] "; - + @Path("images.transparency.color") String transparencyColor = "&7"; @@ -61,13 +61,13 @@ public class ConfigurationFileModel implements MappedConfig { @Path("time.zone") String timeZone = "GMT+1"; - + @Path("update-notification") boolean updateNotification = true; @Path("debug") boolean debug = false; - + @Override public List getHeader() { return Arrays.asList( @@ -92,14 +92,14 @@ public class ConfigurationFileModel implements MappedConfig { ); boolean modified = false; - + for (String path : pathsToRemove) { if (rawConfig.get(path) != null) { rawConfig.remove(path); modified = true; } } - + return modified; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramConfig.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramConfig.java index 7de194ce..b574f1f2 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramConfig.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramConfig.java @@ -22,9 +22,9 @@ import java.util.Locale; public class HologramConfig { - private static final DecimalFormat LOCATION_NUMBER_FORMAT + private static final DecimalFormat LOCATION_NUMBER_FORMAT = new DecimalFormat("0.000", DecimalFormatSymbols.getInstance(Locale.ROOT)); - + private final String name; private final List serializedLines; private final String serializedLocation; @@ -72,7 +72,7 @@ public class HologramConfig { throw new HologramLoadException("invalid line: " + e.getMessage(), e); } } - + hologram.setLines(lines); return hologram; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramLineParser.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramLineParser.java index 46e5082e..be9071dc 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramLineParser.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/HologramLineParser.java @@ -22,12 +22,12 @@ public class HologramLineParser { public static InternalHologramLine parseLine(InternalHologram hologram, String serializedLine) throws HologramLoadException { InternalHologramLine hologramLine; - + if (serializedLine.toLowerCase().startsWith(ICON_PREFIX)) { String serializedIcon = serializedLine.substring(ICON_PREFIX.length()); ItemStack icon = parseItemStack(serializedIcon); hologramLine = hologram.createItemLine(icon, serializedLine); - + } else { String displayText; if (serializedLine.trim().equalsIgnoreCase(EMPTY_LINE_PLACEHOLDER)) { @@ -35,37 +35,37 @@ public class HologramLineParser { } else { displayText = TextFormatter.toDisplayFormat(serializedLine); } - + hologramLine = hologram.createTextLine(displayText, serializedLine); } - + return hologramLine; } - - + + @SuppressWarnings("deprecation") private static ItemStack parseItemStack(String serializedItem) throws HologramLoadException { serializedItem = serializedItem.trim(); - + // Parse json int nbtStart = serializedItem.indexOf('{'); int nbtEnd = serializedItem.lastIndexOf('}'); String nbtString = null; - + String basicItemData; - + if (nbtStart > 0 && nbtEnd > 0 && nbtEnd > nbtStart) { nbtString = serializedItem.substring(nbtStart, nbtEnd + 1); basicItemData = serializedItem.substring(0, nbtStart) + serializedItem.substring(nbtEnd + 1); } else { basicItemData = serializedItem; } - + basicItemData = Strings.stripChars(basicItemData, ' '); String materialName; short dataValue = 0; - + if (basicItemData.contains(":")) { String[] materialAndDataValue = Strings.split(basicItemData, ":", 2); try { @@ -77,14 +77,14 @@ public class HologramLineParser { } else { materialName = basicItemData; } - + Material material = MaterialsHelper.matchMaterial(materialName); if (material == null) { throw new HologramLoadException("\"" + materialName + "\" is not a valid material"); } - + ItemStack itemStack = new ItemStack(material, 1, dataValue); - + if (nbtString != null) { try { // Check NBT syntax validity before applying it @@ -96,7 +96,7 @@ public class HologramLineParser { throw new HologramLoadException("unexpected exception while parsing NBT data", e); } } - + return itemStack; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ServerAddress.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ServerAddress.java index d570a74c..86126dc8 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ServerAddress.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/ServerAddress.java @@ -6,11 +6,11 @@ package me.filoghost.holographicdisplays.plugin.disk; public class ServerAddress { - + private final String name; private final String ip; private final int port; - + public ServerAddress(String name, String ip, int port) { this.name = name; this.ip = ip; @@ -28,10 +28,10 @@ public class ServerAddress { public int getPort() { return port; } - + @Override public String toString() { return name + " (" + ip + ":" + port + ")"; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/StaticReplacements.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/StaticReplacements.java index cac63b4f..6efdd598 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/StaticReplacements.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/StaticReplacements.java @@ -33,13 +33,13 @@ public class StaticReplacements { String replacement = Colors.addColors(entry.getValue()); if (target.length() == 0) { - errorCollector.add("error in \"" + config.getSourceFile() + "\":" + errorCollector.add("error in \"" + config.getSourceFile() + "\":" + " placeholder cannot be empty (skipped)"); continue; } if (target.length() > 100) { - errorCollector.add("error in \"" + config.getSourceFile() + "\":" + errorCollector.add("error in \"" + config.getSourceFile() + "\":" + " placeholder cannot be longer than 100 character (" + target + ")"); continue; } @@ -54,26 +54,26 @@ public class StaticReplacements { } return text; } - + private static class StaticReplacement { - + private final String target; private final String replacement; - + StaticReplacement(String target, String replacement) { this.target = target; this.replacement = replacement; } - + public String getTarget() { return target; } - + public String getReplacement() { return replacement; } - + } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/TextFormatter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/TextFormatter.java index efe4bdb3..decffc23 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/TextFormatter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/TextFormatter.java @@ -9,7 +9,7 @@ package me.filoghost.holographicdisplays.plugin.disk; import me.filoghost.fcommons.Colors; public class TextFormatter { - + public static String toDisplayFormat(String input) { if (input == null) { return null; @@ -20,5 +20,5 @@ public class TextFormatter { input = Colors.addColors(input); return input; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/upgrade/LegacySymbolsUpgrade.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/upgrade/LegacySymbolsUpgrade.java index f3110496..5bfed789 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/upgrade/LegacySymbolsUpgrade.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/disk/upgrade/LegacySymbolsUpgrade.java @@ -23,7 +23,7 @@ import java.nio.file.Path; import java.util.List; public class LegacySymbolsUpgrade { - + public static void run(ConfigManager configManager, ErrorCollector errorCollector) throws ConfigLoadException, ConfigSaveException { Path oldFile = configManager.getRootDataFolder().resolve("symbols.yml"); ConfigLoader newConfigLoader = configManager.getConfigLoader("custom-placeholders.yml"); @@ -32,14 +32,14 @@ public class LegacySymbolsUpgrade { if (!Files.isRegularFile(oldFile)) { return; // Old file doesn't exist, ignore upgrade } - + if (Files.isRegularFile(newFile)) { return; // Already created, do not override } Config newConfig = new Config(); ConfigSection placeholdersSection = newConfig.getOrCreateSection("placeholders"); - + List lines; try { lines = Files.readAllLines(oldFile); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/HolographicDisplaysReloadEvent.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/HolographicDisplaysReloadEvent.java index b8b25347..9ae5c0fb 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/HolographicDisplaysReloadEvent.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/HolographicDisplaysReloadEvent.java @@ -9,16 +9,16 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; public class HolographicDisplaysReloadEvent extends Event { - + private static final HandlerList handlers = new HandlerList(); - + @Override public HandlerList getHandlers() { return handlers; } - + public static HandlerList getHandlerList() { return handlers; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/InternalHologramEditEvent.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/InternalHologramEditEvent.java index 2c63924f..38d80b90 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/InternalHologramEditEvent.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/event/InternalHologramEditEvent.java @@ -10,11 +10,11 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; public class InternalHologramEditEvent extends Event { - + private static final HandlerList handlers = new HandlerList(); - + private final InternalHologram hologram; - + public InternalHologramEditEvent(InternalHologram hologram) { this.hologram = hologram; } @@ -27,9 +27,9 @@ public class InternalHologramEditEvent extends Event { public HandlerList getHandlers() { return handlers; } - + public static HandlerList getHandlerList() { return handlers; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java index 59a0276c..0e4ede0b 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java @@ -45,12 +45,12 @@ public class APIHologram extends BaseHologram implements Hologr this.creationTimestamp = System.currentTimeMillis(); this.v2Adapter = new V2HologramAdapter(this); } - + @Override public Plugin getCreatorPlugin() { return plugin; } - + @Override public @NotNull APITextLine appendTextLine(@Nullable String text) { APITextLine line = createTextLine(text); @@ -115,7 +115,7 @@ public class APIHologram extends BaseHologram implements Hologr public boolean isVisibleTo(Player player) { return visibilitySettings.isVisibleTo(player); } - + @Override public double getHeight() { List lines = getLines(); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramLine.java index f975ab19..e80db0c3 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramLine.java @@ -14,7 +14,7 @@ public interface APIHologramLine extends HologramLine, StandardHologramLine { @Override @NotNull APIHologram getParent(); - + @Override default void removeLine() { getParent().removeLine(this); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramManager.java index f6ff2668..3fb109db 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologramManager.java @@ -35,13 +35,13 @@ public class APIHologramManager extends BaseHologramManager { public Collection getHologramsByPlugin(Plugin plugin) { List ownedHolograms = new ArrayList<>(); - + for (APIHologram hologram : getHolograms()) { if (hologram.getCreatorPlugin().equals(plugin)) { ownedHolograms.add(hologram); } } - + return Collections.unmodifiableList(ownedHolograms); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java index 1627b0dd..2c4a6389 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java @@ -41,10 +41,10 @@ public class APIItemLine extends BaseItemLine implements ItemLine, APITouchableL v2Adapter.onNewPickupHandlerChange(getPickupHandler(), pickupHandler); super.setPickupHandler(pickupHandler); } - + @Override public V2ItemLineAdapter getV2Adapter() { return v2Adapter; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java index b3911bbf..908d8816 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java @@ -38,7 +38,7 @@ public class APITextLine extends BaseTextLine implements TextLine, APITouchableL v2Adapter.onNewTouchHandlerChange(getTouchHandler(), touchHandler); super.setTouchHandler(touchHandler); } - + @Override public V2TextLineAdapter getV2Adapter() { return v2Adapter; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/DefaultVisibilitySettings.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/DefaultVisibilitySettings.java index e78c5b08..5222147c 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/DefaultVisibilitySettings.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/DefaultVisibilitySettings.java @@ -19,30 +19,30 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; public class DefaultVisibilitySettings implements VisibilitySettings { - + private final StandardHologram hologram; private final V2VisibilityManagerAdapter v2Adapter; private Map visibilityByPlayer; private Visibility defaultVisibility; - + public DefaultVisibilitySettings(StandardHologram hologram) { Preconditions.notNull(hologram, "hologram"); this.hologram = hologram; this.v2Adapter = new V2VisibilityManagerAdapter(this); this.defaultVisibility = Visibility.VISIBLE; } - + @Override public @NotNull Visibility getDefaultVisibility() { return defaultVisibility; } - + @Override public void setDefaultVisibility(@NotNull Visibility defaultVisibility) { if (this.defaultVisibility == defaultVisibility) { return; } - + this.defaultVisibility = defaultVisibility; for (Player player : Bukkit.getOnlinePlayers()) { @@ -50,11 +50,11 @@ public class DefaultVisibilitySettings implements VisibilitySettings { // Has a specific value set continue; } - + sendVisibilityChangePacket(hologram, player, defaultVisibility); } } - + @Override public void setIndividualVisibility(@NotNull Player player, @NotNull Visibility visibility) { Visibility oldVisibility = getVisibility(player); @@ -69,14 +69,14 @@ public class DefaultVisibilitySettings implements VisibilitySettings { sendVisibilityChangePacket(hologram, player, visibility); } } - + @Override public boolean isVisibleTo(@NotNull Player player) { Preconditions.notNull(player, "player"); - + return getVisibility(player) == Visibility.VISIBLE; } - + private Visibility getVisibility(Player player) { if (visibilityByPlayer != null) { Visibility visibility = visibilityByPlayer.get(player.getUniqueId()); @@ -91,24 +91,24 @@ public class DefaultVisibilitySettings implements VisibilitySettings { @Override public void resetIndividualVisibility(@NotNull Player player) { Preconditions.notNull(player, "player"); - + if (visibilityByPlayer == null) { return; } - + Visibility oldVisibility = visibilityByPlayer.remove(player.getUniqueId()); - + if (oldVisibility != null && oldVisibility != defaultVisibility) { sendVisibilityChangePacket(hologram, player, defaultVisibility); } } - + @Override public void resetIndividualVisibilityAll() { if (visibilityByPlayer == null) { return; } - + for (Player player : Bukkit.getOnlinePlayers()) { Visibility oldVisibility = getVisibility(player); if (oldVisibility != defaultVisibility) { @@ -117,7 +117,7 @@ public class DefaultVisibilitySettings implements VisibilitySettings { } visibilityByPlayer = null; } - + private void sendVisibilityChangePacket(StandardHologram hologram, Player player, Visibility visibility) { if (ProtocolLibHook.isEnabled()) { if (visibility == Visibility.VISIBLE) { @@ -130,9 +130,9 @@ public class DefaultVisibilitySettings implements VisibilitySettings { @Override public String toString() { - return "VisibilitySettings [" - + "defaultVisibility=" + defaultVisibility - + ", visibilityByPlayer=" + visibilityByPlayer + return "VisibilitySettings [" + + "defaultVisibility=" + defaultVisibility + + ", visibilityByPlayer=" + visibilityByPlayer + "]"; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologram.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologram.java index f6c9566e..a91d6178 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologram.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologram.java @@ -21,12 +21,12 @@ import java.util.Iterator; import java.util.List; public abstract class BaseHologram extends BaseHologramComponent implements StandardHologram { - + private final NMSManager nmsManager; private final PlaceholderLineTracker placeholderLineTracker; private final List lines; private final List unmodifiableLinesView; - + private boolean deleted; public BaseHologram(Location location, NMSManager nmsManager, PlaceholderLineTracker placeholderLineTracker) { @@ -50,7 +50,7 @@ public abstract class BaseHologram extends BaseH public boolean isDeleted() { return deleted; } - + @Override public void setDeleted() { if (!deleted) { @@ -66,28 +66,28 @@ public abstract class BaseHologram extends BaseH public void addLine(T line) { checkNotDeleted(); - + lines.add(line); refresh(); } public void addLines(List newLines) { checkNotDeleted(); - + lines.addAll(newLines); refresh(); } public void insertLine(int afterIndex, T line) { checkNotDeleted(); - + lines.add(afterIndex, line); refresh(); } public void setLine(int index, T line) { checkNotDeleted(); - + T previousLine = lines.set(index, line); previousLine.despawn(); refresh(); @@ -95,19 +95,19 @@ public abstract class BaseHologram extends BaseH public void setLines(List newLines) { checkNotDeleted(); - + clearLines(); lines.addAll(newLines); refresh(); } - + public void removeLine(int index) { checkNotDeleted(); lines.remove(index).despawn(); refresh(); } - + public void removeLine(T line) { checkNotDeleted(); @@ -115,31 +115,31 @@ public abstract class BaseHologram extends BaseH line.despawn(); refresh(); } - + public void clearLines() { checkNotDeleted(); - + Iterator iterator = lines.iterator(); while (iterator.hasNext()) { T line = iterator.next(); iterator.remove(); line.despawn(); } - + // No need to refresh, since there are no lines } - + @Override public int getLineCount() { return lines.size(); } - + public void teleport(@NotNull Location location) { Preconditions.notNull(location, "location"); teleport(location.getWorld(), location.getX(), location.getY(), location.getZ()); } - + public void teleport(@NotNull World world, double x, double y, double z) { checkNotDeleted(); Preconditions.notNull(world, "world"); @@ -161,7 +161,7 @@ public abstract class BaseHologram extends BaseH @Override public void refresh(boolean forceRespawn, boolean isChunkLoaded) { checkNotDeleted(); - + if (isChunkLoaded) { respawnEntities(forceRespawn); } else { @@ -178,7 +178,7 @@ public abstract class BaseHologram extends BaseH for (int i = 0; i < lines.size(); i++) { T line = lines.get(i); - + currentLineY -= line.getHeight(); if (i > 0) { currentLineY -= Configuration.spaceBetweenLines; @@ -211,5 +211,5 @@ public abstract class BaseHologram extends BaseH * Object.equals() and Object.hashCode() are not overridden: * two holograms are equal only if they are the same exact instance. */ - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramComponent.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramComponent.java index c36c0345..5197e8b0 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramComponent.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramComponent.java @@ -16,11 +16,11 @@ public abstract class BaseHologramComponent { private World world; private double x, y, z; private int chunkX, chunkZ; - + public boolean isInChunk(Chunk chunk) { - return world != null - && chunk.getWorld() == world - && chunk.getX() == chunkX + return world != null + && chunk.getWorld() == world + && chunk.getX() == chunkX && chunk.getZ() == chunkZ; } @@ -31,7 +31,7 @@ public abstract class BaseHologramComponent { public @NotNull Location getLocation() { return new Location(world, x, y, z); } - + protected void setLocation(Location location) { setLocation(location.getWorld(), location.getX(), location.getY(), location.getZ()); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java index fc67c5e4..9a211fd3 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java @@ -15,7 +15,7 @@ import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderL import org.bukkit.World; public abstract class BaseHologramLine extends BaseHologramComponent implements StandardHologramLine { - + private final BaseHologram hologram; private boolean isSpawned; @@ -24,7 +24,7 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements Preconditions.notNull(hologram, "parent hologram"); this.hologram = hologram; } - + @Override public final StandardHologram getHologram() { return hologram; @@ -41,10 +41,10 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements @Override public final void respawn(World world, double x, double y, double z) { Preconditions.notNull(world, "world"); - + boolean changedWorld = world != getWorld(); setLocation(world, x, y, z); - + try { if (changedWorld) { // World has changed, entities must be fully respawned @@ -71,7 +71,7 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements despawnEntities(); isSpawned = false; } - + protected final boolean isSpawned() { return isSpawned; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramManager.java index a8a06d1f..38b03e5f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramManager.java @@ -41,7 +41,7 @@ public abstract class BaseHologramManager { hologram.setDeleted(); } } - + public void onChunkLoad(Chunk chunk) { // Load the holograms in that chunk for (H hologram : holograms) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseItemLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseItemLine.java index 960d0ff9..343baa77 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseItemLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseItemLine.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; public abstract class BaseItemLine extends BaseTouchableLine implements StandardItemLine { - + private ItemStack itemStack; private NMSItem itemEntity; @@ -32,38 +32,38 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard super(hologram); setItemStack(itemStack); } - + @Override public void onPickup(Player player) { if (pickupHandler == null || !getHologram().isVisibleTo(player)) { return; } - + try { pickupHandler.onPickup(player); } catch (Throwable t) { - Log.warning("The plugin " + getHologram().getCreatorPlugin().getName() + " generated an exception" + Log.warning("The plugin " + getHologram().getCreatorPlugin().getName() + " generated an exception" + " when the player " + player.getName() + " picked up an item from a hologram.", t); } } - + public @Nullable PickupHandler getPickupHandler() { return pickupHandler; } - + public void setPickupHandler(@Nullable PickupHandler pickupHandler) { this.pickupHandler = pickupHandler; } - + public @NotNull ItemStack getItemStack() { return itemStack; } - + public void setItemStack(@NotNull ItemStack itemStack) { Preconditions.notNull(itemStack, "itemStack"); Preconditions.checkArgument(0 < itemStack.getAmount() && itemStack.getAmount() <= 64, "Item must have amount between 1 and 64"); this.itemStack = itemStack; - + if (itemEntity != null) { itemEntity.setItemStackNMS(itemStack); } @@ -72,14 +72,14 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard @Override public void spawnEntities(World world, double x, double y, double z) throws SpawnFailedException { super.spawnEntities(world, x, y, z); - + if (itemStack != null) { itemEntity = getNMSManager().spawnNMSItem(world, x, y + getItemSpawnOffset(), z, this, itemStack); itemVehicleEntity = getNMSManager().spawnNMSArmorStand(world, x, y + getItemSpawnOffset(), z, this); itemVehicleEntity.setPassengerNMS(itemEntity); } } - + @Override public void teleportEntities(double x, double y, double z) { super.teleportEntities(x, y, z); @@ -95,12 +95,12 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard @Override public void despawnEntities() { super.despawnEntities(); - + if (itemVehicleEntity != null) { itemVehicleEntity.killEntityNMS(); itemVehicleEntity = null; } - + if (itemEntity != null) { itemEntity.killEntityNMS(); itemEntity = null; @@ -115,7 +115,7 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard @Override public void collectTrackedEntityIDs(Player player, Collection collector) { super.collectTrackedEntityIDs(player, collector); - + if (itemVehicleEntity != null && itemVehicleEntity.isTrackedBy(player)) { collector.add(itemVehicleEntity.getIdNMS()); } @@ -133,7 +133,7 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard public NMSArmorStand getNMSItemVehicle() { return itemVehicleEntity; } - + private double getItemSpawnOffset() { return 0; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTextLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTextLine.java index d2cca201..951b2513 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTextLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTextLine.java @@ -15,23 +15,23 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; public abstract class BaseTextLine extends BaseTouchableLine implements StandardTextLine { - + private String text; private NMSArmorStand textEntity; - + public BaseTextLine(BaseHologram hologram, String text) { super(hologram); setText(text); } - + @Override public @Nullable String getText() { return text; } - + public void setText(@Nullable String text) { this.text = text; - + if (textEntity != null) { textEntity.setCustomNameNMS(text); getPlaceholderLineTracker().onTextLineChange(this); @@ -50,7 +50,7 @@ public abstract class BaseTextLine extends BaseTouchableLine implements Standard getPlaceholderLineTracker().onTextLineChange(this); } - + @Override public void teleportEntities(double x, double y, double z) { super.teleportEntities(x, y, z); @@ -63,7 +63,7 @@ public abstract class BaseTextLine extends BaseTouchableLine implements Standard @Override public void despawnEntities() { super.despawnEntities(); - + if (textEntity != null) { textEntity.killEntityNMS(); textEntity = null; @@ -74,11 +74,11 @@ public abstract class BaseTextLine extends BaseTouchableLine implements Standard public double getHeight() { return 0.23; } - + @Override public void collectTrackedEntityIDs(Player player, Collection collector) { super.collectTrackedEntityIDs(player, collector); - + if (textEntity != null && textEntity.isTrackedBy(player)) { collector.add(textEntity.getIdNMS()); } @@ -97,5 +97,5 @@ public abstract class BaseTextLine extends BaseTouchableLine implements Standard public String toString() { return "TextLine [text=" + text + "]"; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTouchableLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTouchableLine.java index c9fbaacb..a95acbb1 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTouchableLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseTouchableLine.java @@ -27,14 +27,14 @@ import java.util.WeakHashMap; public abstract class BaseTouchableLine extends BaseHologramLine implements StandardTouchableLine { private static final double SLIME_HEIGHT = 0.5; - + private static final Map lastClickByPlayer = new WeakHashMap<>(); private TouchHandler touchHandler; private NMSSlime slimeEntity; private NMSArmorStand slimeVehicleEntity; - + protected BaseTouchableLine(BaseHologram hologram) { super(hologram); @@ -57,14 +57,14 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan try { touchHandler.onTouch(player); } catch (Throwable t) { - Log.warning("The plugin " + getHologram().getCreatorPlugin().getName() + " generated an exception" + Log.warning("The plugin " + getHologram().getCreatorPlugin().getName() + " generated an exception" + " when the player " + player.getName() + " touched a hologram.", t); } } public void setTouchHandler(@Nullable TouchHandler touchHandler) { this.touchHandler = touchHandler; - + if (touchHandler != null && slimeEntity == null && super.isSpawned()) { // If the touch handler was null before and no entity has been spawned, spawn it now spawnSlime(getWorld(), getX(), getY(), getZ()); @@ -102,7 +102,7 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan private void spawnSlime(World world, double x, double y, double z) { despawnSlime(); - + if (world != null) { try { slimeEntity = getNMSManager().spawnNMSSlime(world, x, getSlimeSpawnY(y), z, this); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologram.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologram.java index 51b64f23..777fb504 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologram.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologram.java @@ -39,7 +39,7 @@ public class InternalHologram extends BaseHologram { public Plugin getCreatorPlugin() { return HolographicDisplays.getInstance(); } - + @Override public boolean isVisibleTo(Player player) { return true; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramLine.java index 45dd5529..5cafa319 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramLine.java @@ -8,7 +8,7 @@ package me.filoghost.holographicdisplays.plugin.hologram.internal; import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine; public interface InternalHologramLine extends StandardHologramLine { - + String getSerializedConfigValue(); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramManager.java index 8e170345..155a45ca 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/internal/InternalHologramManager.java @@ -11,7 +11,7 @@ import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderL import org.bukkit.Location; public class InternalHologramManager extends BaseHologramManager { - + private final NMSManager nmsManager; private final PlaceholderLineTracker placeholderLineTracker; @@ -38,5 +38,5 @@ public class InternalHologramManager extends BaseHologramManager colorsMap = new HashMap<>(); private static final Map graysMap = new HashMap<>(); - + static { colorsMap.put(ChatColor.DARK_BLUE, new Color(0, 0, 170)); colorsMap.put(ChatColor.DARK_GREEN, new Color(0, 170, 0)); @@ -39,13 +39,13 @@ public class ImageMessage { colorsMap.put(ChatColor.RED, new Color(255, 85, 85)); colorsMap.put(ChatColor.LIGHT_PURPLE, new Color(255, 85, 255)); colorsMap.put(ChatColor.YELLOW, new Color(255, 255, 85)); - + graysMap.put(ChatColor.BLACK, new Color(0, 0, 0)); graysMap.put(ChatColor.DARK_GRAY, new Color(85, 85, 85)); graysMap.put(ChatColor.GRAY, new Color(170, 170, 170)); graysMap.put(ChatColor.WHITE, new Color(255, 255, 255)); } - + private final String[] lines; @@ -60,13 +60,13 @@ public class ImageMessage { if (height == 0) { height = 1; } - + if (width > MAX_WIDTH) { throw new ImageTooWideException(); } BufferedImage resized = resizeImage(image, width, height); - + ChatColor[][] chatImg = new ChatColor[resized.getWidth()][resized.getHeight()]; for (int x = 0; x < resized.getWidth(); x++) { for (int y = 0; y < resized.getHeight(); y++) { @@ -82,14 +82,14 @@ public class ImageMessage { ChatColor transparencyColor = Configuration.transparencyColor; String transparencySymbol = Configuration.transparencySymbol; String imageSymbol = Configuration.imageSymbol; - + for (int y = 0; y < colors[0].length; y++) { StringBuilder line = new StringBuilder(); ChatColor previous = ChatColor.RESET; - + for (int x = 0; x < colors.length; x++) { ChatColor currentColor = colors[x][y]; - + if (currentColor == null) { // Use the transparent char if (previous != transparencyColor) { @@ -98,27 +98,27 @@ public class ImageMessage { previous = transparencyColor; } line.append(transparencySymbol); - + } else { if (previous != currentColor) { line.append(currentColor.toString()); previous = currentColor; } - + line.append(imageSymbol); } } - + lines[y] = line.toString(); } - + return lines; } private BufferedImage resizeImage(BufferedImage originalImage, int width, int height) { return toBufferedImage(originalImage.getScaledInstance(width, height, Image.SCALE_DEFAULT)); } - + private BufferedImage toBufferedImage(Image img) { // Creates a buffered image with transparency BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); @@ -144,8 +144,8 @@ public class ImageMessage { } private boolean areIdentical(Color c1, Color c2) { - return Math.abs(c1.getRed() - c2.getRed()) <= 5 - && Math.abs(c1.getGreen() - c2.getGreen()) <= 5 + return Math.abs(c1.getRed() - c2.getRed()) <= 5 + && Math.abs(c1.getGreen() - c2.getGreen()) <= 5 && Math.abs(c1.getBlue() - c2.getBlue()) <= 5; } @@ -160,29 +160,29 @@ public class ImageMessage { return entry.getKey(); } } - + double bestGrayDistance = -1; ChatColor bestGrayMatch = null; - + for (Entry entry : graysMap.entrySet()) { double distance = getDistance(color, entry.getValue()); - + if (distance < bestGrayDistance || bestGrayDistance == -1) { bestGrayDistance = distance; bestGrayMatch = entry.getKey(); } } - + if (bestGrayDistance < 17500) { return bestGrayMatch; } - + double bestColorDistance = -1; ChatColor bestColorMatch = null; - + for (Entry entry : colorsMap.entrySet()) { double distance = getDistance(color, entry.getValue()); - + if (distance < bestColorDistance || bestColorDistance == -1) { bestColorDistance = distance; bestColorMatch = entry.getKey(); @@ -192,9 +192,9 @@ public class ImageMessage { // Minecraft has 15 colors return bestColorMatch; } - + public String[] getLines() { return lines; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/image/ImageReader.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/image/ImageReader.java index 55981179..0e548422 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/image/ImageReader.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/image/ImageReader.java @@ -16,21 +16,21 @@ public class ImageReader { public static BufferedImage readImage(Path file) throws ImageReadException, IOException { BufferedImage image = ImageIO.read(Files.newInputStream(file)); - + if (image == null) { throw new ImageReadException(); } - + return image; } public static BufferedImage readImage(URL url) throws ImageReadException, IOException { BufferedImage image = ImageIO.read(url); - + if (image == null) { throw new ImageReadException(); } - + return image; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/AbstractPacket.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/AbstractPacket.java index 9d58c7e0..9425e9b8 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/AbstractPacket.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/AbstractPacket.java @@ -25,7 +25,7 @@ import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; public abstract class AbstractPacket { - + // The packet we will be modifying protected PacketContainer handle; @@ -76,5 +76,5 @@ public abstract class AbstractPacket { throw new RuntimeException("Cannot receive packet.", e); } } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerAttachEntity.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerAttachEntity.java index 7cf32612..d4a58aec 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerAttachEntity.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerAttachEntity.java @@ -23,18 +23,18 @@ import org.bukkit.World; import org.bukkit.entity.Entity; public class WrapperPlayServerAttachEntity extends AbstractPacket { - + public static final PacketType TYPE = PacketType.Play.Server.ATTACH_ENTITY; - + public WrapperPlayServerAttachEntity() { super(new PacketContainer(TYPE), TYPE); handle.getModifier().writeDefaults(); } - + public WrapperPlayServerAttachEntity(PacketContainer packet) { super(packet, TYPE); } - + /** * Retrieve whether or not the entity is leached onto the vehicle. * @@ -43,7 +43,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket { public boolean getLeached() { return handle.getIntegers().read(0) != 0; } - + /** * Set whether or not the entity is leached onto the vehicle. * @@ -52,7 +52,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket { public void setLeached(boolean value) { handle.getIntegers().write(0, value ? 1 : 0); } - + /** * Retrieve the player entity ID being attached. * @@ -61,7 +61,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket { public int getEntityId() { return handle.getIntegers().read(1); } - + /** * Set the player entity ID being attached. * @@ -90,7 +90,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket { public Entity getEntity(PacketEvent event) { return getEntity(event.getPlayer().getWorld()); } - + /** * Retrieve the vehicle entity ID attached to (-1 for unattaching). * @@ -99,7 +99,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket { public int getVehicleId() { return handle.getIntegers().read(2); } - + /** * Set the vehicle entity ID attached to (-1 for unattaching). * @@ -108,7 +108,7 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket { public void setVehicleId(int value) { handle.getIntegers().write(2, value); } - + /** * Retrieve the vehicle entity attached to (NULL for unattaching). * @@ -128,5 +128,5 @@ public class WrapperPlayServerAttachEntity extends AbstractPacket { public Entity getVehicle(PacketEvent event) { return getVehicle(event.getPlayer().getWorld()); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityDestroy.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityDestroy.java index 4556e4e4..eee2bf0f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityDestroy.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityDestroy.java @@ -23,37 +23,37 @@ import com.google.common.primitives.Ints; import java.util.List; public class WrapperPlayServerEntityDestroy extends AbstractPacket { - + public static final PacketType TYPE = PacketType.Play.Server.ENTITY_DESTROY; - + public WrapperPlayServerEntityDestroy() { super(new PacketContainer(TYPE), TYPE); handle.getModifier().writeDefaults(); } - + public WrapperPlayServerEntityDestroy(PacketContainer packet) { super(packet, TYPE); } - + /** * Retrieve the IDs of the entities that will be destroyed. */ public List getEntities() { return Ints.asList(handle.getIntegerArrays().read(0)); } - + /** * Set the entities that will be destroyed. */ public void setEntities(int[] entities) { handle.getIntegerArrays().write(0, entities); } - + /** * Set the entities that will be destroyed. */ public void setEntities(List entities) { setEntities(Ints.toArray(entities)); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityMetadata.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityMetadata.java index e8a70427..52c03d8c 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityMetadata.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerEntityMetadata.java @@ -27,32 +27,32 @@ import org.bukkit.entity.Entity; import java.util.List; public class WrapperPlayServerEntityMetadata extends AbstractPacket { - + public static final PacketType TYPE = PacketType.Play.Server.ENTITY_METADATA; - + public WrapperPlayServerEntityMetadata() { super(new PacketContainer(TYPE), TYPE); handle.getModifier().writeDefaults(); } - + public WrapperPlayServerEntityMetadata(PacketContainer packet) { super(packet, TYPE); } - + /** * Retrieve unique entity ID to update. */ public int getEntityID() { return handle.getIntegers().read(0); } - + /** * Set unique entity ID to update. */ public void setEntityID(int value) { handle.getIntegers().write(0, value); } - + /** * Retrieve the entity. */ @@ -76,12 +76,12 @@ public class WrapperPlayServerEntityMetadata extends AbstractPacket { public List getEntityMetadata() { return handle.getWatchableCollectionModifier().read(0); } - + /** * Set the list of the watchable objects (meta data). */ public void setEntityMetadata(List value) { handle.getWatchableCollectionModifier().write(0, value); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerMount.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerMount.java index 8075cdb7..5c0aa3b3 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerMount.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerMount.java @@ -23,25 +23,25 @@ import com.google.common.primitives.Ints; import java.util.List; public class WrapperPlayServerMount extends AbstractPacket { - + public static final PacketType TYPE = PacketType.Play.Server.MOUNT; - + public WrapperPlayServerMount() { super(new PacketContainer(TYPE), TYPE); handle.getModifier().writeDefaults(); } - + public WrapperPlayServerMount(PacketContainer packet) { super(packet, TYPE); } - + /** * Retrieve the entity ID being attached. */ public int getVehicleId() { return handle.getIntegers().read(0); } - + /** * Set the entity ID being attached. */ @@ -55,19 +55,19 @@ public class WrapperPlayServerMount extends AbstractPacket { public List getPassengers() { return Ints.asList(handle.getIntegerArrays().read(0)); } - + /** * Set the passenger entities. */ public void setPassengers(int[] entities) { handle.getIntegerArrays().write(0, entities); } - + /** * Set the passenger entities. */ public void setPassengers(List entities) { setPassengers(Ints.toArray(entities)); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntity.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntity.java index cf55a8d7..fa6965a4 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntity.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntity.java @@ -27,18 +27,18 @@ import org.bukkit.World; import org.bukkit.entity.Entity; public class WrapperPlayServerSpawnEntity extends AbstractPacket { - + public static final PacketType TYPE = PacketType.Play.Server.SPAWN_ENTITY; - + private static PacketConstructor entityConstructor; - + /** * Represents the different object types. * * @author Kristian */ public static class ObjectTypes extends IntEnum { - + public static final int BOAT = 1; public static final int ITEM_STACK = 2; public static final int MINECART = 10; @@ -67,29 +67,29 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket { * The singleton instance. Can also be retrieved from the parent class. */ private static final ObjectTypes INSTANCE = new ObjectTypes(); - + /** * Retrieve an instance of the object types enum. */ public static ObjectTypes getInstance() { return INSTANCE; } - + } - + public WrapperPlayServerSpawnEntity() { super(new PacketContainer(TYPE), TYPE); handle.getModifier().writeDefaults(); } - + public WrapperPlayServerSpawnEntity(PacketContainer packet) { super(packet, TYPE); } - + public WrapperPlayServerSpawnEntity(Entity entity, int type, int objectData) { super(fromEntity(entity, type, objectData), TYPE); } - + // Useful constructor private static PacketContainer fromEntity(Entity entity, int type, int objectData) { if (entityConstructor == null) { @@ -99,21 +99,21 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket { entityConstructor = ProtocolLibrary.getProtocolManager().createPacketConstructor(TYPE, entity, type, objectData); } } - + if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_14_R1)) { return entityConstructor.createPacket(entity, objectData); } else { return entityConstructor.createPacket(entity, type, objectData); } } - + /** * Retrieve entity ID of the Object. */ public int getEntityID() { return handle.getIntegers().read(0); } - + /** * Retrieve the entity that will be spawned. */ @@ -127,26 +127,26 @@ public class WrapperPlayServerSpawnEntity extends AbstractPacket { public Entity getEntity(PacketEvent event) { return getEntity(event.getPlayer().getWorld()); } - + /** * Set entity ID of the Object. */ public void setEntityID(int value) { handle.getIntegers().write(0, value); } - + /** * Retrieve the type of object. See {@link ObjectTypes} */ public int getType() { return handle.getIntegers().read(6); } - + /** * Set the type of object. See {@link ObjectTypes}. */ public void setType(int value) { handle.getIntegers().write(6, value); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntityLiving.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntityLiving.java index c2459d99..7d4cd4ba 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntityLiving.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/lib/packetwrapper/WrapperPlayServerSpawnEntityLiving.java @@ -27,24 +27,24 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket { - + public static final PacketType TYPE = PacketType.Play.Server.SPAWN_ENTITY_LIVING; - + private static PacketConstructor entityConstructor; - + public WrapperPlayServerSpawnEntityLiving() { super(new PacketContainer(TYPE), TYPE); handle.getModifier().writeDefaults(); } - + public WrapperPlayServerSpawnEntityLiving(PacketContainer packet) { super(packet, TYPE); } - + public WrapperPlayServerSpawnEntityLiving(Entity entity) { super(fromEntity(entity), TYPE); } - + // Useful constructor private static PacketContainer fromEntity(Entity entity) { if (entityConstructor == null) { @@ -52,14 +52,14 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket { } return entityConstructor.createPacket(entity); } - + /** * Retrieve entity ID. */ public int getEntityID() { return handle.getIntegers().read(0); } - + /** * Retrieve the entity that will be spawned. */ @@ -73,14 +73,14 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket { public Entity getEntity(PacketEvent event) { return getEntity(event.getPlayer().getWorld()); } - + /** * Set entity ID. */ public void setEntityID(int value) { handle.getIntegers().write(0, value); } - + /** * Retrieve the type of mob. */ @@ -88,7 +88,7 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket { public EntityType getType() { return EntityType.fromId(handle.getIntegers().read(1)); } - + /** * Set the type of mob. */ @@ -96,7 +96,7 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket { public void setType(EntityType value) { handle.getIntegers().write(1, (int) value.getTypeId()); } - + /** * Retrieve the data watcher. *

@@ -105,12 +105,12 @@ public class WrapperPlayServerSpawnEntityLiving extends AbstractPacket { public WrappedDataWatcher getMetadata() { return handle.getDataWatcherModifier().read(0); } - + /** * Set the data watcher. */ public void setMetadata(WrappedDataWatcher value) { handle.getDataWatcherModifier().write(0, value); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/InteractListener.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/InteractListener.java index 7ec07430..26dbb4d0 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/InteractListener.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/InteractListener.java @@ -18,24 +18,24 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEntityEvent; public class InteractListener implements Listener { - + private final NMSManager nmsManager; - + public InteractListener(NMSManager nmsManager) { this.nmsManager = nmsManager; } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSlimeInteract(PlayerInteractEntityEvent event) { if (event.getRightClicked().getType() != EntityType.SLIME) { return; } - + Player clicker = event.getPlayer(); if (clicker.getGameMode() == GameMode.SPECTATOR) { return; } - + NMSEntity entityBase = nmsManager.getNMSEntityBase(event.getRightClicked()); if (entityBase == null) { return; @@ -48,5 +48,5 @@ public class InteractListener implements Listener { ((StandardTouchableLine) line).onTouch(clicker); } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java index 65cd0482..45bb3ecc 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/listener/UpdateNotificationListener.java @@ -36,11 +36,11 @@ public class UpdateNotificationListener implements Listener { public void onJoin(PlayerJoinEvent event) { if (Configuration.updateNotification && newVersion != null) { Player player = event.getPlayer(); - + if (player.hasPermission(Permissions.UPDATE_NOTIFICATION)) { - player.sendMessage(Colors.PRIMARY_SHADOW + "[HolographicDisplays] " + player.sendMessage(Colors.PRIMARY_SHADOW + "[HolographicDisplays] " + Colors.PRIMARY + "Found an update: " + newVersion + ". Download:"); - player.sendMessage(Colors.PRIMARY_SHADOW + ">> " + player.sendMessage(Colors.PRIMARY_SHADOW + ">> " + Colors.PRIMARY + "https://dev.bukkit.org/projects/holographic-displays"); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/MessagePartJoiner.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/MessagePartJoiner.java index 976b9250..fff9a545 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/MessagePartJoiner.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/MessagePartJoiner.java @@ -62,7 +62,7 @@ class MessagePartJoiner { if (previousMessagePart == null) { return; } - + if (hasSentenceEnding(previousMessagePart)) { output.append(" "); this.appendedFirstSentenceSeparator = false; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/PrintableErrorCollector.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/PrintableErrorCollector.java index 480e9002..915cdfe4 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/PrintableErrorCollector.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/log/PrintableErrorCollector.java @@ -18,15 +18,15 @@ import java.util.ArrayList; import java.util.List; public class PrintableErrorCollector extends ErrorCollector { - + private static final String ERROR_PREFIX = ChatColor.RED + "[HolographicDisplays] "; - + public void logErrorCount() { Bukkit.getConsoleSender().sendMessage(ERROR_PREFIX + "Encountered " + getErrorsCount() + " error(s) on load. " + "Check previous console logs for more information."); } - + @Override public void logToConsole() { StringBuilder output = new StringBuilder(); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/StandardPlaceholder.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/StandardPlaceholder.java index 19289cab..e31dd112 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/StandardPlaceholder.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/StandardPlaceholder.java @@ -45,7 +45,7 @@ public abstract class StandardPlaceholder { /* * Below methods may use externally provided objects which can throw any exception */ - + protected abstract int doGetRefreshIntervalTicks() throws Throwable; protected abstract @Nullable String doGetReplacement(Player player, @Nullable String argument) throws Throwable; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/TickClock.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/TickClock.java index 54a36383..66452e92 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/TickClock.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/TickClock.java @@ -8,7 +8,7 @@ package me.filoghost.holographicdisplays.plugin.placeholder; public class TickClock { private long currentTick; - + public void incrementTick() { currentTick++; } @@ -16,5 +16,5 @@ public class TickClock { public long getCurrentTick() { return currentTick; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationPlaceholder.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationPlaceholder.java index fc7f6029..b491a93f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationPlaceholder.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationPlaceholder.java @@ -14,7 +14,7 @@ public class AnimationPlaceholder implements Placeholder { private final int refreshIntervalTicks; private final List frames; private int currentIndex; - + public AnimationPlaceholder(int refreshIntervalTicks, List frames) { this.frames = frames; this.refreshIntervalTicks = refreshIntervalTicks; @@ -24,7 +24,7 @@ public class AnimationPlaceholder implements Placeholder { public int getRefreshIntervalTicks() { return refreshIntervalTicks; } - + @Override public String getReplacement(String argument) { String result = frames.get(currentIndex); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationRegistry.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationRegistry.java index f04ac2d3..a30c5136 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationRegistry.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/AnimationRegistry.java @@ -22,9 +22,9 @@ import java.util.Map; import java.util.stream.Stream; public class AnimationRegistry implements PlaceholderFactory { - + private static final String SPEED_PREFIX = "speed:"; - + private final Map animationsByFilename = new HashMap<>(); public void loadAnimations(ConfigManager configManager, ErrorCollector errorCollector) throws IOException, ConfigSaveException { @@ -36,7 +36,7 @@ public class AnimationRegistry implements PlaceholderFactory { configManager.getExampleAnimationLoader().createDefault(); return; } - + try (Stream animationFiles = Files.list(animationFolder)) { animationFiles.forEach(file -> readAnimationFile(file, errorCollector)); } @@ -44,7 +44,7 @@ public class AnimationRegistry implements PlaceholderFactory { private void readAnimationFile(Path file, ErrorCollector errorCollector) { String fileName = file.getFileName().toString(); - + try { List lines = Files.readAllLines(file); if (lines.size() == 0) { @@ -68,14 +68,14 @@ public class AnimationRegistry implements PlaceholderFactory { } if (!validSpeedFound) { - errorCollector.add("could not find a valid \"" + SPEED_PREFIX + " \"" - + " in the first line of the file \"" + fileName + "\"," + errorCollector.add("could not find a valid \"" + SPEED_PREFIX + " \"" + + " in the first line of the file \"" + fileName + "\"," + " default speed of 0.5 seconds will be used"); } if (lines.isEmpty()) { lines.add("[No lines: " + fileName + "]"); - errorCollector.add("could not find any line in \"" + fileName + "\" (excluding the speed)," + errorCollector.add("could not find any line in \"" + fileName + "\" (excluding the speed)," + " you should add at least one more line"); } @@ -92,7 +92,7 @@ public class AnimationRegistry implements PlaceholderFactory { errorCollector.add(e, "couldn't load the animation file \"" + fileName + "\""); } } - + @Override public Placeholder getPlaceholder(String fileNameArgument) { Placeholder placeholder = animationsByFilename.get(fileNameArgument); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/DefaultPlaceholders.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/DefaultPlaceholders.java index 9ba0d059..a8fbadb5 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/DefaultPlaceholders.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/DefaultPlaceholders.java @@ -29,7 +29,7 @@ public class DefaultPlaceholders { BungeeServerTracker bungeeServerTracker) { HolographicDisplays plugin = HolographicDisplays.getInstance(); placeholderRegistry.unregisterAll(plugin); - + placeholderRegistry.registerGlobalPlaceholder(plugin, "rainbow", new AnimationPlaceholder(4, toStringList( ChatColor.RED, ChatColor.GOLD, @@ -106,7 +106,7 @@ public class DefaultPlaceholders { placeholderRegistry.registerIndividualPlaceholderReplacer(plugin, "player", Integer.MAX_VALUE, (player, argument) -> { return player.getName(); }); - + placeholderRegistry.registerIndividualPlaceholderReplacer(plugin, "displayName", 20, (player, argument) -> { return player.getDisplayName(); }); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/OnlinePlayersPlaceholderFactory.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/OnlinePlayersPlaceholderFactory.java index 75489359..9094ebbd 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/OnlinePlayersPlaceholderFactory.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/OnlinePlayersPlaceholderFactory.java @@ -26,12 +26,12 @@ public class OnlinePlayersPlaceholderFactory implements PlaceholderFactory { // No argument specified, return online players in this server return new LocalOnlinePlayersPlaceholder(); } - + String[] serverNames = Strings.splitAndTrim(argument, ","); return new BungeeOnlinePlayersPlaceholder(serverNames, bungeeServerTracker); } - - + + private static class LocalOnlinePlayersPlaceholder implements Placeholder { @Override diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/WorldPlayersPlaceholderFactory.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/WorldPlayersPlaceholderFactory.java index 549e1e12..2acd4b2f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/WorldPlayersPlaceholderFactory.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/internal/WorldPlayersPlaceholderFactory.java @@ -14,7 +14,7 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; public class WorldPlayersPlaceholderFactory implements PlaceholderFactory { - + @Override public Placeholder getPlaceholder(@Nullable String argument) { if (argument == null) { @@ -42,7 +42,7 @@ public class WorldPlayersPlaceholderFactory implements PlaceholderFactory { @Override public String getReplacement(@Nullable String argument) { int count = 0; - + for (String worldName : worldNames) { World world = Bukkit.getWorld(worldName); if (world == null) { @@ -55,7 +55,7 @@ public class WorldPlayersPlaceholderFactory implements PlaceholderFactory { } } } - + return String.valueOf(count); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderIdentifier.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderIdentifier.java index 0772bcee..b5a1b06f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderIdentifier.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderIdentifier.java @@ -10,7 +10,7 @@ import me.filoghost.fcommons.collection.CaseInsensitiveString; public class PlaceholderIdentifier { private final CaseInsensitiveString identifier; - + public PlaceholderIdentifier(String identifier) { this.identifier = new CaseInsensitiveString(identifier); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderOccurrence.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderOccurrence.java index d9f84999..8cd790d1 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderOccurrence.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderOccurrence.java @@ -12,11 +12,11 @@ import org.jetbrains.annotations.Nullable; import java.util.Objects; public class PlaceholderOccurrence { - + private final PluginName pluginName; private final PlaceholderIdentifier identifier; private final String argument; - + private final int hashCode; // Cached for performance reasons private PlaceholderOccurrence(PluginName pluginName, PlaceholderIdentifier identifier, String argument) { @@ -25,15 +25,15 @@ public class PlaceholderOccurrence { this.argument = argument; this.hashCode = Objects.hash(pluginName, identifier, argument); } - + public @Nullable PluginName getPluginName() { return pluginName; } - + public @NotNull PlaceholderIdentifier getIdentifier() { return identifier; } - + public @Nullable String getArgument() { return argument; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderReplaceFunction.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderReplaceFunction.java index 86feb115..6411b338 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderReplaceFunction.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PlaceholderReplaceFunction.java @@ -9,5 +9,5 @@ package me.filoghost.holographicdisplays.plugin.placeholder.parsing; public interface PlaceholderReplaceFunction { String getReplacement(PlaceholderOccurrence placeholderOccurrence); - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PluginName.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PluginName.java index b49dc6c8..8bb27236 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PluginName.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/PluginName.java @@ -37,7 +37,7 @@ public class PluginName { public final int hashCode() { return pluginName.hashCode(); } - + @Override public String toString() { return pluginName.toString(); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholders.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholders.java index 494837ab..07613492 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholders.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholders.java @@ -28,7 +28,7 @@ public class StringWithPlaceholders { this.string = string; this.stringParts = stringParts; } - + @Override public String toString() { return string; @@ -42,7 +42,7 @@ public class StringWithPlaceholders { if (stringParts == null) { return false; } - + for (StringPart stringPart : stringParts) { if (stringPart instanceof PlaceholderStringPart) { PlaceholderStringPart placeholderStringPart = (PlaceholderStringPart) stringPart; @@ -51,7 +51,7 @@ public class StringWithPlaceholders { } } } - + return false; } @@ -63,7 +63,7 @@ public class StringWithPlaceholders { StringBuilder output = new StringBuilder(); StringBuilder fullOutput = new StringBuilder(); List newStringParts = null; // Lazy initialization - + for (StringPart part : stringParts) { if (part instanceof PlaceholderStringPart) { PlaceholderStringPart placeholderStringPart = (PlaceholderStringPart) part; @@ -91,11 +91,11 @@ public class StringWithPlaceholders { fullOutput.append(literalStringPart.literalString); } } - + if (output.length() > 0 && newStringParts != null) { newStringParts.add(new LiteralStringPart(output.toString())); } - + return new StringWithPlaceholders(fullOutput.toString(), newStringParts); } @@ -103,15 +103,15 @@ public class StringWithPlaceholders { if (!containsPlaceholders()) { return string; } - + StringBuilder output = new StringBuilder(); for (StringPart part : stringParts) { output.append(part.getValue(replaceFunction)); } - + return output.toString(); } - + private @Nullable List splitToParts(String string) { int placeholderStartIndex = -1; int lastAppendIndex = 0; @@ -124,14 +124,14 @@ public class StringWithPlaceholders { // Inside placeholder if (currentChar == PLACEHOLDER_END_CHAR) { int endIndex = currentIndex + 1; - + // The unparsed string includes the opening and closing tags (e.g.: "{online: lobby}") String unparsedString = string.substring(placeholderStartIndex, endIndex); - + // The content string does NOT include the opening and closing tags (e.g.: "online: lobby") String contentString = unparsedString.substring(1, unparsedString.length() - 1); PlaceholderOccurrence content = PlaceholderOccurrence.parse(contentString); - + if (stringParts == null) { stringParts = new ArrayList<>(); } @@ -140,7 +140,7 @@ public class StringWithPlaceholders { if (placeholderStartIndex != lastAppendIndex) { stringParts.add(new LiteralStringPart(string.substring(lastAppendIndex, placeholderStartIndex))); } - + // Append placeholder part stringParts.add(new PlaceholderStringPart(content, unparsedString)); lastAppendIndex = endIndex; @@ -157,25 +157,25 @@ public class StringWithPlaceholders { } } } - + // Append trailing literal part (if any) if (lastAppendIndex != string.length() && stringParts != null) { stringParts.add(new LiteralStringPart(string.substring(lastAppendIndex))); } - + return stringParts; } - - + + private interface StringPart { - + String getValue(PlaceholderReplaceFunction placeholderReplaceFunction); - + } - - + + private static class LiteralStringPart implements StringPart { - + private final String literalString; LiteralStringPart(String literalString) { @@ -188,7 +188,7 @@ public class StringWithPlaceholders { } } - + private static class PlaceholderStringPart implements StringPart { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/GlobalPlaceholderExpansion.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/GlobalPlaceholderExpansion.java index 9f43e75b..f0c682db 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/GlobalPlaceholderExpansion.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/GlobalPlaceholderExpansion.java @@ -36,7 +36,7 @@ class GlobalPlaceholderExpansion extends PlaceholderExpansion { } catch (Throwable t) { throw new PlaceholderException(t, this); } - + if (placeholder != null) { return new GlobalStandardPlaceholder(placeholder, this); } else { @@ -44,26 +44,26 @@ class GlobalPlaceholderExpansion extends PlaceholderExpansion { } } - + private static class GlobalStandardPlaceholder extends StandardPlaceholder { - + private final @NotNull Placeholder placeholder; - + GlobalStandardPlaceholder(@NotNull Placeholder placeholder, @NotNull GlobalPlaceholderExpansion source) { super(source); this.placeholder = placeholder; } - + @Override protected int doGetRefreshIntervalTicks() { return placeholder.getRefreshIntervalTicks(); } - + @Override protected @Nullable String doGetReplacement(Player player, @Nullable String argument) { return placeholder.getReplacement(argument); } - + } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/IndividualPlaceholderExpansion.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/IndividualPlaceholderExpansion.java index 16182bbc..e01bdf33 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/IndividualPlaceholderExpansion.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/IndividualPlaceholderExpansion.java @@ -36,7 +36,7 @@ class IndividualPlaceholderExpansion extends PlaceholderExpansion { } catch (Throwable t) { throw new PlaceholderException(t, this); } - + if (placeholder != null) { return new IndividualStandardPlaceholder(placeholder, this); } else { @@ -44,26 +44,26 @@ class IndividualPlaceholderExpansion extends PlaceholderExpansion { } } - + private static class IndividualStandardPlaceholder extends StandardPlaceholder { - + private final @NotNull IndividualPlaceholder placeholder; - + IndividualStandardPlaceholder(@NotNull IndividualPlaceholder placeholder, @NotNull IndividualPlaceholderExpansion source) { super(source); this.placeholder = placeholder; } - + @Override protected int doGetRefreshIntervalTicks() { return placeholder.getRefreshIntervalTicks(); } - + @Override protected @Nullable String doGetReplacement(Player player, @Nullable String argument) { return placeholder.getReplacement(player, argument); } - + } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderExpansion.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderExpansion.java index 8c78296a..2d407d47 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderExpansion.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderExpansion.java @@ -13,15 +13,15 @@ import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.Nullable; public abstract class PlaceholderExpansion { - + private final PluginName pluginName; private final PlaceholderIdentifier identifier; - + public PlaceholderExpansion(Plugin plugin, String identifier) { this.pluginName = new PluginName(plugin); this.identifier = new PlaceholderIdentifier(identifier); } - + public PluginName getPluginName() { return pluginName; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderRegistry.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderRegistry.java index c1a7d574..429ec7be 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderRegistry.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/registry/PlaceholderRegistry.java @@ -24,10 +24,10 @@ import java.util.ArrayList; import java.util.List; public class PlaceholderRegistry { - + private final Table placeholderExpansions; private Runnable changeListener; - + public PlaceholderRegistry() { this.placeholderExpansions = HashBasedTable.create(); } @@ -39,7 +39,7 @@ public class PlaceholderRegistry { public void registerIndividualPlaceholderReplacer(Plugin plugin, String identifier, int refreshIntervalTicks, IndividualPlaceholderReplacer placeholderReplacer) { registerIndividualPlaceholder(plugin, identifier, new SimpleIndividualPlaceholder(refreshIntervalTicks, placeholderReplacer)); } - + public void registerIndividualPlaceholder(Plugin plugin, String identifier, IndividualPlaceholder placeholder) { registerIndividualPlaceholderFactory(plugin, identifier, (String argument) -> placeholder); } @@ -52,38 +52,38 @@ public class PlaceholderRegistry { public void registerGlobalPlaceholderReplacer(Plugin plugin, String identifier, int refreshIntervalTicks, PlaceholderReplacer placeholderReplacer) { registerGlobalPlaceholder(plugin, identifier, new SimpleGlobalPlaceholder(refreshIntervalTicks, placeholderReplacer)); } - + public void registerGlobalPlaceholder(Plugin plugin, String identifier, Placeholder placeholder) { registerGlobalPlaceholderFactory(plugin, identifier, (String argument) -> placeholder); } - + public void registerGlobalPlaceholderFactory(Plugin plugin, String identifier, PlaceholderFactory factory) { PlaceholderExpansion expansion = new GlobalPlaceholderExpansion(plugin, identifier, factory); registerExpansion(expansion); } - + private void registerExpansion(PlaceholderExpansion expansion) { placeholderExpansions.put(expansion.getIdentifier(), expansion.getPluginName(), expansion); changeListener.run(); } - + public void unregisterAll(Plugin plugin) { placeholderExpansions.column(new PluginName(plugin)).clear(); - + changeListener.run(); } public void unregister(Plugin plugin, String identifier) { placeholderExpansions.remove(new PlaceholderIdentifier(identifier), new PluginName(plugin)); - + changeListener.run(); } - + public @Nullable PlaceholderExpansion find(PlaceholderOccurrence textOccurrence) { PluginName pluginName = textOccurrence.getPluginName(); PlaceholderIdentifier identifier = textOccurrence.getIdentifier(); - + if (pluginName != null) { // Find exact entry if plugin name is specified return placeholderExpansions.get(identifier, pluginName); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderExceptionHandler.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderExceptionHandler.java index c515f6d7..6466e3da 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderExceptionHandler.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderExceptionHandler.java @@ -22,16 +22,16 @@ class PlaceholderExceptionHandler { this.tickClock = tickClock; this.lastErrorLogByPlaceholderExpansion = new WeakHashMap<>(); } - + void handle(PlaceholderException exception) { PlaceholderExpansion placeholderExpansion = exception.getPlaceholderExpansion(); Long lastErrorLog = lastErrorLogByPlaceholderExpansion.get(placeholderExpansion); long currentTick = tickClock.getCurrentTick(); - + if (lastErrorLog != null && currentTick - lastErrorLog < 20) { return; // Avoid spamming the console too frequently } - + lastErrorLogByPlaceholderExpansion.put(placeholderExpansion, currentTick); Log.warning("The placeholder \"" + placeholderExpansion.getIdentifier() + "\"" diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderTracker.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderTracker.java index 4f8bf1a3..f275996a 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderTracker.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/PlaceholderTracker.java @@ -56,7 +56,7 @@ public class PlaceholderTracker { public @Nullable String updateAndGetIndividualReplacement(PlaceholderOccurrence placeholderOccurrence, Player player) { return updateAndGetReplacement(placeholderOccurrence, player, true); } - + private @Nullable String updateAndGetReplacement(PlaceholderOccurrence placeholderOccurrence, Player player, boolean individual) { try { TrackedPlaceholder trackedPlaceholder = getTrackedPlaceholder(placeholderOccurrence); @@ -85,13 +85,13 @@ public class PlaceholderTracker { private TrackedPlaceholder createTrackedPlaceholder(PlaceholderOccurrence placeholderOccurrence) throws PlaceholderException { PlaceholderExpansion placeholderExpansion = registry.find(placeholderOccurrence); StandardPlaceholder placeholder; - + if (placeholderExpansion != null) { placeholder = placeholderExpansion.createPlaceholder(placeholderOccurrence.getArgument()); } else { placeholder = null; } - + if (placeholder == null) { return new TrackedNullPlaceholder(placeholderExpansion); } else if (placeholder.isIndividual()) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedGlobalPlaceholder.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedGlobalPlaceholder.java index 43accd24..9b278351 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedGlobalPlaceholder.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedGlobalPlaceholder.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; class TrackedGlobalPlaceholder extends TrackedPlaceholder { - + private final ReplacementHolder replacementHolder; TrackedGlobalPlaceholder(@NotNull StandardPlaceholder placeholder, @NotNull PlaceholderOccurrence placeholderOccurrence) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedPlaceholder.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedPlaceholder.java index faa32d34..e6b0d176 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedPlaceholder.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/placeholder/tracking/TrackedPlaceholder.java @@ -11,7 +11,7 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; abstract class TrackedPlaceholder { - + private final @Nullable PlaceholderExpansion source; TrackedPlaceholder(@Nullable PlaceholderExpansion source) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/FileUtils.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/FileUtils.java index 2c9e6cb6..7e08d680 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/FileUtils.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/FileUtils.java @@ -9,7 +9,7 @@ import java.nio.file.Path; public class FileUtils { - + public static String getExtension(String fileName) { int lastFullStop = fileName.lastIndexOf('.'); if (lastFullStop >= 0) { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/NMSVersion.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/NMSVersion.java index 4ed3c34e..4a944f5f 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/NMSVersion.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/NMSVersion.java @@ -17,7 +17,7 @@ import java.util.regex.Pattern; * The NMS version is the name of the main package under net.minecraft.server, for example "v1_13_R2". */ public enum NMSVersion { - + // Not using shorter method reference syntax here because it initializes the class, causing a ClassNotFoundException v1_8_R2(packetSettings -> new me.filoghost.holographicdisplays.nms.v1_8_R2.VersionNMSManager(packetSettings)), v1_8_R3(packetSettings -> new me.filoghost.holographicdisplays.nms.v1_8_R3.VersionNMSManager(packetSettings)), @@ -33,9 +33,9 @@ public enum NMSVersion { v1_16_R1(packetSettings -> new me.filoghost.holographicdisplays.nms.v1_16_R1.VersionNMSManager(packetSettings)), v1_16_R2(packetSettings -> new me.filoghost.holographicdisplays.nms.v1_16_R2.VersionNMSManager(packetSettings)), v1_16_R3(packetSettings -> new me.filoghost.holographicdisplays.nms.v1_16_R3.VersionNMSManager(packetSettings)); - + private static final NMSVersion CURRENT_VERSION = extractCurrentVersion(); - + private final NMSManagerConstructor nmsManagerConstructor; NMSVersion(NMSManagerConstructor nmsManagerConstructor) { @@ -59,7 +59,7 @@ public enum NMSVersion { return null; // Unknown version } } - + public static boolean isValid() { return CURRENT_VERSION != null; } @@ -77,7 +77,7 @@ public enum NMSVersion { private interface NMSManagerConstructor { NMSManager create(ProtocolPacketSettings protocolPacketSettings); - + } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/VersionUtils.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/VersionUtils.java index 04d4a598..31a00e01 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/VersionUtils.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/util/VersionUtils.java @@ -19,21 +19,21 @@ public class VersionUtils { private static int compare(String version1, String version2) throws NumberFormatException { String[] version1Split = Strings.split(version1, "."); String[] version2Split = Strings.split(version2, "."); - + int longest = Math.max(version1Split.length, version2Split.length); - + // Default value is 0 (for elements not explicitly set) int[] version1NumbersArray = new int[longest]; int[] version2NumbersArray = new int[longest]; - + for (int i = 0; i < version1Split.length; i++) { version1NumbersArray[i] = Integer.parseInt(version1Split[i]); } - + for (int i = 0; i < version2Split.length; i++) { version2NumbersArray[i] = Integer.parseInt(version2Split[i]); } - + for (int i = 0; i < longest; i++) { int diff = version1NumbersArray[i] - version2NumbersArray[i]; if (diff > 0) { @@ -42,8 +42,8 @@ public class VersionUtils { return -1; } } - + return 0; } - + } diff --git a/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java b/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java index 08ea643b..64ed9458 100644 --- a/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java +++ b/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java @@ -29,7 +29,7 @@ class V2TouchableLineAdapterTest { newLine.setTouchHandler(newTouchHandler); v2Line.setTouchHandler(null); - + assertThat(v2Line.getTouchHandler()).isNull(); assertThat(newLine.getTouchHandler()).isNull(); } @@ -39,7 +39,7 @@ class V2TouchableLineAdapterTest { APITextLine newLine = new APITextLine(hologram, ""); TextLine v2Line = newLine.getV2Adapter(); ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); - + v2Line.setTouchHandler(v2TouchHandler); newLine.setTouchHandler(null); @@ -53,7 +53,7 @@ class V2TouchableLineAdapterTest { ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); v2Line.setTouchHandler(v2TouchHandler); - + assertThat(v2Line.getTouchHandler()).isSameAs(v2TouchHandler); } @@ -62,9 +62,9 @@ class V2TouchableLineAdapterTest { APITextLine newLine = new APITextLine(hologram, ""); TextLine v2Line = newLine.getV2Adapter(); ExampleNewTouchHandler newTouchHandler = new ExampleNewTouchHandler(); - + newLine.setTouchHandler(newTouchHandler); - + assertThat(v2Line.getTouchHandler()).isNotNull(); } @@ -96,12 +96,12 @@ class V2TouchableLineAdapterTest { APITextLine newLine = new APITextLine(hologram, ""); TextLine v2Line = newLine.getV2Adapter(); ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); - + v2Line.setTouchHandler(v2TouchHandler); TouchHandler newTouchHandlerA = newLine.getTouchHandler(); v2Line.setTouchHandler(v2TouchHandler); TouchHandler newTouchHandlerB = newLine.getTouchHandler(); - + assertThat(newTouchHandlerA).isSameAs(newTouchHandlerB); } @@ -128,7 +128,7 @@ class V2TouchableLineAdapterTest { com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandlerA = v2Line.getTouchHandler(); newLine.setTouchHandler(new ExampleNewTouchHandler()); com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandlerB = v2Line.getTouchHandler(); - + assertThat(v2TouchHandlerA).isNotSameAs(v2TouchHandlerB); } @@ -150,9 +150,9 @@ class V2TouchableLineAdapterTest { APITextLine newLine = new APITextLine(hologram, ""); TextLine v2Line = newLine.getV2Adapter(); ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); - + v2Line.setTouchHandler(v2TouchHandler); - + TouchHandler newTouchHandler = newLine.getTouchHandler(); v2Line.setTouchHandler(null); // This also clears the adapter newLine.setTouchHandler(newTouchHandler); // Return to the initial value @@ -167,9 +167,9 @@ class V2TouchableLineAdapterTest { APITextLine newLine = new APITextLine(hologram, ""); TextLine v2Line = newLine.getV2Adapter(); ExampleNewTouchHandler newTouchHandler = new ExampleNewTouchHandler(); - + newLine.setTouchHandler(newTouchHandler); - + com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandler = v2Line.getTouchHandler(); v2Line.setTouchHandler(null); // This also clears the adapter v2Line.setTouchHandler(v2TouchHandler); // Return to the initial value @@ -186,8 +186,8 @@ class V2TouchableLineAdapterTest { public void onTouch(@NotNull Player player) {} } - - + + private static class ExampleV2TouchHandler implements com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler { @Override diff --git a/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholdersTest.java b/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholdersTest.java index de0d50fa..c8baf047 100644 --- a/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholdersTest.java +++ b/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/placeholder/parsing/StringWithPlaceholdersTest.java @@ -23,11 +23,11 @@ class StringWithPlaceholdersTest { void replacements(String input, String expectedOutput) { boolean expectedContainsPlaceholders = expectedOutput.contains("#"); StringWithPlaceholders s = new StringWithPlaceholders(input); - + assertThat(s.replacePlaceholders(occurrence -> "#")).isEqualTo(expectedOutput); assertThat(s.containsPlaceholders()).isEqualTo(expectedContainsPlaceholders); } - + static Stream replacementsTestArguments() { return Stream.of( Arguments.of("", ""), @@ -40,7 +40,7 @@ class StringWithPlaceholdersTest { Arguments.of("abc p}", "abc p}") // Placeholder without opening tag ); } - + @Test void skipReplacing() { String input = "{p} a {p} b {p}"; @@ -52,16 +52,16 @@ class StringWithPlaceholdersTest { @MethodSource("parsingTestArguments") void parsing(String input, String expectedPluginName, String expectedIdentifier, String expectedArgument) { StringWithPlaceholders s = new StringWithPlaceholders(input); - + List placeholders = new ArrayList<>(); s.replacePlaceholders(occurrence -> { placeholders.add(occurrence); // Just save occurrences return null; }); assertThat(placeholders).hasSize(1); - + PlaceholderOccurrence placeholder = placeholders.get(0); - + if (expectedPluginName != null) { assertThat(placeholder.getPluginName()).hasToString(expectedPluginName); } else { diff --git a/pom.xml b/pom.xml index 9ec47749..75cd6d66 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ plugin example - + spigot-repo @@ -51,18 +51,18 @@ nms-repo https://repo.codemc.io/repository/nms/ - + dmulloy2-repo https://repo.dmulloy2.net/repository/public/ - + placeholderapi-repo https://repo.extendedclip.com/content/repositories/placeholderapi/ - + @@ -70,13 +70,13 @@ holographicdisplays-api ${project.version} - + ${project.groupId} holographicdisplays-common ${project.version} - + ${project.groupId} holographicdisplays-legacy-api-v1 @@ -88,79 +88,79 @@ holographicdisplays-legacy-api-v2 ${project.version} - + ${project.groupId} holographicdisplays-config ${project.version} - + ${project.groupId} holographicdisplays-nms-interfaces ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_8_r2 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_8_r3 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_9_r1 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_9_r2 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_10_r1 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_11_r1 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_12_r1 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_13_r1 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_13_r2 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_14_r1 ${project.version} - + ${project.groupId} holographicdisplays-nms-v1_15_r1 @@ -184,7 +184,7 @@ holographicdisplays-nms-v1_16_r3 ${project.version} - + org.spigotmc spigot-api @@ -197,7 +197,7 @@ - + com.comphenix.protocol ProtocolLib @@ -211,13 +211,13 @@ 2.8.1 provided - + org.bstats bstats-bukkit-lite 1.7 - + me.filoghost.updatechecker updatechecker @@ -264,7 +264,7 @@ clean package - + @@ -280,7 +280,7 @@ - + org.apache.maven.plugins maven-javadoc-plugin @@ -300,13 +300,13 @@ build-helper-maven-plugin 3.2.0 - + org.apache.maven.plugins maven-shade-plugin 3.2.3 - + org.apache.maven.plugins maven-enforcer-plugin @@ -318,7 +318,7 @@ directory-maven-plugin 0.3.1 - + org.apache.maven.plugins maven-checkstyle-plugin @@ -332,7 +332,7 @@ - + org.apache.maven.plugins