use of org.bukkit.craftbukkit.v1_18_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method changeChunkServerThread.
@Override
public void changeChunkServerThread(World world) {
if (DenizenCoreImplementation.tagThread == null) {
return;
}
if (resetServerThread != null) {
return;
}
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
ServerChunkCache provider = nmsWorld.getChunkSource();
try {
resetServerThread = (Thread) chunkProviderServerThreadField.get(provider);
chunkProviderServerThreadFieldSetter.invoke(provider, Thread.currentThread());
worldThreadFieldSetter.invoke(nmsWorld, Thread.currentThread());
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of org.bukkit.craftbukkit.v1_18_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method restoreServerThread.
@Override
public void restoreServerThread(World world) {
if (DenizenCoreImplementation.tagThread == null) {
return;
}
if (resetServerThread == null) {
return;
}
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
ServerChunkCache provider = nmsWorld.getChunkSource();
try {
chunkProviderServerThreadFieldSetter.invoke(provider, resetServerThread);
worldThreadFieldSetter.invoke(nmsWorld, resetServerThread);
resetServerThread = null;
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of org.bukkit.craftbukkit.v1_18_R1.CraftWorld in project MyPet by xXKeyleXx.
the class CustomInventory method dropContentAt.
public void dropContentAt(Location loc) {
World world = ((CraftWorld) loc.getWorld()).getHandle();
for (int i = 0; i < this.getSize(); i++) {
ItemStack is = this.splitWithoutUpdate(i);
if (is != null && CraftMagicNumbers.getMaterial(is.getItem()) != org.bukkit.Material.AIR) {
is = is.cloneItemStack();
EntityItem itemEntity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), is);
itemEntity.pickupDelay = 20;
world.addEntity(itemEntity);
}
}
}
use of org.bukkit.craftbukkit.v1_18_R1.CraftWorld in project MyPet by xXKeyleXx.
the class EntityRegistry method createMinecraftEntity.
@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
EntityMyPet petEntity = null;
Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
World world = ((CraftWorld) bukkitWorld).getHandle();
try {
Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
Object obj = ctor.newInstance(world, pet);
if (obj instanceof EntityMyPet) {
petEntity = (EntityMyPet) obj;
}
} catch (Exception e) {
MyPetApi.getLogger().info(ChatColor.RED + Util.getClassName(entityClass) + "(" + pet.getPetType() + ") is no valid MyPet(Entity)!");
e.printStackTrace();
}
return petEntity;
}
use of org.bukkit.craftbukkit.v1_18_R1.CraftWorld in project MyPet by xXKeyleXx.
the class EntityRegistry method createMinecraftEntity.
@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
EntityMyPet petEntity = null;
Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
World world = ((CraftWorld) bukkitWorld).getHandle();
try {
Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
Object obj = ctor.newInstance(world, pet);
if (obj instanceof EntityMyPet) {
petEntity = (EntityMyPet) obj;
}
} catch (Exception e) {
MyPetApi.getLogger().info(ChatColor.RED + Util.getClassName(entityClass) + "(" + pet.getPetType() + ") is no valid MyPet(Entity)!");
e.printStackTrace();
}
return petEntity;
}
Aggregations