use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class PlayerlistTrackerEntry method updateLastPlayer.
public void updateLastPlayer() {
if (lastUpdatedPlayer == null)
return;
final Entity tracker = getTracker(this);
final EntityPlayer entityplayer = lastUpdatedPlayer;
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
lastUpdatedPlayer = null;
if (!Setting.DISABLE_TABLIST.asBoolean())
return;
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
}
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asInt());
}
use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method removeFromWorld.
@Override
public void removeFromWorld(org.bukkit.entity.Entity entity) {
Preconditions.checkNotNull(entity);
Entity nmsEntity = ((CraftEntity) entity).getHandle();
((WorldServer) nmsEntity.world).removeEntity(nmsEntity);
}
use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method registerEntityClass.
@Override
public void registerEntityClass(Class<?> clazz) {
if (ENTITY_REGISTRY == null)
return;
Class<?> search = clazz;
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
MinecraftKey key = ENTITY_REGISTRY.getKey(type);
if (key == null || type == null)
continue;
CITIZENS_ENTITY_TYPES.put(clazz, type);
int code = ENTITY_REGISTRY.a(type);
ENTITY_REGISTRY.put(code, key, type);
return;
}
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method removeHookIfNecessary.
@Override
public void removeHookIfNecessary(NPCRegistry npcRegistry, FishHook entity) {
if (FISHING_HOOK_HOOKED == null)
return;
EntityFishingHook hook = (EntityFishingHook) NMSImpl.getHandle(entity);
Entity hooked = null;
try {
hooked = (Entity) FISHING_HOOK_HOOKED.invoke(hook);
} catch (Throwable e) {
e.printStackTrace();
}
if (hooked == null)
return;
NPC npc = npcRegistry.getNPC(hooked.getBukkitEntity());
if (npc == null)
return;
if (npc.isProtected()) {
try {
FISHING_HOOK_HOOKED_SETTER.invoke(hook, null);
} catch (Throwable e) {
e.printStackTrace();
}
hook.die();
}
}
use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method setNoGravity.
@Override
public void setNoGravity(org.bukkit.entity.Entity entity, boolean enabled) {
Entity handle = getHandle(entity);
handle.setNoGravity(enabled);
if (!(handle instanceof EntityInsentient) || !(entity instanceof NPCHolder))
return;
EntityInsentient mob = (EntityInsentient) handle;
NPC npc = ((NPCHolder) entity).getNPC();
if (!(mob.getControllerMove() instanceof ControllerMoveFlying) || npc.data().has("flying-nogravity-float"))
return;
try {
if (enabled) {
boolean old = (boolean) FLYING_MOVECONTROL_FLOAT_GETTER.invoke(mob.getControllerMove());
FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), true);
npc.data().set("flying-nogravity-float", old);
} else if (npc.data().has("flying-nogravity-float")) {
FLYING_MOVECONTROL_FLOAT_SETTER.invoke(mob.getControllerMove(), npc.data().get("flying-nogravity-float"));
npc.data().remove("flying-nogravity-float");
}
} catch (Throwable t) {
t.printStackTrace();
}
}
Aggregations