+ changed ItemHologram so they use Bukkit ItemStacks instead of NMS ItemStacks.

This commit is contained in:
Johannes Theiner 2016-10-14 13:53:23 +02:00
parent 93d263d063
commit 4f79661aa9
2 changed files with 16 additions and 3 deletions

View File

@ -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<EntityArmorStand> 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);

View File

@ -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);