org.bukkit.Chunk Java Examples
The following examples show how to use
org.bukkit.Chunk.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleChunkManager.java From EntityAPI with GNU Lesser General Public License v3.0 | 7 votes |
@EventHandler public void onUnload(ChunkUnloadEvent event) { Chunk unloadedChunk = event.getChunk(); for (Entity entity : unloadedChunk.getEntities()) { if (entity instanceof LivingEntity) { Object handle = BukkitUnwrapper.getInstance().unwrap(entity); if (handle instanceof ControllableEntityHandle) { ControllableEntity controllableEntity = ((ControllableEntityHandle) handle).getControllableEntity(); if (controllableEntity != null && controllableEntity.isSpawned()) { this.SPAWN_QUEUE.add(new EntityChunkData(controllableEntity, entity.getLocation())); controllableEntity.despawn(DespawnReason.CHUNK_UNLOAD); } } } } }
Example #2
Source File: CraftWorld.java From Thermos with GNU General Public License v3.0 | 6 votes |
private void chunkLoadPostProcess(net.minecraft.world.chunk.Chunk chunk, int x, int z) { if (chunk != null) { world.theChunkProviderServer.loadedChunkHashMap_KC.add(LongHash.toLong(x, z), chunk); // Passes to chunkt_TH world.theChunkProviderServer.loadedChunks.add(chunk); // Cauldron - vanilla compatibility chunk.onChunkLoad(); if (!chunk.isTerrainPopulated && world.theChunkProviderServer.chunkExists(x + 1, z + 1) && world.theChunkProviderServer.chunkExists(x, z + 1) && world.theChunkProviderServer.chunkExists(x + 1, z)) { world.theChunkProviderServer.populate(world.theChunkProviderServer, x, z); } if (world.theChunkProviderServer.chunkExists(x - 1, z) && !world.theChunkProviderServer.provideChunk(x - 1, z).isTerrainPopulated && world.theChunkProviderServer.chunkExists(x - 1, z + 1) && world.theChunkProviderServer.chunkExists(x, z + 1) && world.theChunkProviderServer.chunkExists(x - 1, z)) { world.theChunkProviderServer.populate(world.theChunkProviderServer, x - 1, z); } if (world.theChunkProviderServer.chunkExists(x, z - 1) && !world.theChunkProviderServer.provideChunk(x, z - 1).isTerrainPopulated && world.theChunkProviderServer.chunkExists(x + 1, z - 1) && world.theChunkProviderServer.chunkExists(x, z - 1) && world.theChunkProviderServer.chunkExists(x + 1, z)) { world.theChunkProviderServer.populate(world.theChunkProviderServer, x, z - 1); } if (world.theChunkProviderServer.chunkExists(x - 1, z - 1) && !world.theChunkProviderServer.provideChunk(x - 1, z - 1).isTerrainPopulated && world.theChunkProviderServer.chunkExists(x - 1, z - 1) && world.theChunkProviderServer.chunkExists(x, z - 1) && world.theChunkProviderServer.chunkExists(x - 1, z)) { world.theChunkProviderServer.populate(world.theChunkProviderServer, x - 1, z - 1); } } }
Example #3
Source File: WorldManager.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
/** * Removes all unnamed {@link Monster}'s at the given {@link Location}. * @param target Location to remove unnamed monsters. */ public void removeCreatures(@Nullable final Location target) { if (!Settings.island_removeCreaturesByTeleport || target == null || target.getWorld() == null) { return; } final int px = target.getBlockX(); final int py = target.getBlockY(); final int pz = target.getBlockZ(); for (int x = -1; x <= 1; ++x) { for (int z = -1; z <= 1; ++z) { Chunk chunk = target.getWorld().getChunkAt( new Location(target.getWorld(), (px + x * 16), py, (pz + z * 16))); Arrays.stream(chunk.getEntities()) .filter(entity -> entity instanceof Monster) .filter(entity -> entity.getCustomName() == null) .forEach(Entity::remove); } } }
Example #4
Source File: ChunkEventHelper.java From ClaimChunk with MIT License | 6 votes |
public static void handleToFromEvent(@Nonnull BlockFromToEvent e) { if (e.isCancelled()) return; // Only continue if we should stop the spread from the config. if (!config.getBool("protection", "blockFluidSpreadIntoClaims")) return; // If the block isn't water or lava, we don't protect it. Material blockType = e.getBlock().getType(); if (blockType != Material.WATER && blockType != Material.LAVA) return; Chunk from = e.getBlock().getChunk(); Chunk to = e.getToBlock().getChunk(); // If the from and to chunks have the same owner or if the to chunk is // unclaimed, the flow is allowed. final ChunkHandler CHUNK = ClaimChunk.getInstance().getChunkHandler(); if (getChunksSameOwner(CHUNK, from, to) || !CHUNK.isClaimed(to)) return; // Cancel the flow e.setCancelled(true); }
Example #5
Source File: ExprEntities.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { types = (Expression<? extends EntityData<?>>) exprs[0]; if (matchedPattern % 2 == 0) { for (EntityData<?> d : ((Literal<EntityData<?>>) types).getAll()) { if (d.isPlural().isFalse() || d.isPlural().isUnknown() && !StringUtils.startsWithIgnoreCase(parseResult.expr, "all")) return false; } } isUsingRadius = matchedPattern >= 2; if (isUsingRadius) { radius = (Expression<Number>) exprs[exprs.length - 2]; center = (Expression<Location>) exprs[exprs.length - 1]; } else { if (parseResult.mark == 1) { chunks = (Expression<Chunk>) exprs[2]; } else { worlds = (Expression<World>) exprs[1]; } } if (types instanceof Literal && ((Literal<EntityData<?>>) types).getAll().length == 1) returnType = ((Literal<EntityData<?>>) types).getSingle().getType(); return true; }
Example #6
Source File: HologramListener.java From Holograms with MIT License | 6 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { Chunk chunk = event.getChunk(); if (chunk == null || !chunk.isLoaded()) { return; } Collection<Hologram> holograms = plugin.getHologramManager().getActiveHolograms().values(); for (Hologram holo : holograms) { int chunkX = (int) Math.floor(holo.getLocation().getBlockX() / 16.0D); int chunkZ = (int) Math.floor(holo.getLocation().getBlockZ() / 16.0D); if (chunkX == chunk.getX() && chunkZ == chunk.getZ()) { plugin.getServer().getScheduler().runTaskLater(plugin, holo::spawn, 10L); } } }
Example #7
Source File: WorldGuardSevenCommunicator.java From WorldGuardExtraFlagsPlugin with MIT License | 6 votes |
@Override public boolean doUnloadChunkFlagCheck(org.bukkit.World world, Chunk chunk) { for (ProtectedRegion region : this.getRegionContainer().get(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16), BlockVector3.at(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15)))) { if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY) { if (WorldGuardSevenCommunicator.supportsForceLoad) { chunk.setForceLoaded(true); chunk.load(true); return true; } return false; } } return true; }
Example #8
Source File: NMSImpl.java From TabooLib with MIT License | 6 votes |
private int distance(Object from, Object to) { if (is11600) { String name1 = ((WorldDataServer) ((net.minecraft.server.v1_16_R1.Chunk) from).world.getWorldData()).getName(); String name2 = ((WorldDataServer) ((net.minecraft.server.v1_16_R1.Chunk) to).world.getWorldData()).getName(); if (!name1.equals(name2)) { return 100; } } else { if (!((net.minecraft.server.v1_14_R1.Chunk) from).world.getWorldData().getName().equals(((net.minecraft.server.v1_14_R1.Chunk) to).world.getWorldData().getName())) { return 100; } } double var2 = ((net.minecraft.server.v1_14_R1.Chunk) to).getPos().x - ((net.minecraft.server.v1_14_R1.Chunk) from).getPos().x; double var4 = ((net.minecraft.server.v1_14_R1.Chunk) to).getPos().z - ((net.minecraft.server.v1_14_R1.Chunk) from).getPos().z; return (int) Math.sqrt(var2 * var2 + var4 * var4); }
Example #9
Source File: ShopkeepersPlugin.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
/** * Unloads (deactivates) all shopkeepers in the given chunk. * * @param chunk * the chunk * @return the number of shops in the affected chunk */ int unloadShopkeepersInChunk(Chunk chunk) { assert chunk != null; int affectedShops = 0; List<Shopkeeper> shopkeepers = this.getShopkeepersInChunk(new ChunkData(chunk)); if (shopkeepers != null) { affectedShops = shopkeepers.size(); Log.debug("Unloading " + affectedShops + " shopkeepers in chunk " + chunk.getX() + "," + chunk.getZ()); for (Shopkeeper shopkeeper : shopkeepers) { // inform shopkeeper about chunk unload: shopkeeper.onChunkUnload(); // skip shopkeepers which are kept active all the time (ex. sign, citizens shops): if (!shopkeeper.needsSpawning()) continue; // deactivate: this.deactivateShopkeeper(shopkeeper, false); } } return affectedShops; }
Example #10
Source File: InvisibleBlock.java From CardinalPGM with MIT License | 6 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { final Chunk chunk = event.getChunk(); Bukkit.getScheduler().runTask(GameHandler.getGameHandler().getPlugin(), new Runnable() { @Override public void run() { for (Block block36 : chunk.getBlocks(Material.getMaterial(36))) { block36.setType(Material.AIR); block36.setMetadata("block36", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true)); } for (Block door : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) { if (door.getRelative(BlockFace.DOWN).getType() != Material.IRON_DOOR_BLOCK && door.getRelative(BlockFace.UP).getType() != Material.IRON_DOOR_BLOCK) door.setType(Material.BARRIER); } } }); }
Example #11
Source File: BiomeTypePopulator.java From UhcCore with GNU General Public License v3.0 | 6 votes |
@Override public void populate(World world, Random random, Chunk chunk){ for (int x = 1; x < 15; x++) { for (int z = 1; z < 15; z++) { Block block = chunk.getBlock(x, 1, z); Biome replacementBiome = getReplacementBiome(block.getBiome()); if (UhcCore.getVersion() < 16){ if (replacementBiome != null) { block.setBiome(replacementBiome); } }else { for (int y = 0; y < 200; y++) { block = chunk.getBlock(x, y, z); if (replacementBiome != null) { block.setBiome(replacementBiome); } } } } } }
Example #12
Source File: BlockListener.java From civcraft with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.NORMAL) public void OnBlockFormEvent (BlockFormEvent event) { /* Disable cobblestone generators. */ if (ItemManager.getId(event.getNewState()) == CivData.COBBLESTONE) { ItemManager.setTypeId(event.getNewState(), CivData.GRAVEL); return; } Chunk spreadChunk = event.getNewState().getChunk(); coord.setX(spreadChunk.getX()); coord.setZ(spreadChunk.getZ()); coord.setWorldname(spreadChunk.getWorld().getName()); TownChunk tc = CivGlobal.getTownChunk(coord); if (tc == null) { return; } if (tc.perms.isFire() == false) { if(event.getNewState().getType() == Material.FIRE) { event.setCancelled(true); } } }
Example #13
Source File: SnapshotMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockChange(BlockTransformEvent event) { Match match = PGM.get().getMatchManager().getMatch(event.getWorld()); // Dont carry over old chunks into a new match if (match == null || match.isFinished()) return; Chunk chunk = event.getOldState().getChunk(); ChunkVector chunkVector = ChunkVector.of(chunk); if (!chunkSnapshots.containsKey(chunkVector)) { match.getLogger().fine("Copying chunk at " + chunkVector); ChunkSnapshot chunkSnapshot = chunk.getChunkSnapshot(); chunkSnapshot.updateBlock( event .getOldState()); // ChunkSnapshot is very likely to have the post-event state already, // so we have to correct it chunkSnapshots.put(chunkVector, chunkSnapshot); } }
Example #14
Source File: WorldListener.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onWorldUnload(WorldUnloadEvent e) { // FIXME: 24/11/2019 It's not necessary but ok. // This is a workaround, because I don't get parsed chunk events when a // world unloads, I think... // So manually tell all of these shops they're unloaded. for (final Chunk chunk : e.getWorld().getLoadedChunks()) { final Map<Location, Shop> inChunk = plugin.getShopManager().getShops(chunk); if (inChunk == null) { continue; } for (final Shop shop : inChunk.values()) { if (shop.isLoaded()) { //Don't unload already unloaded shops. shop.onUnload(); } } } }
Example #15
Source File: CraftChunk.java From Kettle with GNU General Public License v3.0 | 5 votes |
public CraftChunk(net.minecraft.world.chunk.Chunk chunk) { this.weakChunk = new WeakReference<net.minecraft.world.chunk.Chunk>(chunk); worldServer = (WorldServer) getHandle().getWorld(); x = getHandle().x; z = getHandle().z; }
Example #16
Source File: WorldProblemMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private void checkChunk(ChunkPosition pos, @Nullable Chunk chunk) { if(repairedChunks.add(pos)) { if(chunk == null) { chunk = pos.getChunk(match.getWorld()); } for(BlockState state : chunk.getTileEntities()) { if(state instanceof Skull) { if(!NMSHacks.isSkullCached((Skull) state)) { Location loc = state.getLocation(); broadcastDeveloperWarning("Uncached skull \"" + ((Skull) state).getOwner() + "\" at " + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ()); } } } // Replace formerly invisible half-iron-door blocks with barriers for(Block ironDoor : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) { BlockFace half = (ironDoor.getData() & 8) == 0 ? BlockFace.DOWN : BlockFace.UP; if(ironDoor.getRelative(half.getOppositeFace()).getType() != Material.IRON_DOOR_BLOCK) { ironDoor.setType(Material.BARRIER, false); } } // Remove all block 36 and remember the ones at y=0 so VoidFilter can check them for(Block block36 : chunk.getBlocks(Material.PISTON_MOVING_PIECE)) { if(block36.getY() == 0) { block36Locations.add(block36.getX(), block36.getY(), block36.getZ()); } block36.setType(Material.AIR, false); } } }
Example #17
Source File: ChunkEventHelper.java From ClaimChunk with MIT License | 5 votes |
private static void handlePistonEvent(@Nonnull Block piston, @Nonnull List<Block> blocks, @Nonnull BlockFace direction, @Nonnull Cancellable e) { if (e.isCancelled()) return; // If we don't protect against pistons, no work is needed. if (!config.getBool("protection", "blockPistonsIntoClaims")) return; Chunk pistonChunk = piston.getChunk(); List<Chunk> blockChunks = new ArrayList<>(); blockChunks.add(piston.getRelative(direction).getChunk()); // Add to the list of chunks possible affected by this piston // extension. This list should never be >2 in size but the world // is a weird place. for (Block block : blocks) { Chunk to = block.getRelative(direction).getChunk(); boolean added = false; for (Chunk ablockChunk : blockChunks) { if (getChunksEqual(ablockChunk, to)) { added = true; break; } } if (!added) blockChunks.add(to); } // If the from and to chunks have the same owner or if the to chunk is // unclaimed, the piston can extend into the blockChunk. final ChunkHandler CHUNK = ClaimChunk.getInstance().getChunkHandler(); boolean die = false; for (Chunk blockChunk : blockChunks) { if (!getChunksSameOwner(CHUNK, pistonChunk, blockChunk) && CHUNK.isClaimed(blockChunk)) { die = true; break; } } if (!die) return; e.setCancelled(true); }
Example #18
Source File: GridManager.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Removes monsters around location l * * @param l location */ public void removeMobs(final Location l) { if (!inWorld(l)) { return; } //plugin.getLogger().info("DEBUG: removing mobs"); // Don't remove mobs if at spawn if (this.isAtSpawn(l)) { //plugin.getLogger().info("DEBUG: at spawn!"); return; } final int px = l.getBlockX(); final int py = l.getBlockY(); final int pz = l.getBlockZ(); for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { final Chunk c = l.getWorld().getChunkAt(new Location(l.getWorld(), px + x * 16, py, pz + z * 16)); if (c.isLoaded()) { for (final Entity e : c.getEntities()) { //plugin.getLogger().info("DEBUG: " + e.getType()); // Don't remove if the entity is an NPC or has a name tag if (e.getCustomName() != null || e.hasMetadata("NPC")) continue; if (e instanceof Monster && !Settings.mobWhiteList.contains(e.getType())) { e.remove(); } } } } } }
Example #19
Source File: BukkitQueue_1_9_R1.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public boolean hasEntities(net.minecraft.server.v1_9_R2.Chunk nmsChunk) { for (int i = 0; i < nmsChunk.entitySlices.length; i++) { List<Entity> slice = nmsChunk.entitySlices[i]; if (slice != null && !slice.isEmpty()) { return true; } } return false; }
Example #20
Source File: AsyncChunksSync.java From PaperLib with MIT License | 5 votes |
@Override public CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean gen, boolean isUrgent) { if (!gen && !PaperLib.isChunkGenerated(world, x, z)) { return CompletableFuture.completedFuture(null); } else { return CompletableFuture.completedFuture(world.getChunkAt(x, z)); } }
Example #21
Source File: WorldGuardApi.java From ClaimChunk with MIT License | 5 votes |
static boolean _isAllowedClaim(ClaimChunk claimChunk, Chunk chunk) { try { // Generate a region in the given chunk to get all intersecting regions int bx = chunk.getX() << 4; int bz = chunk.getZ() << 4; BlockVector3 pt1 = BlockVector3.at(bx, 0, bz); BlockVector3 pt2 = BlockVector3.at(bx + 15, 256, bz + 15); ProtectedCuboidRegion region = new ProtectedCuboidRegion("_", pt1, pt2); RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(chunk.getWorld())); // No regions in this world, claiming should be determined by the config if (regionManager == null) { return claimChunk.chConfig().getBool("worldguard", "allowClaimingInNonGuardedWorlds"); } // If any regions in the given chunk deny chunk claiming, false is returned for (ProtectedRegion regionIn : regionManager.getApplicableRegions(region)) { StateFlag.State flag = regionIn.getFlag(FLAG_CHUNK_CLAIM); if (flag == StateFlag.State.DENY) return false; } // No objections return true; } catch (Exception e) { e.printStackTrace(); } // An error occurred, better to be on the safe side so false is returned return false; }
Example #22
Source File: ChunkSorter.java From GlobalWarming with GNU Lesser General Public License v3.0 | 5 votes |
public static List<Chunk> sortByDistance(Chunk[] chunks, Map<GChunk, Integer> waterLevel, List<Player> players, int height, int numChunks) { if (players.size() == 0) { return Arrays.asList(chunks).subList(0, Math.min(numChunks, chunks.length)); } else { List<Chunk> sortedChunks = new ArrayList<>(); for (Chunk chunk : chunks) { GChunk gchunk = new GChunk(chunk); if (waterLevel.containsKey(gchunk)) { int seaLevel = waterLevel.get(gchunk); if (seaLevel == height) { continue; } } sortedChunks.add(chunk); } sortedChunks.sort((o1, o2) -> { Location l1 = chunkToLocation(o1); Location l2 = chunkToLocation(o2); double d1 = 0; double d2 = 0; for (Player player : players) { d1 += l1.distance(player.getLocation()); d2 += l2.distance(player.getLocation()); } d1 /= players.size(); d2 /= players.size(); return Double.compare(d1, d2); }); return sortedChunks.subList(0, Math.min(numChunks, sortedChunks.size())); } }
Example #23
Source File: DebugCommand.java From civcraft with GNU General Public License v2.0 | 5 votes |
public void show_cmd() throws CivException { Player player = getPlayer(); Chunk chunk = player.getLocation().getChunk(); for (Entity entity : chunk.getEntities()) { CivMessage.send(player, "E:"+entity.getType().name()+" UUID:"+entity.getUniqueId().toString()); CivLog.info("E:"+entity.getType().name()+" UUID:"+entity.getUniqueId().toString()); } }
Example #24
Source File: GameCreator.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static boolean isChunkInArea(Chunk l, Location p1, Location p2) { if (!p1.getWorld().equals(l.getWorld())) { return false; } Chunk min = new Location(p1.getWorld(), Math.min(p1.getX(), p2.getX()), Math.min(p1.getY(), p2.getY()), Math.min(p1.getZ(), p2.getZ())).getChunk(); Chunk max = new Location(p1.getWorld(), Math.max(p1.getX(), p2.getX()), Math.max(p1.getY(), p2.getY()), Math.max(p1.getZ(), p2.getZ())).getChunk(); return (min.getX() <= l.getX() && min.getZ() <= l.getZ() && max.getX() >= l.getX() && max.getZ() >= l.getZ()); }
Example #25
Source File: WorldListener.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void onChunkUnloadEvent(ChunkUnloadEvent event) { World world = event.getWorld(); Chunk chunk = event.getChunk(); if (!this.plugin.getWorldGuardCommunicator().doUnloadChunkFlagCheck(world, chunk)) { event.setCancelled(true); } }
Example #26
Source File: CraftWorld.java From Thermos with GNU General Public License v3.0 | 5 votes |
public void setBiome(int x, int z, Biome bio) { net.minecraft.world.biome.BiomeGenBase bb = CraftBlock.biomeToBiomeBase(bio); if (this.world.blockExists(x, 0, z)) { net.minecraft.world.chunk.Chunk chunk = this.world.getChunkFromBlockCoords(x, z); if (chunk != null) { byte[] biomevals = chunk.getBiomeArray(); biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.biomeID; } } }
Example #27
Source File: MainListener.java From HolographicDisplays with GNU General Public License v3.0 | 5 votes |
@EventHandler (priority = EventPriority.MONITOR) public void onChunkLoad(ChunkLoadEvent event) { Chunk chunk = event.getChunk(); // Other plugins could call this event wrongly, check if the chunk is actually loaded. if (chunk.isLoaded()) { // In case another plugin loads the chunk asynchronously always make sure to load the holograms on the main thread. if (Bukkit.isPrimaryThread()) { processChunkLoad(chunk); } else { Bukkit.getScheduler().runTask(HolographicDisplays.getInstance(), () -> processChunkLoad(chunk)); } } }
Example #28
Source File: WorldGuardSixCommunicator.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
@Override public boolean doUnloadChunkFlagCheck(org.bukkit.World world, Chunk chunk) { for (ProtectedRegion region : this.getRegionContainer().get(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", new BlockVector(chunk.getX() * 16, 0, chunk.getZ() * 16), new BlockVector(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15)))) { if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY) { return false; } } return true; }
Example #29
Source File: PlayerMovementHandler.java From ClaimChunk with MIT License | 5 votes |
private void showTitle(Player player, Chunk newChunk) { // Get the UUID of the new chunk owner UUID newOwner = claimChunk.getChunkHandler().getOwner(newChunk.getWorld(), newChunk.getX(), newChunk.getZ()); // Check if this player doesn't own the new chunk if (newOwner != null && !player.getUniqueId().equals(newOwner)) { // Get the name of the chunks for the owner of this chunk and display it PlayerHandler ph = claimChunk.getPlayerHandler(); String newName = ph.getChunkName(newOwner); String text = ((newName == null) ? claimChunk.getMessages().unknownChunkOwner // Something probably went wrong with the PlayerHandler : claimChunk.getMessages().chunkOwner.replace("%%PLAYER%%", newName)); showTitleRaw(true, player, text); // Send a message to the chunk owner if possible if (ph.hasAlerts(newOwner)) { Player owner = Bukkit.getPlayer(newOwner); if (owner != null) { if (owner.canSee(player) || !claimChunk.chConfig().getBool("chunks", "hideAlertsForVanishedPlayers")) { showTitleRaw(false, owner, claimChunk.getMessages().playerEnterChunk.replace("%%PLAYER%%", player.getDisplayName())); } } } } else { // This chunk is owned by this player showTitleRaw(true, player, claimChunk.getMessages().chunkSelf); } }
Example #30
Source File: BukkitQueue_1_10.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public boolean hasEntities(net.minecraft.server.v1_10_R1.Chunk nmsChunk) { try { final Collection<Entity>[] entities = (Collection<Entity>[]) getEntitySlices.invoke(nmsChunk); for (int i = 0; i < entities.length; i++) { Collection<Entity> slice = entities[i]; if (slice != null && !slice.isEmpty()) { return true; } } } catch (Throwable ignore) {} return false; }