use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.
the class NMSImpl method look.
@Override
public void look(org.bukkit.entity.Entity entity, float yaw, float pitch) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null)
return;
yaw = Util.clampYaw(yaw);
handle.yaw = yaw;
setHeadYaw(entity, yaw);
handle.pitch = pitch;
}
use of org.bukkit.craftbukkit.v1_18_R2.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.bukkit.craftbukkit.v1_18_R2.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.bukkit.craftbukkit.v1_18_R2.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.bukkit.craftbukkit.v1_18_R2.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();
}
}
Aggregations