From dbfabc0e83ad48c8eae4dd839ba36c4d5ca3f463 Mon Sep 17 00:00:00 2001 From: filoghost Date: Sat, 27 Feb 2021 19:03:21 +0100 Subject: [PATCH] Refactor hologram-related objects, move some to "core" module --- .../holographicdisplays/core/DebugLogger.java | 6 +- .../core/nms/ItemPickupManager.java | 15 --- .../core/nms/NMSManager.java | 10 +- .../core/nms/entity/NMSEntityBase.java | 6 +- .../core}/object/base/BaseHologram.java | 95 +++++-------------- .../core}/object/base/BaseHologramLine.java | 8 +- .../core}/object/base/BaseItemLine.java | 52 ++++++---- .../core}/object/base/BaseTouchableLine.java | 35 +++++-- .../core/object/base}/HologramComponent.java | 2 +- .../object/base/SpawnableHologramLine.java | 5 +- .../nms/v1_10_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_10_R1/EntityNMSItem.java | 23 ++--- .../nms/v1_10_R1/EntityNMSSlime.java | 14 +-- .../nms/v1_10_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_11_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_11_R1/EntityNMSItem.java | 21 ++-- .../nms/v1_11_R1/EntityNMSSlime.java | 8 +- .../nms/v1_11_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_12_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_12_R1/EntityNMSItem.java | 21 ++-- .../nms/v1_12_R1/EntityNMSSlime.java | 8 +- .../nms/v1_12_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_13_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_13_R1/EntityNMSItem.java | 21 ++-- .../nms/v1_13_R1/EntityNMSSlime.java | 8 +- .../nms/v1_13_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_13_R2/EntityNMSArmorStand.java | 8 +- .../nms/v1_13_R2/EntityNMSItem.java | 21 ++-- .../nms/v1_13_R2/EntityNMSSlime.java | 8 +- .../nms/v1_13_R2/VersionNMSManager.java | 17 ++-- .../nms/v1_14_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_14_R1/EntityNMSItem.java | 21 ++-- .../nms/v1_14_R1/EntityNMSSlime.java | 8 +- .../nms/v1_14_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_15_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_15_R1/EntityNMSItem.java | 21 ++-- .../nms/v1_15_R1/EntityNMSSlime.java | 8 +- .../nms/v1_15_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_16_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_16_R1/EntityNMSItem.java | 21 ++-- .../nms/v1_16_R1/EntityNMSSlime.java | 8 +- .../nms/v1_16_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_16_R2/EntityNMSArmorStand.java | 8 +- .../nms/v1_16_R2/EntityNMSItem.java | 21 ++-- .../nms/v1_16_R2/EntityNMSSlime.java | 8 +- .../nms/v1_16_R2/VersionNMSManager.java | 17 ++-- .../nms/v1_16_R3/EntityNMSArmorStand.java | 8 +- .../nms/v1_16_R3/EntityNMSItem.java | 21 ++-- .../nms/v1_16_R3/EntityNMSSlime.java | 12 +-- .../nms/v1_16_R3/VersionNMSManager.java | 17 ++-- .../nms/v1_8_R2/EntityNMSArmorStand.java | 8 +- .../nms/v1_8_R2/EntityNMSItem.java | 17 ++-- .../nms/v1_8_R2/EntityNMSSlime.java | 8 +- .../nms/v1_8_R2/VersionNMSManager.java | 17 ++-- .../nms/v1_8_R3/EntityNMSArmorStand.java | 8 +- .../nms/v1_8_R3/EntityNMSItem.java | 21 ++-- .../nms/v1_8_R3/EntityNMSSlime.java | 8 +- .../nms/v1_8_R3/VersionNMSManager.java | 17 ++-- .../nms/v1_9_R1/EntityNMSArmorStand.java | 8 +- .../nms/v1_9_R1/EntityNMSItem.java | 23 ++--- .../nms/v1_9_R1/EntityNMSSlime.java | 8 +- .../nms/v1_9_R1/VersionNMSManager.java | 17 ++-- .../nms/v1_9_R2/EntityNMSArmorStand.java | 8 +- .../nms/v1_9_R2/EntityNMSItem.java | 23 ++--- .../nms/v1_9_R2/EntityNMSSlime.java | 8 +- .../nms/v1_9_R2/VersionNMSManager.java | 17 ++-- .../HolographicDisplays.java | 30 ++---- .../bridge/protocollib/PacketListener.java | 14 +-- .../bridge/protocollib/PacketSender.java | 8 +- .../bridge/protocollib/ProtocolLibHook.java | 2 +- .../commands/subs/CreateCommand.java | 13 ++- .../commands/subs/DebugCommand.java | 42 +++----- .../listener/ChunkListener.java | 3 +- .../listener/MainListener.java | 27 +----- .../object/api/APIHologram.java | 91 ++++++++++++++++-- .../object/api/APIHologramLine.java | 13 +++ .../object/api/APIItemLine.java | 22 +++++ .../object/api/APITextLine.java | 21 ++++ .../object/base/BaseHologramManager.java | 1 + .../object/base/BaseTextLine.java | 11 ++- .../object/base/DefaultVisibilityManager.java | 1 + .../object/internal/InternalHologram.java | 64 ++++++------- .../object/internal/InternalHologramLine.java | 2 +- .../object/internal/InternalItemLine.java | 4 +- .../object/internal/InternalTextLine.java | 2 +- .../holographicdisplays/util/NMSVersion.java | 7 +- 86 files changed, 667 insertions(+), 713 deletions(-) delete mode 100644 core/src/main/java/me/filoghost/holographicdisplays/core/nms/ItemPickupManager.java rename {plugin/src/main/java/me/filoghost/holographicdisplays => core/src/main/java/me/filoghost/holographicdisplays/core}/object/base/BaseHologram.java (63%) rename {plugin/src/main/java/me/filoghost/holographicdisplays => core/src/main/java/me/filoghost/holographicdisplays/core}/object/base/BaseHologramLine.java (91%) rename {plugin/src/main/java/me/filoghost/holographicdisplays => core/src/main/java/me/filoghost/holographicdisplays/core}/object/base/BaseItemLine.java (81%) rename {plugin/src/main/java/me/filoghost/holographicdisplays => core/src/main/java/me/filoghost/holographicdisplays/core}/object/base/BaseTouchableLine.java (83%) rename {plugin/src/main/java/me/filoghost/holographicdisplays/object => core/src/main/java/me/filoghost/holographicdisplays/core/object/base}/HologramComponent.java (96%) rename {plugin/src/main/java/me/filoghost/holographicdisplays => core/src/main/java/me/filoghost/holographicdisplays/core}/object/base/SpawnableHologramLine.java (64%) create mode 100644 plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologramLine.java create mode 100644 plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIItemLine.java create mode 100644 plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APITextLine.java diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/DebugLogger.java b/core/src/main/java/me/filoghost/holographicdisplays/core/DebugLogger.java index 6f24ed0c..bb238ef0 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/DebugLogger.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/DebugLogger.java @@ -6,7 +6,7 @@ package me.filoghost.holographicdisplays.core; import me.filoghost.fcommons.logging.Log; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; public class DebugLogger { @@ -47,8 +47,8 @@ public class DebugLogger { } } - public static void handleSpawnFail(HologramLine parentPiece) { - warning("Couldn't spawn entity for this hologram: " + parentPiece.getParent().toString()); + public static void handleSpawnFail(BaseHologramLine parentPiece) { + warning("Couldn't spawn entity for this hologram: " + parentPiece.getBaseParent().toString()); } public static void cannotSetPassenger(Throwable t) { diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/nms/ItemPickupManager.java b/core/src/main/java/me/filoghost/holographicdisplays/core/nms/ItemPickupManager.java deleted file mode 100644 index 6491d3eb..00000000 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/nms/ItemPickupManager.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) filoghost and contributors - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ -package me.filoghost.holographicdisplays.core.nms; - -import me.filoghost.holographicdisplays.api.line.ItemLine; -import org.bukkit.entity.Player; - -public interface ItemPickupManager { - - void handleItemLinePickup(Player player, ItemLine itemLine); - -} diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/nms/NMSManager.java b/core/src/main/java/me/filoghost/holographicdisplays/core/nms/NMSManager.java index ee64432f..0e1e28c2 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/nms/NMSManager.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/nms/NMSManager.java @@ -5,12 +5,12 @@ */ package me.filoghost.holographicdisplays.core.nms; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import org.bukkit.inventory.ItemStack; public interface NMSManager { @@ -18,11 +18,11 @@ public interface NMSManager { // A method to register all the custom entities of the plugin, it may fail. void setup() throws Exception; - NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece); + NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece); - NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack); + NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack); - NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece); + NMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z,BaseHologramLine parentPiece); boolean isNMSEntityBase(org.bukkit.entity.Entity bukkitEntity); diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/nms/entity/NMSEntityBase.java b/core/src/main/java/me/filoghost/holographicdisplays/core/nms/entity/NMSEntityBase.java index 57e35f46..f280aa84 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/nms/entity/NMSEntityBase.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/nms/entity/NMSEntityBase.java @@ -5,15 +5,15 @@ */ package me.filoghost.holographicdisplays.core.nms.entity; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; /** * An interface to represent a custom NMS entity being part of a hologram. */ public interface NMSEntityBase { - // Returns the linked CraftHologramLine, all the entities are part of a piece. Should never be null. - HologramLine getHologramLine(); + // Returns the linked line, all the entities are part of a piece. Should never be null. + BaseHologramLine getHologramLine(); // Sets the location through NMS. void setLocationNMS(double x, double y, double z); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologram.java b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseHologram.java similarity index 63% rename from plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologram.java rename to core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseHologram.java index f67e7bf5..837599b3 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologram.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseHologram.java @@ -3,41 +3,41 @@ * * SPDX-License-Identifier: GPL-3.0-or-later */ -package me.filoghost.holographicdisplays.object.base; +package me.filoghost.holographicdisplays.core.object.base; import me.filoghost.fcommons.Preconditions; -import me.filoghost.holographicdisplays.api.Hologram; -import me.filoghost.holographicdisplays.api.VisibilityManager; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.disk.Configuration; import me.filoghost.holographicdisplays.core.nms.NMSManager; -import me.filoghost.holographicdisplays.object.HologramComponent; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import java.util.List; -public abstract class BaseHologram extends HologramComponent implements Hologram { +public abstract class BaseHologram extends HologramComponent { private final NMSManager nmsManager; - private final VisibilityManager visibilityManager; - private final long creationTimestamp; - - private boolean allowPlaceholders; + private boolean deleted; public BaseHologram(Location location, NMSManager nmsManager) { Preconditions.notNull(location, "location"); this.setLocation(location); this.nmsManager = nmsManager; - this.visibilityManager = new DefaultVisibilityManager(this); - this.creationTimestamp = System.currentTimeMillis(); - this.allowPlaceholders = false; } + public abstract Plugin getOwner(); + public abstract List getLinesUnsafe(); - @Override + public abstract boolean isAllowPlaceholders(); + + public abstract boolean isVisibleTo(Player player); + + protected abstract double getSpaceBetweenLines(); + + public abstract String toFormattedString(); + public boolean isDeleted() { return deleted; } @@ -49,36 +49,10 @@ public abstract class BaseHologram extends HologramComponent implements Hologram } } - @Override - public long getCreationTimestamp() { - return creationTimestamp; - } - - @Override - public void setAllowPlaceholders(boolean allowPlaceholders) { - if (this.allowPlaceholders == allowPlaceholders) { - return; - } - - this.allowPlaceholders = allowPlaceholders; - refresh(true); - } - - @Override - public boolean isAllowPlaceholders() { - return allowPlaceholders; - } - public NMSManager getNMSManager() { return nmsManager; } - - @Override - public HologramLine getLine(int index) { - return getLinesUnsafe().get(index); - } - - @Override + public void removeLine(int index) { checkState(); @@ -86,15 +60,14 @@ public abstract class BaseHologram extends HologramComponent implements Hologram refresh(); } - public void removeLine(SpawnableHologramLine line) { + public void removeLine(BaseHologramLine line) { checkState(); getLinesUnsafe().remove(line); line.despawn(); refresh(); } - - @Override + public void clearLines() { for (SpawnableHologramLine line : getLinesUnsafe()) { line.despawn(); @@ -102,19 +75,16 @@ public abstract class BaseHologram extends HologramComponent implements Hologram getLinesUnsafe().clear(); } - - @Override + public int size() { return getLinesUnsafe().size(); } - - @Override + public void teleport(Location location) { Preconditions.notNull(location, "location"); teleport(location.getWorld(), location.getX(), location.getY(), location.getZ()); } - - @Override + public void teleport(World world, double x, double y, double z) { checkState(); Preconditions.notNull(world, "world"); @@ -141,22 +111,6 @@ public abstract class BaseHologram extends HologramComponent implements Hologram } } - @Override - public double getHeight() { - if (getLinesUnsafe().isEmpty()) { - return 0; - } - - double height = 0.0; - - for (SpawnableHologramLine line : getLinesUnsafe()) { - height += line.getHeight(); - } - - height += Configuration.spaceBetweenLines * (getLinesUnsafe().size() - 1); - return height; - } - /* * When spawning at a location, the top part of the first line should be exactly on that location. * The second line is below the first, and so on. @@ -169,7 +123,7 @@ public abstract class BaseHologram extends HologramComponent implements Hologram currentLineY -= line.getHeight(); if (i > 0) { - currentLineY -= Configuration.spaceBetweenLines; + currentLineY -= getSpaceBetweenLines(); } if (forceRespawn) { @@ -185,11 +139,6 @@ public abstract class BaseHologram extends HologramComponent implements Hologram } } - @Override - public VisibilityManager getVisibilityManager() { - return visibilityManager; - } - protected void checkState() { Preconditions.checkState(!deleted, "hologram already deleted"); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologramLine.java b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseHologramLine.java similarity index 91% rename from plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologramLine.java rename to core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseHologramLine.java index 724d5c17..b6bb6c67 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologramLine.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseHologramLine.java @@ -3,11 +3,10 @@ * * SPDX-License-Identifier: GPL-3.0-or-later */ -package me.filoghost.holographicdisplays.object.base; +package me.filoghost.holographicdisplays.core.object.base; import me.filoghost.fcommons.Preconditions; import me.filoghost.holographicdisplays.core.nms.NMSManager; -import me.filoghost.holographicdisplays.object.HologramComponent; import org.bukkit.World; public abstract class BaseHologramLine extends HologramComponent implements SpawnableHologramLine { @@ -21,15 +20,14 @@ public abstract class BaseHologramLine extends HologramComponent implements Spaw this.parent = parent; } - public final BaseHologram getParent() { + public final BaseHologram getBaseParent() { return parent; } protected final NMSManager getNMSManager() { return parent.getNMSManager(); } - - @Override + public final void removeLine() { parent.removeLine(this); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseItemLine.java b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseItemLine.java similarity index 81% rename from plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseItemLine.java rename to core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseItemLine.java index daa9eef7..0dd2e658 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseItemLine.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseItemLine.java @@ -3,37 +3,57 @@ * * SPDX-License-Identifier: GPL-3.0-or-later */ -package me.filoghost.holographicdisplays.object.base; +package me.filoghost.holographicdisplays.core.object.base; import me.filoghost.fcommons.Preconditions; +import me.filoghost.fcommons.logging.Log; import me.filoghost.holographicdisplays.api.handler.PickupHandler; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; import org.bukkit.World; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.Collection; -public class BaseItemLine extends BaseTouchableLine implements ItemLine { +public abstract class BaseItemLine extends BaseTouchableLine { private ItemStack itemStack; - private PickupHandler pickupHandler; - + private NMSItem itemEntity; private NMSArmorStand vehicleEntity; - + private PickupHandler pickupHandler; + public BaseItemLine(BaseHologram parent, ItemStack itemStack) { super(parent); setItemStack(itemStack); } - @Override + public void onPickup(Player player) { + if (pickupHandler == null || !getBaseParent().isVisibleTo(player)) { + return; + } + + try { + pickupHandler.onPickup(player); + } catch (Throwable t) { + Log.warning("The plugin " + getBaseParent().getOwner().getName() + " generated an exception" + + " when the player " + player.getName() + " picked up an item from a hologram.", t); + } + } + + public PickupHandler getPickupHandler() { + return pickupHandler; + } + + public void setPickupHandler(PickupHandler pickupHandler) { + this.pickupHandler = pickupHandler; + } + public ItemStack getItemStack() { return itemStack; } - - @Override + public void setItemStack(ItemStack itemStack) { Preconditions.notNull(itemStack, "itemStack"); Preconditions.checkArgument(0 < itemStack.getAmount() && itemStack.getAmount() <= 64, "Item must have amount between 1 and 64"); @@ -44,16 +64,6 @@ public class BaseItemLine extends BaseTouchableLine implements ItemLine { } } - @Override - public PickupHandler getPickupHandler() { - return pickupHandler; - } - - @Override - public void setPickupHandler(PickupHandler pickupHandler) { - this.pickupHandler = pickupHandler; - } - @Override public void spawnEntities(World world, double x, double y, double z) { super.spawnEntities(world, x, y, z); @@ -124,7 +134,7 @@ public class BaseItemLine extends BaseTouchableLine implements ItemLine { @Override public String toString() { - return "ItemLine [itemStack=" + itemStack + ", pickupHandler=" + pickupHandler + "]"; + return "ItemLine [itemStack=" + itemStack + "]"; } - + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseTouchableLine.java b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseTouchableLine.java similarity index 83% rename from plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseTouchableLine.java rename to core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseTouchableLine.java index 4aaa4016..59b7b9e1 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseTouchableLine.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/BaseTouchableLine.java @@ -3,34 +3,52 @@ * * SPDX-License-Identifier: GPL-3.0-or-later */ -package me.filoghost.holographicdisplays.object.base; +package me.filoghost.holographicdisplays.core.object.base; import me.filoghost.holographicdisplays.api.handler.TouchHandler; -import me.filoghost.holographicdisplays.api.line.TouchableLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import org.bukkit.World; +import org.bukkit.entity.Player; import java.util.Collection; +import java.util.Map; +import java.util.WeakHashMap; /** * Useful class that implements TouchablePiece. The downside is that subclasses must extend this, and cannot extend other classes. * But all the current items are touchable. */ -public abstract class BaseTouchableLine extends BaseHologramLine implements TouchableLine { +public abstract class BaseTouchableLine extends BaseHologramLine { private static final double SLIME_HEIGHT = 0.5; + private static final Map anticlickSpam = new WeakHashMap<>(); + private TouchHandler touchHandler; private NMSSlime slimeEntity; private NMSArmorStand vehicleEntity; + protected BaseTouchableLine(BaseHologram parent) { super(parent); } - - @Override + + public void onTouch(Player player) { + if (touchHandler == null || !getBaseParent().isVisibleTo(player)) { + return; + } + + Long lastClick = anticlickSpam.get(player); + if (lastClick != null && System.currentTimeMillis() - lastClick < 100) { + return; + } + + anticlickSpam.put(player, System.currentTimeMillis()); + touchHandler.onTouch(player); + } + public void setTouchHandler(TouchHandler touchHandler) { this.touchHandler = touchHandler; @@ -43,12 +61,11 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Touc despawnSlime(); } } - - @Override + public TouchHandler getTouchHandler() { return this.touchHandler; } - + @Override public void spawnEntities(World world, double x, double y, double z) { if (touchHandler != null) { @@ -97,7 +114,7 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Touc private double getSlimeSpawnY(double y) { return y + ((getHeight() - SLIME_HEIGHT) / 2) + getSlimeSpawnOffset(); } - + private double getSlimeSpawnOffset() { return 0; } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/HologramComponent.java b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/HologramComponent.java similarity index 96% rename from plugin/src/main/java/me/filoghost/holographicdisplays/object/HologramComponent.java rename to core/src/main/java/me/filoghost/holographicdisplays/core/object/base/HologramComponent.java index 4f4f0d5a..d0821606 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/HologramComponent.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/HologramComponent.java @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: GPL-3.0-or-later */ -package me.filoghost.holographicdisplays.object; +package me.filoghost.holographicdisplays.core.object.base; import me.filoghost.fcommons.Preconditions; import me.filoghost.holographicdisplays.core.Utils; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/SpawnableHologramLine.java b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/SpawnableHologramLine.java similarity index 64% rename from plugin/src/main/java/me/filoghost/holographicdisplays/object/base/SpawnableHologramLine.java rename to core/src/main/java/me/filoghost/holographicdisplays/core/object/base/SpawnableHologramLine.java index 14afa02f..3cad7308 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/SpawnableHologramLine.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/object/base/SpawnableHologramLine.java @@ -3,14 +3,13 @@ * * SPDX-License-Identifier: GPL-3.0-or-later */ -package me.filoghost.holographicdisplays.object.base; +package me.filoghost.holographicdisplays.core.object.base; -import me.filoghost.holographicdisplays.api.line.HologramLine; import org.bukkit.World; import java.util.Collection; -public interface SpawnableHologramLine extends HologramLine { +public interface SpawnableHologramLine { void respawn(World world, double x, double y, double z); 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 6f4d3dd6..c3dcaffe 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 @@ -5,10 +5,10 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_10_R1.AxisAlignedBB; import net.minecraft.server.v1_10_R1.DamageSource; import net.minecraft.server.v1_10_R1.EntityArmorStand; @@ -27,11 +27,11 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -225,7 +225,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 e63379e9..35eea069 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 @@ -5,14 +5,14 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; +import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.holographicdisplays.core.Utils; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_10_R1.Blocks; import net.minecraft.server.v1_10_R1.DamageSource; import net.minecraft.server.v1_10_R1.Entity; @@ -27,22 +27,19 @@ import net.minecraft.server.v1_10_R1.PacketPlayOutMount; import net.minecraft.server.v1_10_R1.World; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "au"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private int resendMountPacketTicks; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = Integer.MAX_VALUE; this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -90,8 +87,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -209,7 +206,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 01289baf..2d1ecf86 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 @@ -5,12 +5,12 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; -import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; +import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.Utils; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; +import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_10_R1.AxisAlignedBB; import net.minecraft.server.v1_10_R1.DamageSource; import net.minecraft.server.v1_10_R1.Entity; @@ -29,11 +29,11 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "au"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private int resendMountPacketTicks; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; super.collides = false; @@ -198,7 +198,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 6a5b2a24..65f8f470 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 @@ -9,16 +9,15 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_10_R1.Entity; import net.minecraft.server.v1_10_R1.EntityTypes; import net.minecraft.server.v1_10_R1.MathHelper; @@ -38,11 +37,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -59,9 +56,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -71,7 +68,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -82,7 +79,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 02536871..ad40e4b7 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; @@ -27,11 +27,11 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -225,7 +225,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 9732661b..6cb0307e 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_11_R1.Blocks; import net.minecraft.server.v1_11_R1.DamageSource; import net.minecraft.server.v1_11_R1.Entity; @@ -25,20 +25,17 @@ import net.minecraft.server.v1_11_R1.NBTTagString; import net.minecraft.server.v1_11_R1.World; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "au"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -65,8 +62,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -183,7 +180,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 9519bb26..d57f4a34 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -27,9 +27,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "au"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; super.collides = false; @@ -173,7 +173,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 26d75957..71a45277 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 @@ -9,16 +9,15 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_11_R1.Entity; import net.minecraft.server.v1_11_R1.EntityTypes; import net.minecraft.server.v1_11_R1.MathHelper; @@ -38,11 +37,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -67,9 +64,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -79,7 +76,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -90,7 +87,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 67be299a..25db73c6 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 @@ -5,10 +5,10 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_12_R1.AxisAlignedBB; import net.minecraft.server.v1_12_R1.DamageSource; import net.minecraft.server.v1_12_R1.EntityArmorStand; @@ -27,11 +27,11 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -225,7 +225,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 b045a637..24d32e29 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_12_R1.Blocks; import net.minecraft.server.v1_12_R1.DamageSource; import net.minecraft.server.v1_12_R1.Entity; @@ -25,20 +25,17 @@ import net.minecraft.server.v1_12_R1.NBTTagString; import net.minecraft.server.v1_12_R1.World; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "au"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -65,8 +62,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -183,7 +180,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 0378c57b..f9049970 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -27,9 +27,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "au"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; super.collides = false; @@ -173,7 +173,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 31ad101f..bd080870 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 @@ -9,16 +9,15 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_12_R1.Entity; import net.minecraft.server.v1_12_R1.EntityTypes; import net.minecraft.server.v1_12_R1.MathHelper; @@ -38,11 +37,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -67,9 +64,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -79,7 +76,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -90,7 +87,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 0c3a30c8..b253bf30 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; @@ -29,11 +29,11 @@ import org.bukkit.craftbukkit.v1_13_R1.util.CraftChatMessage; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -227,7 +227,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 dc38c7ef..7ed99e8d 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_13_R1.Blocks; import net.minecraft.server.v1_13_R1.DamageSource; import net.minecraft.server.v1_13_R1.Entity; @@ -25,20 +25,17 @@ import net.minecraft.server.v1_13_R1.NBTTagString; import net.minecraft.server.v1_13_R1.World; import org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "ax"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -65,8 +62,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -183,7 +180,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 326b0412..d1857975 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -28,9 +28,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "ax"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; super.collides = false; @@ -174,7 +174,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 3174e85c..2d02f86c 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 @@ -9,18 +9,17 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.ChatComponentAdapter; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_13_R1.ChatComponentText; import net.minecraft.server.v1_13_R1.Entity; import net.minecraft.server.v1_13_R1.EntityTypes; @@ -45,11 +44,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -74,9 +71,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -86,7 +83,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -97,7 +94,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 a144c947..fa4aa054 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 @@ -5,10 +5,10 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; -import me.filoghost.holographicdisplays.api.line.HologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_13_R2.AxisAlignedBB; import net.minecraft.server.v1_13_R2.DamageSource; import net.minecraft.server.v1_13_R2.EntityArmorStand; @@ -29,11 +29,11 @@ import org.bukkit.craftbukkit.v1_13_R2.util.CraftChatMessage; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -227,7 +227,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 6fb9c472..ccc45482 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_13_R2.Blocks; import net.minecraft.server.v1_13_R2.DamageSource; import net.minecraft.server.v1_13_R2.Entity; @@ -25,20 +25,17 @@ import net.minecraft.server.v1_13_R2.NBTTagString; import net.minecraft.server.v1_13_R2.World; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -65,8 +62,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -183,7 +180,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 246742d7..5eb70712 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -28,9 +28,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; super.collides = false; @@ -174,7 +174,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 95923650..4efd8843 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 @@ -9,18 +9,17 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.ChatComponentAdapter; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_13_R2.ChatComponentText; import net.minecraft.server.v1_13_R2.Entity; import net.minecraft.server.v1_13_R2.EntityTypes; @@ -46,11 +45,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -75,9 +72,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -87,7 +84,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -98,7 +95,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 2377b35d..7e6720e9 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; @@ -30,12 +30,12 @@ import org.bukkit.craftbukkit.v1_14_R1.util.CraftChatMessage; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private CraftEntity customBukkitEntity; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(EntityTypes.ARMOR_STAND, world); super.setInvisible(true); super.setSmall(true); @@ -229,7 +229,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 04b39360..d820fd95 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_14_R1.Blocks; import net.minecraft.server.v1_14_R1.DamageSource; import net.minecraft.server.v1_14_R1.Entity; @@ -26,21 +26,18 @@ import net.minecraft.server.v1_14_R1.NBTTagString; import net.minecraft.server.v1_14_R1.World; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(EntityTypes.ITEM, world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -67,8 +64,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -185,7 +182,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 e5c40532..8e0822a1 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -29,10 +29,10 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(EntityTypes.SLIME, world); super.persistent = true; super.collides = false; @@ -176,7 +176,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 8cba88b9..f143045e 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 @@ -9,17 +9,16 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.ChatComponentAdapter; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_14_R1.ChatBaseComponent; import net.minecraft.server.v1_14_R1.ChatComponentText; import net.minecraft.server.v1_14_R1.Entity; @@ -45,11 +44,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectField ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d"); private static final ReflectMethod REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -74,9 +71,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -86,7 +83,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -97,7 +94,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 1871787f..b51cb6b0 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; @@ -30,12 +30,12 @@ import org.bukkit.craftbukkit.v1_15_R1.util.CraftChatMessage; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private CraftEntity customBukkitEntity; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(EntityTypes.ARMOR_STAND, world); super.setInvisible(true); super.setSmall(true); @@ -229,7 +229,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 01bd8b20..6e2545cb 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_15_R1.Blocks; import net.minecraft.server.v1_15_R1.DamageSource; import net.minecraft.server.v1_15_R1.Entity; @@ -26,21 +26,18 @@ import net.minecraft.server.v1_15_R1.NBTTagString; import net.minecraft.server.v1_15_R1.World; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(EntityTypes.ITEM, world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -67,8 +64,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -185,7 +182,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 20faca99..e9420042 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -29,10 +29,10 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(EntityTypes.SLIME, world); super.persistent = true; super.collides = false; @@ -176,7 +176,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 a671deac..70bd2b25 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 @@ -9,17 +9,16 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.ChatComponentAdapter; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_15_R1.ChatComponentText; import net.minecraft.server.v1_15_R1.Entity; import net.minecraft.server.v1_15_R1.EntityTypes; @@ -44,11 +43,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectField ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d"); private static final ReflectMethod REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -73,9 +70,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -85,7 +82,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -96,7 +93,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 778dcef9..4093e0de 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; @@ -30,12 +30,12 @@ import org.bukkit.craftbukkit.v1_16_R1.util.CraftChatMessage; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private CraftEntity customBukkitEntity; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(EntityTypes.ARMOR_STAND, world); super.setInvisible(true); super.setSmall(true); @@ -229,7 +229,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 18382389..ffe7be6e 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_16_R1.Blocks; import net.minecraft.server.v1_16_R1.DamageSource; import net.minecraft.server.v1_16_R1.Entity; @@ -26,21 +26,18 @@ import net.minecraft.server.v1_16_R1.NBTTagString; import net.minecraft.server.v1_16_R1.World; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(EntityTypes.ITEM, world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -67,8 +64,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -185,7 +182,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 58c3cbc3..e865646e 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -29,10 +29,10 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(EntityTypes.SLIME, world); super.persistent = true; super.collides = false; @@ -176,7 +176,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 7f8a0b1c..f8c806e7 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 @@ -9,17 +9,16 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.ChatComponentAdapter; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_16_R1.ChatComponentText; import net.minecraft.server.v1_16_R1.Entity; import net.minecraft.server.v1_16_R1.EntityTypes; @@ -44,11 +43,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectField ID_TO_CLASS_MAP_FIELD = ReflectField.lookup(Object[].class, RegistryID.class, "d"); private static final ReflectMethod REGISTER_ENTITY_METHOD = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -73,9 +70,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -85,7 +82,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -96,7 +93,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 a7bb9e7a..0841550d 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.Utils; @@ -30,12 +30,12 @@ import org.bukkit.craftbukkit.v1_16_R2.util.CraftChatMessage; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private CraftEntity customBukkitEntity; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(EntityTypes.ARMOR_STAND, world); super.setInvisible(true); super.setSmall(true); @@ -229,7 +229,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 c202bd98..1cfb7916 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_16_R2.Blocks; import net.minecraft.server.v1_16_R2.DamageSource; import net.minecraft.server.v1_16_R2.Entity; @@ -26,21 +26,18 @@ import net.minecraft.server.v1_16_R2.NBTTagString; import net.minecraft.server.v1_16_R2.World; import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(EntityTypes.ITEM, world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -67,8 +64,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -185,7 +182,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 97a6a6b1..b0dd406b 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -29,10 +29,10 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(EntityTypes.SLIME, world); super.persistent = true; super.collides = false; @@ -176,7 +176,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 e49d1808..e8693ae2 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 @@ -9,17 +9,16 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.ChatComponentAdapter; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_16_R2.ChatComponentText; import net.minecraft.server.v1_16_R2.Entity; import net.minecraft.server.v1_16_R2.EntityTypes; @@ -43,11 +42,9 @@ 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 = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -64,9 +61,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -76,7 +73,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -87,7 +84,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 b26438a4..1e291ada 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 @@ -5,10 +5,10 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; -import me.filoghost.holographicdisplays.api.line.HologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_16_R3.AxisAlignedBB; import net.minecraft.server.v1_16_R3.DamageSource; import net.minecraft.server.v1_16_R3.EntityArmorStand; @@ -30,12 +30,12 @@ import org.bukkit.craftbukkit.v1_16_R3.util.CraftChatMessage; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private CraftEntity customBukkitEntity; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(EntityTypes.ARMOR_STAND, world); super.setInvisible(true); super.setSmall(true); @@ -229,7 +229,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 91e199d8..e0950c15 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_16_R3.Blocks; import net.minecraft.server.v1_16_R3.DamageSource; import net.minecraft.server.v1_16_R3.Entity; @@ -26,21 +26,18 @@ import net.minecraft.server.v1_16_R3.NBTTagString; import net.minecraft.server.v1_16_R3.World; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(EntityTypes.ITEM, world); super.pickupDelay = 32767; // Lock the item pickup delay, also prevents entities from picking up the item this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -67,8 +64,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -185,7 +182,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 46a87c73..2cc3f8d8 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 @@ -5,11 +5,11 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_16_R3.AxisAlignedBB; import net.minecraft.server.v1_16_R3.DamageSource; import net.minecraft.server.v1_16_R3.Entity; @@ -29,10 +29,10 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "vehicle"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private CraftEntity customBukkitEntity; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(EntityTypes.SLIME, world); super.persistent = true; super.collides = false; @@ -176,7 +176,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 39bda267..f54f6bdd 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 @@ -9,17 +9,16 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.ChatComponentAdapter; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_16_R3.ChatComponentText; import net.minecraft.server.v1_16_R3.Entity; import net.minecraft.server.v1_16_R3.EntityTypes; @@ -43,11 +42,9 @@ 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 = ReflectMethod.lookup(void.class, WorldServer.class, "registerEntity", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -64,9 +61,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -76,7 +73,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -87,7 +84,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 c6c67e2a..9b691eb5 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 @@ -7,11 +7,11 @@ package me.filoghost.holographicdisplays.nms.v1_8_R2; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_8_R2.AxisAlignedBB; import net.minecraft.server.v1_8_R2.DamageSource; import net.minecraft.server.v1_8_R2.EntityArmorStand; @@ -29,11 +29,11 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private static final ReflectField DISABLED_SLOTS_FIELD = ReflectField.lookup(int.class, EntityArmorStand.class, "bi"); private static final ReflectMethod SET_MARKER_METHOD = ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -221,7 +221,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 65bfd8e8..9b1adf13 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 @@ -6,12 +6,12 @@ package me.filoghost.holographicdisplays.nms.v1_8_R2; import me.filoghost.fcommons.reflection.ReflectField; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_8_R2.Blocks; import net.minecraft.server.v1_8_R2.DamageSource; import net.minecraft.server.v1_8_R2.Entity; @@ -25,21 +25,18 @@ import net.minecraft.server.v1_8_R2.NBTTagString; import net.minecraft.server.v1_8_R2.World; import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField RIDER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar"); private static final ReflectField RIDER_YAW_DELTA = ReflectField.lookup(double.class, Entity.class, "as"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = Integer.MAX_VALUE; this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -66,8 +63,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -169,7 +166,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 eb27f639..d9955e42 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 @@ -6,7 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_8_R2; import me.filoghost.fcommons.reflection.ReflectField; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; @@ -27,9 +27,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField RIDER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar"); private static final ReflectField RIDER_YAW_DELTA = ReflectField.lookup(double.class, Entity.class, "as"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; a(0.0F, 0.0F); @@ -161,7 +161,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 a14b4dd6..5948b2b4 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 @@ -9,16 +9,15 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_8_R2.Entity; import net.minecraft.server.v1_8_R2.EntityTypes; import net.minecraft.server.v1_8_R2.MathHelper; @@ -39,11 +38,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "a", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -60,9 +57,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -72,7 +69,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -83,7 +80,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 a446d844..b4535038 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 @@ -7,11 +7,11 @@ package me.filoghost.holographicdisplays.nms.v1_8_R3; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import net.minecraft.server.v1_8_R3.AxisAlignedBB; import net.minecraft.server.v1_8_R3.DamageSource; import net.minecraft.server.v1_8_R3.EntityArmorStand; @@ -29,11 +29,11 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private static final ReflectField DISABLED_SLOTS_FIELD = ReflectField.lookup(int.class, EntityArmorStand.class, "bi"); private static final ReflectMethod SET_MARKER_METHOD = ReflectMethod.lookup(void.class, EntityArmorStand.class, "n", boolean.class); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -221,7 +221,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 f56b6d49..d2409cf9 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 @@ -5,13 +5,13 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_8_R3.Blocks; import net.minecraft.server.v1_8_R3.DamageSource; import net.minecraft.server.v1_8_R3.Entity; @@ -25,21 +25,18 @@ import net.minecraft.server.v1_8_R3.NBTTagString; import net.minecraft.server.v1_8_R3.World; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField RIDER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar"); private static final ReflectField RIDER_YAW_DELTA = ReflectField.lookup(double.class, Entity.class, "as"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = Integer.MAX_VALUE; this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -66,8 +63,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -169,7 +166,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 cbed2965..1ccf8061 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -27,9 +27,9 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField RIDER_PITCH_DELTA = ReflectField.lookup(double.class, Entity.class, "ar"); private static final ReflectField RIDER_YAW_DELTA = ReflectField.lookup(double.class, Entity.class, "as"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; a(0.0F, 0.0F); @@ -161,7 +161,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 4a55b988..2b018f2a 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 @@ -9,16 +9,15 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityTypes; import net.minecraft.server.v1_8_R3.MathHelper; @@ -39,11 +38,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "a", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -60,9 +57,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -72,7 +69,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -83,7 +80,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 5c97f1bc..d8112294 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 @@ -6,7 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_9_R1; import me.filoghost.fcommons.reflection.ReflectField; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; @@ -30,12 +30,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta private static final ReflectField DISABLED_SLOTS_FIELD = ReflectField.lookup(int.class, EntityArmorStand.class, "bz"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -233,7 +233,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 4a981416..20329cd5 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 @@ -5,14 +5,14 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R1; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; +import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.holographicdisplays.core.Utils; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_9_R1.Blocks; import net.minecraft.server.v1_9_R1.DamageSource; import net.minecraft.server.v1_9_R1.Entity; @@ -27,22 +27,19 @@ import net.minecraft.server.v1_9_R1.PacketPlayOutMount; import net.minecraft.server.v1_9_R1.World; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "as"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private int resendMountPacketTicks; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = Integer.MAX_VALUE; this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -89,8 +86,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -207,7 +204,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 61a827ac..f6e392b5 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R1; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -29,11 +29,11 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "as"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private int resendMountPacketTicks; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; a(0.0F, 0.0F); @@ -195,7 +195,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 33a2d0e3..d1353f27 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 @@ -9,16 +9,15 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_9_R1.Entity; import net.minecraft.server.v1_9_R1.EntityTypes; import net.minecraft.server.v1_9_R1.MathHelper; @@ -38,11 +37,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -59,9 +56,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -71,7 +68,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -82,7 +79,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); 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 22ba6ea1..0f064abf 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; @@ -27,11 +27,11 @@ import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorStand { - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private final PacketController packetController; private String customName; - public EntityNMSArmorStand(World world, HologramLine parentPiece, PacketController packetController) { + public EntityNMSArmorStand(World world, BaseHologramLine parentPiece, PacketController packetController) { super(world); super.setInvisible(true); super.setSmall(true); @@ -225,7 +225,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 bf2d0b7a..e1a4eb16 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 @@ -5,14 +5,14 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; +import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.DebugLogger; +import me.filoghost.holographicdisplays.core.Utils; import me.filoghost.holographicdisplays.core.nms.NMSCommons; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; -import me.filoghost.holographicdisplays.core.DebugLogger; -import me.filoghost.holographicdisplays.core.Utils; -import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_9_R2.Blocks; import net.minecraft.server.v1_9_R2.DamageSource; import net.minecraft.server.v1_9_R2.Entity; @@ -27,22 +27,19 @@ import net.minecraft.server.v1_9_R2.PacketPlayOutMount; import net.minecraft.server.v1_9_R2.World; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; -import org.bukkit.entity.Player; public class EntityNMSItem extends EntityItem implements NMSItem { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "at"); - private final ItemLine parentPiece; - private final ItemPickupManager itemPickupManager; + private final BaseItemLine parentPiece; private int resendMountPacketTicks; - public EntityNMSItem(World world, ItemLine piece, ItemPickupManager itemPickupManager) { + public EntityNMSItem(World world, BaseItemLine piece) { super(world); super.pickupDelay = Integer.MAX_VALUE; this.parentPiece = piece; - this.itemPickupManager = itemPickupManager; } @Override @@ -90,8 +87,8 @@ public class EntityNMSItem extends EntityItem implements NMSItem { return; } - if (parentPiece.getPickupHandler() != null && human instanceof EntityPlayer) { - itemPickupManager.handleItemLinePickup((Player) human.getBukkitEntity(), parentPiece); + if (human instanceof EntityPlayer) { + parentPiece.onPickup(((EntityPlayer) human).getBukkitEntity()); // It is never added to the inventory. } } @@ -209,7 +206,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem { } @Override - public ItemLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 eb4ddb0a..f6161d21 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 @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; -import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.DebugLogger; @@ -29,11 +29,11 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { private static final ReflectField VEHICLE_FIELD = ReflectField.lookup(Entity.class, Entity.class, "at"); - private final HologramLine parentPiece; + private final BaseHologramLine parentPiece; private int resendMountPacketTicks; - public EntityNMSSlime(World world, HologramLine parentPiece) { + public EntityNMSSlime(World world, BaseHologramLine parentPiece) { super(world); super.persistent = true; a(0.0F, 0.0F); @@ -197,7 +197,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime { } @Override - public HologramLine getHologramLine() { + public BaseHologramLine getHologramLine() { return parentPiece; } 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 e5ec921a..a859572c 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 @@ -9,16 +9,15 @@ import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.reflection.ClassToken; import me.filoghost.fcommons.reflection.ReflectField; import me.filoghost.fcommons.reflection.ReflectMethod; -import me.filoghost.holographicdisplays.api.line.HologramLine; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.nms.CustomNameHelper; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import net.minecraft.server.v1_9_R2.Entity; import net.minecraft.server.v1_9_R2.EntityTypes; import net.minecraft.server.v1_9_R2.MathHelper; @@ -38,11 +37,9 @@ public class VersionNMSManager implements NMSManager { private static final ReflectMethod VALIDATE_ENTITY_METHOD = ReflectMethod.lookup(Object.class, World.class, "b", Entity.class); - private final ItemPickupManager itemPickupManager; private final PacketController packetController; - public VersionNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - this.itemPickupManager = itemPickupManager; + public VersionNMSManager(PacketController packetController) { this.packetController = packetController; } @@ -59,9 +56,9 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack) { + public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, BaseItemLine parentPiece, ItemStack stack) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); - EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece, itemPickupManager); + EntityNMSItem customItem = new EntityNMSItem(nmsWorld, parentPiece); customItem.setLocationNMS(x, y, z); customItem.setItemStackNMS(stack); if (!addEntityToWorld(nmsWorld, customItem)) { @@ -71,7 +68,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, HologramLine parentPiece) { + public EntityNMSSlime spawnNMSSlime(org.bukkit.World bukkitWorld, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) bukkitWorld).getHandle(); EntityNMSSlime touchSlime = new EntityNMSSlime(nmsWorld, parentPiece); touchSlime.setLocationNMS(x, y, z); @@ -82,7 +79,7 @@ public class VersionNMSManager implements NMSManager { } @Override - public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, HologramLine parentPiece) { + public NMSArmorStand spawnNMSArmorStand(org.bukkit.World world, double x, double y, double z, BaseHologramLine parentPiece) { WorldServer nmsWorld = ((CraftWorld) world).getHandle(); EntityNMSArmorStand invisibleArmorStand = new EntityNMSArmorStand(nmsWorld, parentPiece, packetController); invisibleArmorStand.setLocationNMS(x, y, z); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/HolographicDisplays.java b/plugin/src/main/java/me/filoghost/holographicdisplays/HolographicDisplays.java index 81893608..eda23b79 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/HolographicDisplays.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/HolographicDisplays.java @@ -9,14 +9,15 @@ import me.filoghost.fcommons.FCommonsPlugin; import me.filoghost.fcommons.FeatureSupport; import me.filoghost.fcommons.config.exception.ConfigException; import me.filoghost.fcommons.logging.Log; -import me.filoghost.holographicdisplays.api.Hologram; import me.filoghost.holographicdisplays.api.internal.BackendAPI; -import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker; import me.filoghost.holographicdisplays.bridge.protocollib.ProtocolLibHook; import me.filoghost.holographicdisplays.commands.HologramCommandManager; import me.filoghost.holographicdisplays.commands.Messages; import me.filoghost.holographicdisplays.core.Utils; +import me.filoghost.holographicdisplays.core.nms.NMSManager; +import me.filoghost.holographicdisplays.core.nms.PacketController; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; import me.filoghost.holographicdisplays.disk.ConfigManager; import me.filoghost.holographicdisplays.disk.Configuration; import me.filoghost.holographicdisplays.disk.HologramConfig; @@ -26,12 +27,8 @@ import me.filoghost.holographicdisplays.listener.ChunkListener; import me.filoghost.holographicdisplays.listener.MainListener; import me.filoghost.holographicdisplays.listener.SpawnListener; import me.filoghost.holographicdisplays.listener.UpdateNotificationListener; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; -import me.filoghost.holographicdisplays.core.nms.NMSManager; -import me.filoghost.holographicdisplays.core.nms.PacketController; import me.filoghost.holographicdisplays.object.api.APIHologram; import me.filoghost.holographicdisplays.object.api.APIHologramManager; -import me.filoghost.holographicdisplays.object.base.BaseHologram; import me.filoghost.holographicdisplays.object.internal.InternalHologram; import me.filoghost.holographicdisplays.object.internal.InternalHologramManager; import me.filoghost.holographicdisplays.placeholder.AnimationsRegister; @@ -43,10 +40,8 @@ import org.bstats.bukkit.MetricsLite; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -public class HolographicDisplays extends FCommonsPlugin implements PacketController, ItemPickupManager { +public class HolographicDisplays extends FCommonsPlugin implements PacketController { private static HolographicDisplays instance; @@ -88,7 +83,7 @@ public class HolographicDisplays extends FCommonsPlugin implements PacketControl NMSManager nmsManager; try { - nmsManager = NMSVersion.createNMSManager(this, this); + nmsManager = NMSVersion.createNMSManager(this); nmsManager.setup(); } catch (Exception e) { throw new PluginEnableException(e, "Couldn't initialize the NMS manager."); @@ -196,20 +191,7 @@ public class HolographicDisplays extends FCommonsPlugin implements PacketControl public static HolographicDisplays getInstance() { return instance; } - - @Override - public void handleItemLinePickup(Player player, ItemLine itemLine) { - Hologram hologram = itemLine.getParent(); - try { - if (hologram.getVisibilityManager().isVisibleTo(player)) { - itemLine.getPickupHandler().onPickup(player); - } - } catch (Throwable t) { - Plugin plugin = hologram instanceof APIHologram ? ((APIHologram) hologram).getOwner() : HolographicDisplays.getInstance(); - Log.warning("The plugin " + plugin.getName() + " generated an exception when the player " + player.getName() + " picked up an item from a hologram.", t); - } - } - + @Override public boolean shouldBroadcastLocationPacket() { return ProtocolLibHook.isEnabled(); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketListener.java b/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketListener.java index ce7d3cfe..4e52801b 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketListener.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketListener.java @@ -20,7 +20,7 @@ import me.filoghost.holographicdisplays.bridge.protocollib.packet.WrapperPlaySer import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; -import me.filoghost.holographicdisplays.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; import me.filoghost.holographicdisplays.object.base.BaseTextLine; import me.filoghost.holographicdisplays.placeholder.RelativePlaceholder; import me.filoghost.holographicdisplays.util.NMSVersion; @@ -73,7 +73,7 @@ class PacketListener extends PacketAdapter { return; } - if (!hologramLine.getParent().getVisibilityManager().isVisibleTo(player)) { + if (!hologramLine.getBaseParent().isVisibleTo(player)) { event.setCancelled(true); return; } @@ -88,7 +88,7 @@ class PacketListener extends PacketAdapter { } BaseTextLine textLine = (BaseTextLine) hologramLine; - if (!hologramLine.getParent().isAllowPlaceholders() || !textLine.hasRelativePlaceholders()) { + if (!hologramLine.getBaseParent().isAllowPlaceholders() || !textLine.hasRelativePlaceholders()) { return; } @@ -110,7 +110,7 @@ class PacketListener extends PacketAdapter { return; } - if (!hologramLine.getParent().getVisibilityManager().isVisibleTo(player)) { + if (!hologramLine.getBaseParent().isVisibleTo(player)) { event.setCancelled(true); return; } @@ -123,7 +123,7 @@ class PacketListener extends PacketAdapter { return; } - if (!hologramLine.getParent().getVisibilityManager().isVisibleTo(player)) { + if (!hologramLine.getBaseParent().isVisibleTo(player)) { event.setCancelled(true); return; } @@ -133,7 +133,7 @@ class PacketListener extends PacketAdapter { } BaseTextLine textLine = (BaseTextLine) hologramLine; - if (!hologramLine.getParent().isAllowPlaceholders() || !textLine.hasRelativePlaceholders()) { + if (!hologramLine.getBaseParent().isAllowPlaceholders() || !textLine.hasRelativePlaceholders()) { return; } @@ -197,7 +197,7 @@ class PacketListener extends PacketAdapter { return null; // Entity not existing or not related to holograms. } - return (BaseHologramLine) nmsEntity.getHologramLine(); + return nmsEntity.getHologramLine(); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketSender.java b/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketSender.java index 13495e6b..b9f365a4 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketSender.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/PacketSender.java @@ -18,11 +18,11 @@ import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; -import me.filoghost.holographicdisplays.object.base.BaseHologram; -import me.filoghost.holographicdisplays.object.base.BaseItemLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; +import me.filoghost.holographicdisplays.core.object.base.BaseTouchableLine; +import me.filoghost.holographicdisplays.core.object.base.SpawnableHologramLine; import me.filoghost.holographicdisplays.object.base.BaseTextLine; -import me.filoghost.holographicdisplays.object.base.BaseTouchableLine; -import me.filoghost.holographicdisplays.object.base.SpawnableHologramLine; import me.filoghost.holographicdisplays.util.NMSVersion; import org.bukkit.entity.Player; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/ProtocolLibHook.java b/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/ProtocolLibHook.java index e097a1c4..c14835c8 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/ProtocolLibHook.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/bridge/protocollib/ProtocolLibHook.java @@ -8,7 +8,7 @@ package me.filoghost.holographicdisplays.bridge.protocollib; import com.google.common.base.Preconditions; import me.filoghost.fcommons.logging.Log; import me.filoghost.holographicdisplays.core.nms.NMSManager; -import me.filoghost.holographicdisplays.object.base.BaseHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; import me.filoghost.holographicdisplays.util.VersionUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/CreateCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/CreateCommand.java index f25b4460..f31acd3c 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/CreateCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/CreateCommand.java @@ -16,6 +16,8 @@ import me.filoghost.holographicdisplays.disk.ConfigManager; import me.filoghost.holographicdisplays.object.internal.InternalHologram; import me.filoghost.holographicdisplays.object.internal.InternalHologramLine; import me.filoghost.holographicdisplays.object.internal.InternalHologramManager; +import me.filoghost.holographicdisplays.object.internal.InternalTextLine; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -58,18 +60,21 @@ public class CreateCommand extends HologramSubCommand { } InternalHologram hologram = internalHologramManager.createHologram(spawnLoc, hologramName); + InternalHologramLine line; if (args.length > 1) { String text = Utils.join(args, " ", 1, args.length); CommandValidate.check(!text.equalsIgnoreCase("{empty}"), "The first line should not be empty."); - InternalHologramLine line = HologramCommandValidate.parseHologramLine(hologram, text, true); - hologram.getLinesUnsafe().add(line); + line = HologramCommandValidate.parseHologramLine(hologram, text, true); player.sendMessage(Colors.SECONDARY_SHADOW + "(Change the lines with /" + context.getRootLabel() + " edit " + hologram.getName() + ")"); } else { - hologram.appendTextLine("Default hologram. Change it with " + Colors.PRIMARY + "/" + context.getRootLabel() + " edit " + hologram.getName()); + String defaultText = "Default hologram. Change it with " + + Colors.PRIMARY + "/" + context.getRootLabel() + " edit " + hologram.getName(); + line = new InternalTextLine(hologram, defaultText, defaultText.replace(ChatColor.COLOR_CHAR, '&')); } - + + hologram.getLinesUnsafe().add(line); hologram.refresh(); configManager.getHologramDatabase().addOrUpdate(hologram); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/DebugCommand.java b/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/DebugCommand.java index 0e789289..d44cd1e7 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/DebugCommand.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/commands/subs/DebugCommand.java @@ -7,12 +7,10 @@ package me.filoghost.holographicdisplays.commands.subs; import me.filoghost.fcommons.command.sub.SubCommandContext; import me.filoghost.holographicdisplays.Colors; -import me.filoghost.holographicdisplays.api.Hologram; import me.filoghost.holographicdisplays.commands.HologramSubCommand; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; -import me.filoghost.holographicdisplays.object.api.APIHologram; -import me.filoghost.holographicdisplays.object.internal.InternalHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; @@ -38,21 +36,21 @@ public class DebugCommand extends HologramSubCommand { @Override public void execute(CommandSender sender, String[] args, SubCommandContext context) { boolean foundAnyHologram = false; - + for (World world : Bukkit.getWorlds()) { - Map hologramsDebugInfo = new HashMap<>(); - + Map hologramsDebugInfo = new HashMap<>(); + for (Chunk chunk : world.getLoadedChunks()) { for (Entity entity : chunk.getEntities()) { NMSEntityBase nmsEntity = nmsManager.getNMSEntityBase(entity); - + if (nmsEntity == null) { continue; } - - Hologram ownerHologram = nmsEntity.getHologramLine().getParent(); + + BaseHologram ownerHologram = nmsEntity.getHologramLine().getBaseParent(); HologramDebugInfo hologramDebugInfo = hologramsDebugInfo.computeIfAbsent(ownerHologram, mapKey -> new HologramDebugInfo()); - + if (nmsEntity.isDeadNMS()) { hologramDebugInfo.deadEntities++; } else { @@ -60,35 +58,23 @@ public class DebugCommand extends HologramSubCommand { } } } - + if (!hologramsDebugInfo.isEmpty()) { foundAnyHologram = true; sender.sendMessage(Colors.PRIMARY + "Holograms in world '" + world.getName() + "':"); - - for (Entry entry : hologramsDebugInfo.entrySet()) { - Hologram hologram = entry.getKey(); - String displayName = getHologramDisplayName(hologram); + + for (Entry entry : hologramsDebugInfo.entrySet()) { + BaseHologram hologram = entry.getKey(); HologramDebugInfo debugInfo = entry.getValue(); - sender.sendMessage(Colors.PRIMARY_SHADOW + "- '" + displayName + "': " + hologram.size() + " lines, " + sender.sendMessage(Colors.PRIMARY_SHADOW + "- '" + hologram.toFormattedString() + "': " + hologram.size() + " lines, " + debugInfo.getTotalEntities() + " entities (" + debugInfo.aliveEntities + " alive, " + debugInfo.deadEntities + " dead)"); } } } - + if (!foundAnyHologram) { sender.sendMessage(Colors.ERROR + "Couldn't find any loaded hologram (holograms may be in unloaded chunks)."); } - - } - - private String getHologramDisplayName(Hologram hologram) { - if (hologram instanceof InternalHologram) { - return ((InternalHologram) hologram).getName(); - } else if (hologram instanceof APIHologram) { - return ((APIHologram) hologram).getOwner().getName() + "@" + Integer.toHexString(hologram.hashCode()); - } else { - return hologram.toString(); - } } private static class HologramDebugInfo { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/listener/ChunkListener.java b/plugin/src/main/java/me/filoghost/holographicdisplays/listener/ChunkListener.java index d05cf9dc..971a4840 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/listener/ChunkListener.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/listener/ChunkListener.java @@ -3,7 +3,6 @@ package me.filoghost.holographicdisplays.listener; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; import me.filoghost.holographicdisplays.object.api.APIHologramManager; -import me.filoghost.holographicdisplays.object.base.BaseHologram; import me.filoghost.holographicdisplays.object.internal.InternalHologramManager; import me.filoghost.holographicdisplays.util.SchedulerUtils; import org.bukkit.Chunk; @@ -33,7 +32,7 @@ public class ChunkListener implements Listener { NMSEntityBase entityBase = nmsManager.getNMSEntityBase(entity); if (entityBase != null) { - ((BaseHologram) entityBase.getHologramLine().getParent()).despawnEntities(); + entityBase.getHologramLine().getBaseParent().despawnEntities(); } } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/listener/MainListener.java b/plugin/src/main/java/me/filoghost/holographicdisplays/listener/MainListener.java index e1dbf808..19db8d55 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/listener/MainListener.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/listener/MainListener.java @@ -9,8 +9,8 @@ import me.filoghost.fcommons.logging.Log; import me.filoghost.holographicdisplays.HolographicDisplays; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityBase; +import me.filoghost.holographicdisplays.core.object.base.BaseTouchableLine; import me.filoghost.holographicdisplays.object.api.APIHologram; -import me.filoghost.holographicdisplays.object.base.BaseTouchableLine; import org.bukkit.GameMode; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -18,18 +18,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; -import java.util.HashMap; -import java.util.Map; - public class MainListener implements Listener { private final NMSManager nmsManager; - private final Map anticlickSpam = new HashMap<>(); - public MainListener(NMSManager nmsManager) { this.nmsManager = nmsManager; } @@ -51,28 +45,13 @@ public class MainListener implements Listener { } BaseTouchableLine touchableLine = (BaseTouchableLine) entityBase.getHologramLine(); - if (touchableLine.getTouchHandler() == null || !touchableLine.getParent().getVisibilityManager().isVisibleTo(clicker)) { - return; - } - - Long lastClick = anticlickSpam.get(clicker); - if (lastClick != null && System.currentTimeMillis() - lastClick < 100) { - return; - } - - anticlickSpam.put(event.getPlayer(), System.currentTimeMillis()); try { - touchableLine.getTouchHandler().onTouch(event.getPlayer()); + touchableLine.onTouch(event.getPlayer()); } catch (Throwable t) { - Plugin plugin = touchableLine.getParent() instanceof APIHologram ? ((APIHologram) touchableLine.getParent()).getOwner() : HolographicDisplays.getInstance(); + Plugin plugin = touchableLine.getBaseParent() instanceof APIHologram ? ((APIHologram) touchableLine.getBaseParent()).getOwner() : HolographicDisplays.getInstance(); Log.warning("The plugin " + plugin.getName() + " generated an exception when the player " + event.getPlayer().getName() + " touched a hologram.", t); } } - @EventHandler - public void onQuit(PlayerQuitEvent event) { - anticlickSpam.remove(event.getPlayer()); - } - } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java index 397ec17d..3ff1ed67 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java @@ -7,14 +7,17 @@ package me.filoghost.holographicdisplays.object.api; import me.filoghost.fcommons.Preconditions; import me.filoghost.holographicdisplays.api.Hologram; +import me.filoghost.holographicdisplays.api.VisibilityManager; +import me.filoghost.holographicdisplays.api.line.HologramLine; import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.api.line.TextLine; import me.filoghost.holographicdisplays.core.nms.NMSManager; -import me.filoghost.holographicdisplays.object.base.BaseHologram; -import me.filoghost.holographicdisplays.object.base.BaseHologramLine; -import me.filoghost.holographicdisplays.object.base.BaseItemLine; -import me.filoghost.holographicdisplays.object.base.BaseTextLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseHologramLine; +import me.filoghost.holographicdisplays.disk.Configuration; +import me.filoghost.holographicdisplays.object.base.DefaultVisibilityManager; import org.bukkit.Location; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; @@ -25,23 +28,30 @@ public class APIHologram extends BaseHologram implements Hologram { private final Plugin plugin; private final APIHologramManager apiHologramManager; - private final List lines; + private final VisibilityManager visibilityManager; + private final long creationTimestamp; + private final List lines; + + private boolean allowPlaceholders; protected APIHologram(Location source, Plugin plugin, NMSManager nmsManager, APIHologramManager apiHologramManager) { super(source, nmsManager); Preconditions.notNull(plugin, "plugin"); this.plugin = plugin; this.apiHologramManager = apiHologramManager; + this.visibilityManager = new DefaultVisibilityManager(this); + this.creationTimestamp = System.currentTimeMillis(); this.lines = new ArrayList<>(); } + @Override public Plugin getOwner() { return plugin; } @Override - public List getLinesUnsafe() { + public List getLinesUnsafe() { return lines; } @@ -49,7 +59,7 @@ public class APIHologram extends BaseHologram implements Hologram { public TextLine appendTextLine(String text) { checkState(); - BaseTextLine line = new BaseTextLine(this, text); + APITextLine line = new APITextLine(this, text); lines.add(line); refresh(); return line; @@ -60,7 +70,7 @@ public class APIHologram extends BaseHologram implements Hologram { checkState(); Preconditions.notNull(itemStack, "itemStack"); - BaseItemLine line = new BaseItemLine(this, itemStack); + APIItemLine line = new APIItemLine(this, itemStack); lines.add(line); refresh(); return line; @@ -70,7 +80,7 @@ public class APIHologram extends BaseHologram implements Hologram { public TextLine insertTextLine(int index, String text) { checkState(); - BaseTextLine line = new BaseTextLine(this, text); + APITextLine line = new APITextLine(this, text); lines.add(index, line); refresh(); return line; @@ -81,15 +91,76 @@ public class APIHologram extends BaseHologram implements Hologram { checkState(); Preconditions.notNull(itemStack, "itemStack"); - BaseItemLine line = new BaseItemLine(this, itemStack); + APIItemLine line = new APIItemLine(this, itemStack); lines.add(index, line); refresh(); return line; } + @Override + public HologramLine getLine(int index) { + return lines.get(index); + } + + @Override + public void setAllowPlaceholders(boolean allowPlaceholders) { + if (this.allowPlaceholders == allowPlaceholders) { + return; + } + + this.allowPlaceholders = allowPlaceholders; + refresh(true); + } + + @Override + public boolean isAllowPlaceholders() { + return allowPlaceholders; + } + + @Override + public boolean isVisibleTo(Player player) { + return visibilityManager.isVisibleTo(player); + } + + @Override + protected double getSpaceBetweenLines() { + return Configuration.spaceBetweenLines; + } + + @Override + public double getHeight() { + if (lines.isEmpty()) { + return 0; + } + + double height = 0.0; + + for (APIHologramLine line : lines) { + height += line.getHeight(); + } + + height += Configuration.spaceBetweenLines * (lines.size() - 1); + return height; + } + + @Override + public long getCreationTimestamp() { + return creationTimestamp; + } + + @Override + public VisibilityManager getVisibilityManager() { + return visibilityManager; + } + @Override public void delete() { apiHologramManager.deleteHologram(this); } + @Override + public String toFormattedString() { + return plugin.getName() + "@" + Integer.toHexString(hashCode()); + } + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologramLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologramLine.java new file mode 100644 index 00000000..a9aca66e --- /dev/null +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologramLine.java @@ -0,0 +1,13 @@ +/* + * Copyright (C) filoghost and contributors + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ +package me.filoghost.holographicdisplays.object.api; + +import me.filoghost.holographicdisplays.api.line.HologramLine; +import me.filoghost.holographicdisplays.core.object.base.SpawnableHologramLine; + +public interface APIHologramLine extends HologramLine, SpawnableHologramLine { + +} diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIItemLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIItemLine.java new file mode 100644 index 00000000..216ed68a --- /dev/null +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIItemLine.java @@ -0,0 +1,22 @@ +package me.filoghost.holographicdisplays.object.api; + +import me.filoghost.holographicdisplays.api.Hologram; +import me.filoghost.holographicdisplays.api.line.ItemLine; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; +import org.bukkit.inventory.ItemStack; + +public class APIItemLine extends BaseItemLine implements ItemLine, APIHologramLine { + + private final APIHologram parent; + + public APIItemLine(APIHologram parent, ItemStack itemStack) { + super(parent, itemStack); + this.parent = parent; + } + + @Override + public Hologram getParent() { + return parent; + } + +} diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APITextLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APITextLine.java new file mode 100644 index 00000000..e51968ac --- /dev/null +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APITextLine.java @@ -0,0 +1,21 @@ +package me.filoghost.holographicdisplays.object.api; + +import me.filoghost.holographicdisplays.api.Hologram; +import me.filoghost.holographicdisplays.api.line.TextLine; +import me.filoghost.holographicdisplays.object.base.BaseTextLine; + +public class APITextLine extends BaseTextLine implements TextLine, APIHologramLine { + + private final APIHologram parent; + + public APITextLine(APIHologram parent, String text) { + super(parent, text); + this.parent = parent; + } + + @Override + public Hologram getParent() { + return parent; + } + +} diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologramManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologramManager.java index e45e94ad..7e288eed 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologramManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseHologramManager.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.object.base; import me.filoghost.fcommons.Preconditions; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; import org.bukkit.Chunk; import java.util.ArrayList; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseTextLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseTextLine.java index f140f894..2d08d9b5 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseTextLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/BaseTextLine.java @@ -5,8 +5,9 @@ */ package me.filoghost.holographicdisplays.object.base; -import me.filoghost.holographicdisplays.api.line.TextLine; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseTouchableLine; import me.filoghost.holographicdisplays.placeholder.PlaceholdersManager; import me.filoghost.holographicdisplays.placeholder.RelativePlaceholder; import org.bukkit.World; @@ -15,7 +16,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -public class BaseTextLine extends BaseTouchableLine implements TextLine { +public abstract class BaseTextLine extends BaseTouchableLine { private String text; private List relativePlaceholders; @@ -37,12 +38,12 @@ public class BaseTextLine extends BaseTouchableLine implements TextLine { if (nameableEntity != null) { if (text != null && !text.isEmpty()) { nameableEntity.setCustomNameNMS(text); - if (getParent().isAllowPlaceholders()) { + if (getBaseParent().isAllowPlaceholders()) { PlaceholdersManager.trackIfNecessary(this); } } else { nameableEntity.setCustomNameNMS(""); // It will not appear - if (getParent().isAllowPlaceholders()) { + if (getBaseParent().isAllowPlaceholders()) { PlaceholdersManager.untrack(this); } } @@ -75,7 +76,7 @@ public class BaseTextLine extends BaseTouchableLine implements TextLine { nameableEntity.setCustomNameNMS(text); } - if (getParent().isAllowPlaceholders()) { + if (getBaseParent().isAllowPlaceholders()) { PlaceholdersManager.trackIfNecessary(this); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/DefaultVisibilityManager.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/DefaultVisibilityManager.java index de25aea4..0b28fb08 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/DefaultVisibilityManager.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/base/DefaultVisibilityManager.java @@ -8,6 +8,7 @@ package me.filoghost.holographicdisplays.object.base; import me.filoghost.fcommons.Preconditions; import me.filoghost.holographicdisplays.api.VisibilityManager; import me.filoghost.holographicdisplays.bridge.protocollib.ProtocolLibHook; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologram.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologram.java index b8609e6e..ce857aaa 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologram.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologram.java @@ -5,12 +5,13 @@ */ package me.filoghost.holographicdisplays.object.internal; -import me.filoghost.holographicdisplays.api.line.ItemLine; -import me.filoghost.holographicdisplays.api.line.TextLine; +import me.filoghost.holographicdisplays.HolographicDisplays; import me.filoghost.holographicdisplays.core.nms.NMSManager; -import me.filoghost.holographicdisplays.object.base.BaseHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; +import me.filoghost.holographicdisplays.disk.Configuration; import org.bukkit.Location; -import org.bukkit.inventory.ItemStack; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import java.util.ArrayList; import java.util.List; @@ -22,7 +23,6 @@ public class InternalHologram extends BaseHologram { protected InternalHologram(Location source, String name, NMSManager nmsManager) { super(source, nmsManager); - super.setAllowPlaceholders(true); this.name = name; this.lines = new ArrayList<>(); } @@ -30,40 +30,40 @@ public class InternalHologram extends BaseHologram { public String getName() { return name; } - + + @Override + public Plugin getOwner() { + return HolographicDisplays.getInstance(); + } + @Override public List getLinesUnsafe() { return lines; } - + + @Override + public boolean isAllowPlaceholders() { + return true; + } + + @Override + public boolean isVisibleTo(Player player) { + return true; + } + + @Override + protected double getSpaceBetweenLines() { + return Configuration.spaceBetweenLines; + } + + @Override + public String toFormattedString() { + return name; + } + @Override public String toString() { return "InternalHologram [name=" + name + ", super=" + super.toString() + "]"; } - @Override - public TextLine appendTextLine(String text) { - throw new UnsupportedOperationException(); - } - - @Override - public ItemLine appendItemLine(ItemStack itemStack) { - throw new UnsupportedOperationException(); - } - - @Override - public TextLine insertTextLine(int index, String text) { - throw new UnsupportedOperationException(); - } - - @Override - public ItemLine insertItemLine(int index, ItemStack itemStack) { - throw new UnsupportedOperationException(); - } - - @Override - public void delete() { - throw new UnsupportedOperationException(); - } - } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologramLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologramLine.java index 7e120f54..26e15cde 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologramLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalHologramLine.java @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.object.internal; -import me.filoghost.holographicdisplays.object.base.SpawnableHologramLine; +import me.filoghost.holographicdisplays.core.object.base.SpawnableHologramLine; public interface InternalHologramLine extends SpawnableHologramLine { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalItemLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalItemLine.java index a89d5df1..a140f35c 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalItemLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalItemLine.java @@ -5,8 +5,8 @@ */ package me.filoghost.holographicdisplays.object.internal; -import me.filoghost.holographicdisplays.object.base.BaseHologram; -import me.filoghost.holographicdisplays.object.base.BaseItemLine; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseItemLine; import org.bukkit.inventory.ItemStack; public class InternalItemLine extends BaseItemLine implements InternalHologramLine { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalTextLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalTextLine.java index e9d60ebd..2ede9fea 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalTextLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/internal/InternalTextLine.java @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.object.internal; -import me.filoghost.holographicdisplays.object.base.BaseHologram; +import me.filoghost.holographicdisplays.core.object.base.BaseHologram; import me.filoghost.holographicdisplays.object.base.BaseTextLine; public class InternalTextLine extends BaseTextLine implements InternalHologramLine { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/util/NMSVersion.java b/plugin/src/main/java/me/filoghost/holographicdisplays/util/NMSVersion.java index 6a806d1f..eb32e266 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/util/NMSVersion.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/util/NMSVersion.java @@ -6,7 +6,6 @@ package me.filoghost.holographicdisplays.util; import me.filoghost.fcommons.Preconditions; -import me.filoghost.holographicdisplays.core.nms.ItemPickupManager; import me.filoghost.holographicdisplays.core.nms.NMSManager; import me.filoghost.holographicdisplays.core.nms.PacketController; import org.bukkit.Bukkit; @@ -42,8 +41,8 @@ public enum NMSVersion { this.nmsManagerConstructor = nmsManagerConstructor; } - public static NMSManager createNMSManager(ItemPickupManager itemPickupManager, PacketController packetController) { - return getValid().nmsManagerConstructor.create(itemPickupManager, packetController); + public static NMSManager createNMSManager(PacketController packetController) { + return getValid().nmsManagerConstructor.create(packetController); } private static NMSVersion extractCurrentVersion() { @@ -76,7 +75,7 @@ public enum NMSVersion { private interface NMSManagerConstructor { - NMSManager create(ItemPickupManager itemPickupManager, PacketController packetController); + NMSManager create(PacketController packetController); }