use of net.minecraft.server.v1_11_R1.EntityTrackerEntry in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelper_v1_11_R1 method hideEntity.
@Override
public void hideEntity(Player player, Entity entity, boolean keepInTabList) {
// Use Bukkit API for Player entities
if (entity instanceof Player) {
player.hidePlayer((Player) entity);
return;
}
CraftPlayer craftPlayer = (CraftPlayer) player;
EntityPlayer entityPlayer = craftPlayer.getHandle();
UUID playerUUID = player.getUniqueId();
if (entityPlayer.playerConnection != null && !craftPlayer.equals(entity)) {
if (!hiddenEntities.containsKey(playerUUID)) {
hiddenEntities.put(playerUUID, new HashSet<UUID>());
}
Set hidden = hiddenEntities.get(playerUUID);
UUID entityUUID = entity.getUniqueId();
if (!hidden.contains(entityUUID)) {
hidden.add(entityUUID);
EntityTracker tracker = ((WorldServer) craftPlayer.getHandle().world).tracker;
net.minecraft.server.v1_11_R1.Entity other = ((CraftEntity) entity).getHandle();
EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId());
if (entry != null) {
entry.clear(entityPlayer);
}
}
}
}
use of net.minecraft.server.v1_11_R1.EntityTrackerEntry in project Citizens2 by CitizensDev.
the class NMSImpl method replaceTrackerEntry.
@Override
public void replaceTrackerEntry(Player player) {
WorldServer server = (WorldServer) NMSImpl.getHandle(player).getWorld();
EntityTrackerEntry entry = server.getTracker().trackedEntities.get(player.getEntityId());
if (entry == null)
return;
PlayerlistTrackerEntry replace = new PlayerlistTrackerEntry(entry);
server.getTracker().trackedEntities.a(player.getEntityId(), replace);
if (TRACKED_ENTITY_SET != null) {
try {
Set<Object> set = (Set<Object>) TRACKED_ENTITY_SET.get(server.getTracker());
set.remove(entry);
set.add(replace);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
use of net.minecraft.server.v1_11_R1.EntityTrackerEntry in project Citizens2 by CitizensDev.
the class NMSImpl method replaceTrackerEntry.
@Override
public void replaceTrackerEntry(Player player) {
WorldServer server = (WorldServer) NMSImpl.getHandle(player).getWorld();
EntityTrackerEntry entry = server.getTracker().trackedEntities.get(player.getEntityId());
if (entry == null)
return;
PlayerlistTrackerEntry replace = new PlayerlistTrackerEntry(entry);
server.getTracker().trackedEntities.a(player.getEntityId(), replace);
if (TRACKED_ENTITY_SET != null) {
try {
Set<Object> set = (Set<Object>) TRACKED_ENTITY_SET.get(server.getTracker());
set.remove(entry);
set.add(replace);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
use of net.minecraft.server.v1_11_R1.EntityTrackerEntry in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelper_v1_11_R1 method unhideEntity.
@Override
public void unhideEntity(Player player, Entity entity) {
// Use Bukkit API for Player entities
if (entity instanceof Player) {
player.showPlayer((Player) entity);
return;
}
CraftPlayer craftPlayer = (CraftPlayer) player;
EntityPlayer entityPlayer = craftPlayer.getHandle();
UUID playerUUID = player.getUniqueId();
if (entityPlayer.playerConnection != null && !craftPlayer.equals(entity) && hiddenEntities.containsKey(playerUUID)) {
Set hidden = hiddenEntities.get(playerUUID);
UUID entityUUID = entity.getUniqueId();
if (hidden.contains(entityUUID)) {
hidden.remove(entityUUID);
EntityTracker tracker = ((WorldServer) craftPlayer.getHandle().world).tracker;
net.minecraft.server.v1_11_R1.Entity other = ((CraftEntity) entity).getHandle();
EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId());
if (entry != null && !entry.trackedPlayers.contains(entityPlayer)) {
entry.updatePlayer(entityPlayer);
}
}
}
}
use of net.minecraft.server.v1_11_R1.EntityTrackerEntry in project Citizens2 by CitizensDev.
the class NMSImpl method replaceTrackerEntry.
@Override
public void replaceTrackerEntry(Player player) {
WorldServer server = (WorldServer) NMSImpl.getHandle(player).getWorld();
EntityTrackerEntry entry = server.getTracker().trackedEntities.get(player.getEntityId());
if (entry == null)
return;
PlayerlistTrackerEntry replace = new PlayerlistTrackerEntry(entry);
server.getTracker().trackedEntities.a(player.getEntityId(), replace);
if (TRACKED_ENTITY_SET != null) {
try {
Set<Object> set = (Set<Object>) TRACKED_ENTITY_SET.get(server.getTracker());
set.remove(entry);
set.add(replace);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Aggregations