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

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

源代码1 项目: EntityAPI   文件: SimpleChunkManager.java
@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);
                }
            }
        }
    }
}
 
源代码2 项目: Holograms   文件: HologramListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    for (Entity entity : chunk.getEntities()) {
        HologramEntity hologramEntity = plugin.getEntityController().getHologramEntity(entity);
        if (hologramEntity != null) {
            hologramEntity.remove();
        }
    }
    Collection<Hologram> holograms = plugin.getHologramManager().getActiveHolograms().values();
    for (Hologram holo : holograms) {
        Location loc = holo.getLocation();
        int chunkX = (int) Math.floor(loc.getBlockX() / 16.0D);
        int chunkZ = (int) Math.floor(loc.getBlockZ() / 16.0D);
        if (chunkX == chunk.getX() && chunkZ == chunk.getZ()) {
            holo.despawn();
        }
    }
}
 
源代码3 项目: iDisguise   文件: EventListener.java
@EventHandler(priority = EventPriority.MONITOR)
public void onChunkUnload(ChunkUnloadEvent event) {
	final Chunk chunk = event.getChunk();
	final List<Integer> entityIds = new ArrayList<Integer>();
	for(Entity entity : chunk.getEntities()) {
		if(entity instanceof LivingEntity) {
			entityIds.add(entity.getEntityId());
		}
	}
	Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
		
		public void run() {
			if(!chunk.isLoaded()) {
				for(int entityId : entityIds) {
					EntityIdList.removeEntity(entityId);
				}
			}
		}
		
	}, 40L); // TODO: increase delay?
}
 
源代码4 项目: civcraft   文件: BonusGoodieManager.java
@EventHandler(priority = EventPriority.MONITOR)
public void OnChunkUnload(ChunkUnloadEvent event) {
	
	BonusGoodie goodie;
	
	for (Entity entity : event.getChunk().getEntities()) {
		if (!(entity instanceof Item)) {
			continue;
		}
		
		goodie = CivGlobal.getBonusGoodie(((Item)entity).getItemStack());
		if (goodie == null) {
			continue;
		}
		
		goodie.replenish(((Item)entity).getItemStack(), (Item)entity, null, null);
	}
}
 
源代码5 项目: askyblock   文件: EntityLimits.java
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
    if (!Settings.saveEntities || !IslandGuard.inWorld(event.getWorld())) {
        return;
    }
    // Delete the chunk data
    entities.set(event.getWorld().getName() + "." + event.getChunk().getX() + "." + event.getChunk().getZ() , null);
    // Create new entry
    Arrays.stream(event.getChunk().getEntities()).filter(x -> x.hasMetadata("spawnLoc")).forEach(entity -> {
        // Get the meta data
        entity.getMetadata("spawnLoc").stream().filter(y -> y.getOwningPlugin().equals(plugin)).forEach(v -> {
            entities.set(event.getWorld().getName() + "." 
                    + event.getChunk().getX() + "." + event.getChunk().getZ() + "." 
                    + entity.getUniqueId().toString(), v.asString());            
        });
    });
    Util.saveYamlFile(entities, "entitylimits.yml", true);
}
 
源代码6 项目: BedWars   文件: WorldListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent unload) {
    if (unload instanceof Cancellable) {
        Chunk chunk = unload.getChunk();

        for (String name : Main.getGameNames()) {
            Game game = Main.getGame(name);
            if (game.getStatus() != GameStatus.DISABLED && game.getStatus() != GameStatus.WAITING
                    && GameCreator.isChunkInArea(chunk, game.getPos1(), game.getPos2())) {
                ((Cancellable) unload).setCancelled(false);
                return;
            }
        }
    }
}
 
源代码7 项目: GriefDefender   文件: WorldEventHandler.java
@EventHandler(priority = EventPriority.LOWEST)
public void onChunkUnload(ChunkUnloadEvent 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) {
        if (gdChunk.getTrackedShortPlayerPositions().size() > 0) {
            gdChunk.saveChunkTrackingData();
        }
        claimWorldManager.removeChunk(gdChunk.getChunkKey());
    }
}
 
源代码8 项目: QuickShop-Reremake   文件: ChunkListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent e) {
    final Map<Location, Shop> inChunk = plugin.getShopManager().getShops(e.getChunk());
    if (inChunk == null) {
        return;
    }
    for (Shop shop : inChunk.values()) {
        if (shop.isLoaded()) {
            shop.onUnload();
        }
    }
}
 
源代码9 项目: BedWars   文件: WorldListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent unload) {
    if (unload instanceof Cancellable) {
        Chunk chunk = unload.getChunk();

        for (String name : Main.getGameNames()) {
            Game game = Main.getGame(name);
            if (game.getStatus() != GameStatus.DISABLED && game.getStatus() != GameStatus.WAITING
                    && GameCreator.isChunkInArea(chunk, game.getPos1(), game.getPos2())) {
                ((Cancellable) unload).setCancelled(false);
                return;
            }
        }
    }
}
 
源代码10 项目: StackMob-3   文件: EntityRemoveListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent e) {
    if (sm.getCustomConfig().getStringList("no-stack-worlds")
            .contains(e.getWorld().getName())) {
        return;
    }

    for (Entity entity : e.getChunk().getEntities()) {
        cleanupEntity(entity);
    }
}
 
源代码11 项目: Civs   文件: ConveyorEffect.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    for (Region r : new HashMap<>(carts).keySet()) {
        StorageMinecart sm = carts.get(r);
        if (Util.isWithinChunk(chunk, sm.getLocation())) {
            carts.remove(r);
            orphanCarts.put(r, sm);
        }
    }
}
 
