org.bukkit.event.world.ChunkLoadEvent Java Examples
The following examples show how to use
org.bukkit.event.world.ChunkLoadEvent.
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: WorldProblemListener.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void repairChunk(ChunkLoadEvent event) { if (this.repairedChunks.put(event.getWorld(), event.getChunk())) { // Replace formerly invisible half-iron-door blocks with barriers for (Block ironDoor : event.getChunk().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 : event.getChunk().getBlocks(Material.PISTON_MOVING_PIECE)) { if (block36.getY() == 0) { block36Locations .get(event.getWorld()) .add(block36.getX(), block36.getY(), block36.getZ()); } block36.setType(Material.AIR, false); } } }
Example #2
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 #3
Source File: MobListener.java From civcraft with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.NORMAL) public void onChunkLoad(ChunkLoadEvent event) { for (Entity e : event.getChunk().getEntities()) { if (e instanceof Monster) { e.remove(); return; } if (e instanceof IronGolem) { e.remove(); return; } } }
Example #4
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 #5
Source File: FindSuperMobs.java From EliteMobs with GNU General Public License v3.0 | 6 votes |
@EventHandler public void findSuperMob(ChunkLoadEvent event) { for (Entity entity : event.getChunk().getEntities()) { if (SuperMobProperties.isValidSuperMobType(entity)) if (((LivingEntity) entity).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() == SuperMobProperties.getDataInstance(entity).getSuperMobMaxHealth()) if (!EntityTracker.isSuperMob(entity)) EntityTracker.registerSuperMob((LivingEntity) entity); else if (entity instanceof Villager) { } } }
Example #6
Source File: WorldEventHandler.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onChunkLoad(ChunkLoadEvent event) { if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(event.getWorld().getUID())) { return; } final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getWorld().getUID()); final GDChunk gdChunk = claimWorldManager.getChunk(event.getChunk()); if (gdChunk != null) { try { gdChunk.loadChunkTrackingData(); } catch (IOException e) { e.printStackTrace(); } } }
Example #7
Source File: ShopUpdateListener.java From ShopChest with MIT License | 5 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent e) { if (!plugin.getShopDatabase().isInitialized()) { return; } // Wait 10 ticks after first event is triggered, so that multiple // chunk loads can be handled at the same time without having to // send a database request for each chunk. if (newLoadedChunks.isEmpty()) { new BukkitRunnable(){ @Override public void run() { int chunkCount = newLoadedChunks.size(); plugin.getShopUtils().loadShops(newLoadedChunks.toArray(new Chunk[chunkCount]), new Callback<Integer>(plugin) { @Override public void onResult(Integer result) { if (result == 0) { return; } plugin.debug("Loaded " + result + " shops in " + chunkCount + " chunks"); } @Override public void onError(Throwable throwable) { // Database connection probably failed => disable plugin to prevent more errors plugin.getLogger().severe("Failed to load shops in newly loaded chunks"); plugin.debug("Failed to load shops in newly loaded chunks"); if (throwable != null) plugin.debug(throwable); } }); newLoadedChunks.clear(); } }.runTaskLater(plugin, 10L); } newLoadedChunks.add(e.getChunk()); }
Example #8
Source File: SimpleChunkManager.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler private void onLoad(ChunkLoadEvent event) { Chunk loadedChunk = event.getChunk(); for (EntityChunkData entityChunkData : SPAWN_QUEUE) { if (loadedChunk == entityChunkData.getRespawnLocation().getChunk()) { if (entityChunkData.getControllableEntity().spawn(entityChunkData.getRespawnLocation()) == SpawnResult.FAILED) { throw new ControllableEntitySpawnException(); } } } }
Example #9
Source File: WorldListener.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@EventHandler void onChunkLoad(ChunkLoadEvent event) { final Chunk chunk = event.getChunk(); Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { public void run() { if (chunk.isLoaded()) { plugin.loadShopkeepersInChunk(chunk); } } }, 2); }
Example #10
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 #11
Source File: HoloListener.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onChunkLoad(ChunkLoadEvent event) { for (Hologram h : HoloAPI.getManager().getAllHolograms().keySet()) { if (h.getDefaultLocation().getChunk().equals(event.getChunk())) { for (Entity e : h.getDefaultLocation().getWorld().getEntities()) { if (e instanceof Player) { if (h.getVisibility().isVisibleTo((Player) e, h.getSaveId())) { h.show((Player) e, true); } } } } } }
Example #12
Source File: CleanSuperFlat.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onChunkLoad(ChunkLoadEvent e) { if (ASkyBlock.getIslandWorld() == null || e.getWorld() != ASkyBlock.getIslandWorld()) { if (DEBUG) Bukkit.getLogger().info("DEBUG: not right world"); return; } if (e.getChunk().getBlock(0, 0, 0).getType().equals(Material.BEDROCK)) { e.getWorld().regenerateChunk(e.getChunk().getX(), e.getChunk().getZ()); Bukkit.getLogger().warning("Regenerating superflat chunk at " + (e.getChunk().getX() * 16) + "," + (e.getChunk().getZ() * 16)); } }
Example #13
Source File: WorldLoader.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onChunkLoad(final ChunkLoadEvent event) { if (worldLoaded) { return; } if (DEBUG) plugin.getLogger().info("DEBUG: " + event.getEventName() + " : " + event.getWorld().getName()); if (event.getWorld().getName().equals(Settings.worldName) || event.getWorld().getName().equals(Settings.worldName + "_nether")) { return; } // Load the world worldLoaded = true; ASkyBlock.getIslandWorld(); }
Example #14
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onChunkLoad(ChunkLoadEvent event) { if (!Settings.saveEntities || !IslandGuard.inWorld(event.getWorld())) { return; } Arrays.asList(event.getChunk().getEntities()).forEach(entity -> { String loc = entities.getString(event.getWorld().getName() + "." + event.getChunk().getX() + "." + event.getChunk().getZ() + "." + entity.getUniqueId().toString(), ""); if (!loc.isEmpty()) { entity.setMetadata("spawnLoc", new FixedMetadataValue(plugin, loc )); } }); // Delete the chunk data entities.set(event.getWorld().getName() + "." + event.getChunk().getX() + "." + event.getChunk().getZ() , null); }
Example #15
Source File: SignsFeature.java From AreaShop with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onChunkLoad(ChunkLoadEvent event) { List<RegionSign> chunkSigns = signsByChunk.get(chunkToString(event.getChunk())); if(chunkSigns == null) { return; } Do.forAll(chunkSigns, RegionSign::update); }
Example #16
Source File: ChunkListener.java From QuickShop-Reremake with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onChunkLoad(ChunkLoadEvent e) { if (e.isNewChunk()) { return; } final Map<Location, Shop> inChunk = plugin.getShopManager().getShops(e.getChunk()); if (inChunk == null) { return; } Bukkit.getScheduler().runTaskLater(plugin, () -> { for (Shop shop : inChunk.values()) { shop.onLoad(); } }, 1); }
Example #17
Source File: EventListener.java From iDisguise with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onChunkLoad(ChunkLoadEvent event) { for(Entity entity : event.getChunk().getEntities()) { if(entity instanceof LivingEntity) { EntityIdList.addEntity((LivingEntity)entity); } } }
Example #18
Source File: ChunkListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Prevent FireWorks from loading chunks * @param event */ @EventHandler(priority = EventPriority.LOWEST) public void onChunkLoad(ChunkLoadEvent event) { if (!Settings.IMP.TICK_LIMITER.FIREWORKS_LOAD_CHUNKS) { Chunk chunk = event.getChunk(); Entity[] entities = chunk.getEntities(); World world = chunk.getWorld(); Exception e = new Exception(); int start = 14; int end = 22; int depth = Math.min(end, getDepth(e)); for (int frame = start; frame < depth; frame++) { StackTraceElement elem = getElement(e, frame); if (elem == null) return; String className = elem.getClassName(); int len = className.length(); if (className != null) { if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) { for (Entity ent : world.getEntities()) { if (ent.getType() == EntityType.FIREWORK) { Vector velocity = ent.getVelocity(); double vertical = Math.abs(velocity.getY()); if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); ent.remove(); } } } } } } } }
Example #19
Source File: ProtectionHandler.java From Civs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { if (ConfigManager.getInstance().isDebugLog()) { DebugLogger.chunkLoads++; } // System.out.println("chunk loaded: " + event.getChunk().getX() + ", " + event.getChunk().getZ()); UnloadedInventoryHandler.getInstance().syncAllInventoriesInChunk(event.getChunk()); }
Example #20
Source File: ConveyorEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { Chunk chunk = event.getChunk(); for (Region r : new HashMap<>(orphanCarts).keySet()) { StorageMinecart sm = orphanCarts.get(r); if (Util.isWithinChunk(chunk, sm.getLocation())) { carts.put(r, sm); orphanCarts.remove(r); } } }
Example #21
Source File: SkullPlaceHolders.java From VoxelGamesLibv2 with MIT License | 5 votes |
@EventHandler public void chunkLoad(@Nonnull ChunkLoadEvent event) { Arrays.stream(event.getChunk().getTileEntities()) .filter(blockState -> blockState instanceof Skull) .map((blockState) -> (Skull) blockState) .forEach(skull -> lastSeenSkulls.put(skull.getLocation(), skull)); }
Example #22
Source File: SignPlaceholders.java From VoxelGamesLibv2 with MIT License | 5 votes |
@EventHandler public void chunkLoad(@Nonnull ChunkLoadEvent event) { Arrays.stream(event.getChunk().getTileEntities()) .filter(blockState -> blockState instanceof Sign) .map(blockState -> (Sign) blockState) .forEach(sign -> lastSeenSigns.put(sign.getLocation(), sign)); }
Example #23
Source File: LoadEvent.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent e) { if(sm.getCustomConfig().getStringList("no-stack-worlds") .contains(e.getWorld().getName())){ return; } for(Entity currentEntity : e.getChunk().getEntities()){ if(!(currentEntity instanceof Mob)){ continue; } // Check if has been cached. if(sm.getCache().containsKey(currentEntity.getUniqueId())){ int cacheSize = sm.getCache().get(currentEntity.getUniqueId()); sm.getCache().remove(currentEntity.getUniqueId()); StackTools.setSize(currentEntity, cacheSize); continue; } if(currentEntity.getCustomName() != null){ continue; } if(sm.getTraitManager().checkTraits(currentEntity)){ continue; } if(sm.getHookManager().cantStack(currentEntity)){ continue; } if(sm.getLogic().doChecks(currentEntity)){ continue; } StackTools.setSize(currentEntity, GlobalValues.NOT_ENOUGH_NEAR); } }
Example #24
Source File: WorldProblemMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onChunkLoad(ChunkLoadEvent event) { if(world.equals(event.getWorld())) { checkChunk(event.getChunk()); } }
Example #25
Source File: TPContainerListener.java From Transport-Pipes with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onChunkLoad(ChunkLoadEvent e) { handleChunkLoadSync(e.getChunk(), false); }
Example #26
Source File: ThreadSafetyListener.java From LagMonitor with MIT License | 4 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent chunkLoadEvent) { checkSafety(chunkLoadEvent); }
Example #27
Source File: BukkitQueue_0.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@EventHandler public static void onChunkLoad(ChunkLoadEvent event) { Chunk chunk = event.getChunk(); long pair = MathMan.pairInt(chunk.getX(), chunk.getZ()); keepLoaded.putIfAbsent(pair, Fawe.get().getTimer().getTickStart()); }
Example #28
Source File: ThreadSafetyListener.java From LagMonitor with MIT License | 4 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent chunkLoadEvent) { checkSafety(chunkLoadEvent); }
Example #29
Source File: NPCChunkLoad.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { for (NPCEntity npcEntity : EntityTracker.getNPCEntities()) if (npcEntity.getSpawnLocation().getChunk().equals(event.getChunk())) npcEntity.respawnNPC(); }
Example #30
Source File: SignUpdater.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler private void onChunkLoad(ChunkLoadEvent event) { load(event.getChunk()); }