public Location findOrCreate(Location target) { WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle(); boolean before = worldServer.chunkProviderServer.forceChunkLoad; worldServer.chunkProviderServer.forceChunkLoad = true; Location found = this.findPortal(target); if (found == null) { if (this.getCanCreatePortal() && this.createPortal(target)) { found = this.findPortal(target); } else { found = target; // fallback to original if unable to find or create } } worldServer.chunkProviderServer.forceChunkLoad = before; return found; }
@Override public Location findOrCreate(Location target) { WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle(); boolean before = worldServer.chunkProviderServer.forceChunkLoad; worldServer.chunkProviderServer.forceChunkLoad = true; Location found = this.findPortal(target); if (found == null) { if (this.getCanCreatePortal() && this.createPortal(target)) { found = this.findPortal(target); } else { found = target; // fallback to original if unable to find or create } } worldServer.chunkProviderServer.forceChunkLoad = before; return found; }
private void update() { WorldServer world = ((CraftWorld) getWorld()).getHandle(); EntityPainting painting = new EntityPainting(world); painting.x = getHandle().x; painting.y = getHandle().y; painting.z = getHandle().z; painting.art = getHandle().art; painting.setDirection(getHandle().direction); getHandle().die(); getHandle().velocityChanged = true; // because this occurs when the painting is broken, so it might be important world.addEntity(painting); this.entity = painting; }
public boolean setFacingDirection(BlockFace face, boolean force) { if (!super.setFacingDirection(face, force)) { return false; } WorldServer world = ((CraftWorld) this.getWorld()).getHandle(); world.getTracker().untrackEntity(this.getHandle()); world.getTracker().track(this.getHandle()); return true; }
private static boolean canBuild(CraftWorld world, Player player, int x, int z) { WorldServer worldServer = world.getHandle(); int spawnSize = Bukkit.getServer().getSpawnRadius(); if (world.getHandle().dimension != 0) return true; if (spawnSize <= 0) return true; if (((CraftServer) Bukkit.getServer()).getHandle().getOPs().isEmpty()) return true; if (player.isOp()) return true; ChunkCoordinates chunkcoordinates = worldServer.getSpawn(); int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.x), Math.abs(z - chunkcoordinates.z)); return distanceFromSpawn > spawnSize; }
public CraftChunk(net.minecraft.server.Chunk chunk) { if (!(chunk instanceof EmptyChunk)) { this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk); } worldServer = (WorldServer) getHandle().world; x = getHandle().locX; z = getHandle().locZ; }
private void update() { WorldServer world = ((CraftWorld) getWorld()).getHandle(); EntityPainting painting = new EntityPainting(world); painting.blockPosition = getHandle().blockPosition; painting.art = getHandle().art; painting.setDirection(getHandle().direction); getHandle().die(); getHandle().velocityChanged = true; // because this occurs when the painting is broken, so it might be important world.addEntity(painting); this.entity = painting; }
private void update() { EntityItemFrame old = this.getHandle(); WorldServer world = ((CraftWorld) getWorld()).getHandle(); BlockPosition position = old.getBlockPosition(); EnumDirection direction = old.getDirection(); ItemStack item = old.getItem() != null ? old.getItem().cloneItemStack() : null; old.die(); EntityItemFrame frame = new EntityItemFrame(world,position,direction); frame.setItem(item); world.addEntity(frame); this.entity = frame; }
public CraftChunk(net.minecraft.server.Chunk chunk) { if (!(chunk instanceof EmptyChunk)) { this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk); } worldServer = (WorldServer) getHandle().world; x = getHandle().x; z = getHandle().z; }
@Override public Location findOrCreate(Location target) { WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle(); Location found = this.findPortal(target); if (found == null) { if (this.getCanCreatePortal() && this.createPortal(target)) { found = this.findPortal(target); } else { found = target; // fallback to original if unable to find or create } } return found; }
private static boolean canBuild(CraftWorld world, Player player, int x, int z) { WorldServer worldServer = world.getHandle(); int spawnSize = Bukkit.getServer().getSpawnRadius(); if (world.getHandle().dimension != 0) return true; if (spawnSize <= 0) return true; if (((CraftServer) Bukkit.getServer()).getHandle().getOPs().isEmpty()) return true; if (player.isOp()) return true; ChunkCoordinates chunkcoordinates = worldServer.getSpawn(); int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.x), Math.abs(z - chunkcoordinates.z)); return distanceFromSpawn >= spawnSize; }
private static EntityTrackerEntry getTrackerEntry(net.minecraft.server.Entity nms) { return ((WorldServer) nms.getWorld()).getTracker().trackedEntities.get(nms.getId()); }
public static void playEffect(World bukkitWorld, Vector pos, int effectId, int data) { WorldServer world = ((CraftWorld) bukkitWorld).getHandle(); world.triggerEffect(effectId, new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), data); }
private static void playCustomSound(World bukkitWorld, Location location, SoundEffect sound, SoundCategory category, Float volume, Float pitch) { WorldServer world = ((CraftWorld) bukkitWorld).getHandle(); world.playSoundEffect(null, location.getX(), location.getY(), location.getZ(), sound, category, volume, pitch); }
@Override public boolean unloadWorld(World world, boolean save) { if (world == null) { return false; } WorldServer handle = ((CraftWorld) world).getHandle(); if (!(console.worlds.contains(handle))) { return false; } if (!(handle.dimension > 1)) { return false; } if (handle.players.size() > 0) { return false; } WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld()); pluginManager.callEvent(e); if (e.isCancelled()) { return false; } if (save) { try { handle.save(true, null); handle.saveLevel(); WorldSaveEvent event = new WorldSaveEvent(handle.getWorld()); getPluginManager().callEvent(event); } catch (ExceptionWorldConflict ex) { getLogger().log(Level.SEVERE, null, ex); } } worlds.remove(world.getName().toLowerCase()); console.worlds.remove(console.worlds.indexOf(handle)); return true; }
public CustomChunkGenerator(World world, long seed, ChunkGenerator generator) { this.world = (WorldServer) world; this.generator = generator; this.random = new Random(seed); }
public CraftTravelAgent(WorldServer worldserver) { super(worldserver); if (DEFAULT == null && worldserver.dimension == 0) { DEFAULT = this; } }
public boolean unloadWorld(World world, boolean save) { if (world == null) { return false; } WorldServer handle = ((CraftWorld) world).getHandle(); if (!(console.worlds.contains(handle))) { return false; } if (!(handle.dimension > 1)) { return false; } if (handle.players.size() > 0) { return false; } WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld()); pluginManager.callEvent(e); if (e.isCancelled()) { return false; } if (save) { try { handle.save(true, null); handle.saveLevel(); WorldSaveEvent event = new WorldSaveEvent(handle.getWorld()); getPluginManager().callEvent(event); } catch (ExceptionWorldConflict ex) { getLogger().log(Level.SEVERE, null, ex); } } worlds.remove(world.getName().toLowerCase()); console.worlds.remove(console.worlds.indexOf(handle)); return true; }