From 4f79661aa902bae371e3cfa4b91ee51b3adf31ed Mon Sep 17 00:00:00 2001 From: joethei Date: Fri, 14 Oct 2016 13:53:23 +0200 Subject: [PATCH] + changed ItemHologram so they use Bukkit ItemStacks instead of NMS ItemStacks. --- .../java/eu/univento/core/api/Hologram.java | 18 ++++++++++++++++-- src/main/java/eu/univento/core/api/Utils.java | 1 - 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/univento/core/api/Hologram.java b/src/main/java/eu/univento/core/api/Hologram.java index 82dc258..8a20450 100644 --- a/src/main/java/eu/univento/core/api/Hologram.java +++ b/src/main/java/eu/univento/core/api/Hologram.java @@ -2,10 +2,15 @@ package eu.univento.core.api; import eu.univento.core.Core; import eu.univento.core.api.player.CustomPlayer; -import net.minecraft.server.v1_10_R1.*; +import net.minecraft.server.v1_10_R1.EntityArmorStand; +import net.minecraft.server.v1_10_R1.EnumHand; +import net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; @@ -13,11 +18,13 @@ import java.util.List; public class Hologram { private final List entitylist = new ArrayList<>(); + private final ItemStack item; private final String[] text; private final Location location; private int count; - public Hologram(String[] text, Location location) { + public Hologram(ItemStack item, String[] text, Location location) { + this.item = item; this.text = text; this.location = location; create(); @@ -70,6 +77,13 @@ public class Hologram { private void create() { double DISTANCE = 0.25D; + EntityArmorStand stand = new EntityArmorStand(((CraftWorld) this.location.getWorld()).getHandle(),this.location.getX(), this.location.getY(),this.location.getZ()); + stand.a(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(item)); + stand.setInvisible(true); + stand.setNoGravity(true); + entitylist.add(stand); + this.location.subtract(0, DISTANCE, 0); + count++; for (String text : this.text) { EntityArmorStand entity = new EntityArmorStand(((CraftWorld) this.location.getWorld()).getHandle(),this.location.getX(), this.location.getY(),this.location.getZ()); entity.setCustomName(text); diff --git a/src/main/java/eu/univento/core/api/Utils.java b/src/main/java/eu/univento/core/api/Utils.java index d2566fe..a10adae 100644 --- a/src/main/java/eu/univento/core/api/Utils.java +++ b/src/main/java/eu/univento/core/api/Utils.java @@ -36,7 +36,6 @@ public class Utils { * * @param e Effect */ - @SuppressWarnings("deprecation") public static void playEffectToAll(Effect e) { for (Player all : Bukkit.getOnlinePlayers()) all.playEffect(all.getLocation(), e, 3);