类org.bukkit.event.world.ChunkLoadEvent源码实例Demo

下面列出了怎么用org.bukkit.event.world.ChunkLoadEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: GriefDefender   文件: WorldEventHandler.java
@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();
        }
    }
}
 
源代码2 项目: PGM   文件: WorldProblemListener.java
@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);
    }
  }
}
 
源代码3 项目: EliteMobs   文件: FindSuperMobs.java
@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) {

                }
    }


}
 
源代码4 项目: Holograms   文件: HologramListener.java
@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);
        }
    }
}
 
源代码5 项目: civcraft   文件: MobListener.java
@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;
		}
	}

}
 
源代码6 项目: CardinalPGM   文件: InvisibleBlock.java
@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);
            }
        }
    });
}
 
源代码7 项目: QuickShop-Reremake   文件: ChunkListener.java
@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);
}
 
源代码8 项目: StackMob-3   文件: LoadEvent.java
@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);
    }
}
 
源代码9 项目: VoxelGamesLibv2   文件: SignPlaceholders.java
@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));
}
 
源代码10 项目: VoxelGamesLibv2   文件: SkullPlaceHolders.java
@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));
}
 
源代码11 项目: Civs   文件: ConveyorEffect.java
@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);
        }
    }
}
 
源代码12 项目: Civs   文件: ProtectionHandler.java
@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());
    }
 
源代码13 项目: FastAsyncWorldedit   文件: ChunkListener.java
/**
 * 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();
                            }
                        }
                    }
                }
            }
        }
    }
}
 
源代码14 项目: iDisguise   文件: EventListener.java
@EventHandler(priority = EventPriority.LOWEST)
public void onChunkLoad(ChunkLoadEvent event) {
	for(Entity entity : event.getChunk().getEntities()) {
		if(entity instanceof LivingEntity) {
			EntityIdList.addEntity((LivingEntity)entity);
		}
	}
}
 
源代码15 项目: ShopChest   文件: ShopUpdateListener.java
@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());
}
 
源代码16 项目: AreaShop   文件: SignsFeature.java
@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);
}
 
源代码17 项目: askyblock   文件: EntityLimits.java
@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);
}
 
源代码18 项目: askyblock   文件: WorldLoader.java
@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();
}
 
源代码19 项目: askyblock   文件: CleanSuperFlat.java
@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));
    }
}
 
源代码20 项目: HoloAPI   文件: HoloListener.java
@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);
                    }
                }
            }
        }
    }
}
 
源代码21 项目: HolographicDisplays   文件: MainListener.java
@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));
		}
	}
}
 
源代码22 项目: Shopkeepers   文件: WorldListener.java
@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);
}
 
源代码23 项目: EntityAPI   文件: SimpleChunkManager.java
@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();
            }
        }
    }
}
 
源代码24 项目: ProjectAres   文件: WorldProblemMatchModule.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
    if(world.equals(event.getWorld())) {
        checkChunk(event.getChunk());
    }
}
 
源代码25 项目: ProjectAres   文件: SignUpdater.java
@EventHandler
private void onChunkLoad(ChunkLoadEvent event) {
    load(event.getChunk());
}
 
源代码26 项目: Transport-Pipes   文件: TPContainerListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent e) {
    handleChunkLoadSync(e.getChunk(), false);
}
 
源代码27 项目: EliteMobs   文件: NPCChunkLoad.java
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    for (NPCEntity npcEntity : EntityTracker.getNPCEntities())
        if (npcEntity.getSpawnLocation().getChunk().equals(event.getChunk()))
            npcEntity.respawnNPC();
}
 
源代码28 项目: LagMonitor   文件: ThreadSafetyListener.java
@EventHandler
public void onChunkLoad(ChunkLoadEvent chunkLoadEvent) {
    checkSafety(chunkLoadEvent);
}
 
源代码29 项目: FastAsyncWorldedit   文件: BukkitQueue_0.java
@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());
}
 
源代码30 项目: LagMonitor   文件: ThreadSafetyListener.java
@EventHandler
public void onChunkLoad(ChunkLoadEvent chunkLoadEvent) {
    checkSafety(chunkLoadEvent);
}
 
 类所在包
 类方法
 同包方法