use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method tick.
@Override
public boolean tick(org.bukkit.entity.Entity next) {
Entity entity = NMSImpl.getHandle(next);
Entity entity1 = entity.getVehicle();
if (entity1 != null) {
if ((entity1.dead) || (!entity1.w(entity))) {
entity.stopRiding();
}
} else {
if (!entity.dead) {
try {
entity.world.entityJoinedWorld(entity, true);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
entity.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
}
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
if (entity.dead) {
entity.world.removeEntity(entity);
return true;
} else if (!removeFromPlayerList) {
if (!entity.world.players.contains(entity)) {
entity.world.players.add((EntityHuman) entity);
}
return true;
} else {
entity.world.players.remove(entity);
}
}
return false;
}
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)
continue;
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 removeFromWorld.
@Override
public void removeFromWorld(org.bukkit.entity.Entity entity) {
Preconditions.checkNotNull(entity);
Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.world.removeEntity(nmsEntity);
}
use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method getDestination.
@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
use of org.hypertrace.entity.data.service.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method getVehicle.
@Override
public org.bukkit.entity.Entity getVehicle(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null) {
return null;
}
Entity e = handle.getVehicle();
return (e == handle || e == null) ? null : e.getBukkitEntity();
}
Aggregations