源代码12 项目: Survival-Games   文件: KeepLobbyLoadedEvent.java
@EventHandler
    public void onChunkUnload(ChunkUnloadEvent e){
        LobbyManager.getInstance();
		if(LobbyManager.lobbychunks.contains(e.getChunk())){
//			e.setCancelled(true)
//			TODO find a alternative way to keep the lobby chunks loaded
			SurvivalGames.debug("[KeepLobbyLoadedEvent] Lobby Chunk unloading");
        }
        //System.out.println("Chunk unloading");
    }
 
源代码13 项目: WorldGuardExtraFlagsPlugin   文件: WorldListener.java
@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);
	}
}
 
源代码14 项目: BedwarsRel   文件: ChunkListener.java
@EventHandler
public void onUnload(ChunkUnloadEvent unload) {
  Game game = BedwarsRel.getInstance().getGameManager()
      .getGameByChunkLocation(unload.getChunk().getX(),
          unload.getChunk().getZ());
  if (game == null) {
    return;
  }

  if (game.getState() != GameState.RUNNING) {
    return;
  }

  unload.setCancelled(true);
}
 
源代码15 项目: FastAsyncWorldedit   文件: BukkitQueue_0.java
@EventHandler
public static void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
    Long lastLoad = keepLoaded.get(pair);
    if (lastLoad != null) {
        if (Fawe.get().getTimer().getTickStart() - lastLoad < 10000) {
            event.setCancelled(true);
        } else {
            keepLoaded.remove(pair);
        }
    }
}
 
源代码16 项目: civcraft   文件: BlockListener.java
@EventHandler(priority = EventPriority.HIGH)
public void onChunkUnloadEvent(ChunkUnloadEvent event) {
	Boolean persist = CivGlobal.isPersistChunk(event.getChunk());		
	if (persist != null && persist == true) {
		event.setCancelled(true);
	}
}
 
源代码17 项目: HolographicDisplays   文件: MainListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
	for (Entity entity : event.getChunk().getEntities()) {
		if (!entity.isDead()) {
			NMSEntityBase entityBase = nmsManager.getNMSEntityBase(entity);
			
			if (entityBase != null) {
				((CraftHologram) entityBase.getHologramLine().getParent()).despawnEntities();
			}
		}
	}
}
 
源代码18 项目: VoxelGamesLibv2   文件: SignPlaceholders.java
@EventHandler
public void chunkUnload(@Nonnull ChunkUnloadEvent event) {
    Arrays.stream(event.getChunk().getTileEntities())
            .filter(blockState -> blockState instanceof Sign)
            .forEach(sign -> lastSeenSigns.remove(sign.getLocation()));
}
 
源代码19 项目: VoxelGamesLibv2   文件: SkullPlaceHolders.java
@EventHandler
public void chunkUnload(@Nonnull ChunkUnloadEvent event) {
    Arrays.stream(event.getChunk().getTileEntities())
            .filter(blockState -> blockState instanceof Skull)
            .forEach(sign -> lastSeenSkulls.remove(sign.getLocation()));
}
 
源代码20 项目: Civs   文件: ProtectionHandler.java
@EventHandler
    public void onChunkUnload(ChunkUnloadEvent event) {
//        System.out.println("chunk unloaded: " + event.getChunk().getX() + ", " + event.getChunk().getZ());
        UnloadedInventoryHandler.getInstance().updateInventoriesInChunk(event.getChunk());
    }
 
源代码21 项目: factions-top   文件: WorthListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void recalculate(ChunkUnloadEvent event) {
    plugin.getWorthManager().recalculate(event.getChunk(), RecalculateReason.UNLOAD);
}
 
源代码22 项目: EliteMobs   文件: ChunkUnloadMetadataPurge.java
@EventHandler
public void onUnload(ChunkUnloadEvent event) {
    EntityTracker.chunkWiper(event);
}
 
源代码23 项目: LagMonitor   文件: ThreadSafetyListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent chunkUnloadEvent) {
    checkSafety(chunkUnloadEvent);
}
 
源代码24 项目: LagMonitor   文件: ThreadSafetyListener.java
@EventHandler
public void onChunkUnload(ChunkUnloadEvent chunkUnloadEvent) {
    checkSafety(chunkUnloadEvent);
}
 
源代码25 项目: ThinkMap   文件: Events.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
    // Save the chunk in its current state and use it instead of loading
    // the chunk
    plugin.getChunkManager(event.getWorld()).deactivateChunk(event.getChunk());
}
 
源代码26 项目: ObsidianDestroyer   文件: BlockListener.java
@EventHandler(priority = EventPriority.MONITOR)
public void onChunkUnload(ChunkUnloadEvent event) {
    ChunkManager.getInstance().unloadChunk(event.getChunk());
}
 
源代码27 项目: Shopkeepers   文件: WorldListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onChunkUnload(ChunkUnloadEvent event) {
	plugin.unloadShopkeepersInChunk(event.getChunk());
}
 
源代码28 项目: EliteMobs   文件: EntityTracker.java
/**
 * Wipes a chunk clean of all relevant plugin entities and data.
 *
 * @param event ChunkUnloadEvent to be cleared
 */
public static void chunkWiper(ChunkUnloadEvent event) {
    for (Entity entity : event.getChunk().getEntities())
        wipeEntity(entity);
}
 
 类所在包
 同包方法