本文整理汇总了Java中org.bukkit.event.world.ChunkUnloadEvent类的典型用法代码示例。如果您正苦于以下问题:Java ChunkUnloadEvent类的具体用法?Java ChunkUnloadEvent怎么用?Java ChunkUnloadEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChunkUnloadEvent类属于org.bukkit.event.world包,在下文中一共展示了ChunkUnloadEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onChunkUnload(ChunkUnloadEvent e) {
if (!cm.removeEntityWhenChunkUnload) {
return;
}
for (Entity entity : e.getChunk().getEntities()) {
if (NeverLagUtils.checkCustomNpc(entity)) {
continue;
}
if (entity instanceof Monster && cm.removeMonsterWhenChunkUnload) {
entity.remove();
} else if (entity instanceof Animals && cm.removeAnimalsWhenChunkUnload) {
entity.remove();
} else if (entity instanceof Item && cm.removeItemWhenChunkUnload) {
entity.remove();
} else if (entity instanceof Arrow && cm.removeArrowWhenChunkUnload) {
entity.remove();
} else if (entity instanceof Squid && cm.removeSquidWhenChunkUnload) {
entity.remove();
}
}
}
示例2: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkUnload(ChunkUnloadEvent e) {
if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds().contains(
e.getWorld().getName()))
for (Entity entity : e.getChunk().getEntities()) {
for (NPC npc : questNPCs) {
//if (npc.getEntity().getCustomName() != null &&
if (npc.getName() != null &&
//npc.getEntity().getCustomName().equals(entity.getCustomName()))
npc.getName().equals(entity.getCustomName()))
if (npc.getID().equals(entity.getUniqueId())) {
return;
}
}
if (entity instanceof LivingEntity) {
LivingEntity live = (LivingEntity) entity;
QuestManagerPlugin.questManagerPlugin.getEnemyManager().removeEntity(live);
entity.remove();
}
}
}
示例3: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
/**
* Prevent chunk that contain pearls from unloading
* @param e The event args
*/
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent e) {
Chunk chunk = e.getChunk();
for (Entity entity : chunk.getEntities()) {
if (!(entity instanceof Item)) {
continue;
}
Item item = (Item)entity;
ExilePearl pearl = pearlApi.getPearlFromItemStack(item.getItemStack());
if (pearl != null) {
e.setCancelled(true);
pearlApi.log("Prevented chunk (%d, %d) from unloading because it contained an exile pearl for player %s.", chunk.getX(), chunk.getZ(), pearl.getPlayerName());
}
}
}
示例4: OnChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@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: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onChunkUnload(ChunkUnloadEvent event) {
Entity[] entitiesInChunk = event.getChunk().getEntities();
if (entitiesInChunk.length == 0)
return;
List<EntityType> passives = Settings.getAllPassives();
List<EntityType> hostiles = Settings.getAllHostiles();
for (Entity e : entitiesInChunk) {
if ((hostiles != null && hostiles.contains(e.getType())
|| (passives != null && passives.contains(e.getType())))) {
LivingEntity le = (LivingEntity) e;
if ((le.getCustomName() == null) && (!le.isCustomNameVisible())) {
le.remove();
}
} else if (e.getType() == EntityType.WITHER_SKULL) {
e.remove();
}
}
}
示例6: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChunkUnload(ChunkUnloadEvent event)
{
if(!event.isCancelled())
{
Chunk chunk = event.getChunk();
for(Machine machine : SQTechBase.machines)
{
if(machine.getMachineType() instanceof Harvester)
{
if(machine.getGUIBlock().getLocation().getChunk() == chunk)
{
main.setInactive(machine);
machine.data.put("blocked", false);
}
}
}
}
}
示例7: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChunkUnload(ChunkUnloadEvent event)
{
if(!event.isCancelled())
{
Chunk chunk = event.getChunk();
for(Machine machine : SQTechBase.machines)
{
if(machine.getMachineType().name == "Drill")
{
if(machine.getGUIBlock().getLocation().getChunk() == chunk)
{
machine.data.put("isActive", false);
machine.data.put("blocked", false);
}
}
}
}
}
示例8: onChunkUnloaded
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onChunkUnloaded(ChunkUnloadEvent event) {
Chunk c = event.getChunk();
Entity[] entities = c.getEntities();
for(Entity e: entities){
if (this.manager.isHorse(e))
{
if (this.manager.isOwned(e.getUniqueId()))
{
// We save horse location
Location loc = e.getLocation();
this.data.getHorsesData().set("horses."+e.getUniqueId()+".lastpos",loc.getWorld().getName()+":"+loc.getX()+":"+loc.getY()+":"+loc.getZ()+":"+loc.getYaw()+":"+loc.getPitch());
this.data.save();
}
}
}
}
示例9: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
if (ignoreUnload) {
return;
}
if (Settings.Chunk_Processor.AUTO_TRIM) {
Chunk chunk = event.getChunk();
String world = chunk.getWorld().getName();
if (PS.get().hasPlotArea(world)) {
if (unloadChunk(world, chunk, true)) {
return;
}
}
}
if (processChunk(event.getChunk(), true)) {
event.setCancelled(true);
}
}
示例10: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event)
{
final Chunk c = event.getChunk();
for(Entity entity : c.getEntities())
{
if(!(entity instanceof LivingEntity))
continue;
RemoteEntity rentity = RemoteEntities.getRemoteEntityFromEntity((LivingEntity)entity);
if(rentity != null && rentity.isSpawned())
{
m_toSpawn.add(new EntityLoadData(rentity, entity.getLocation()));
rentity.despawn(DespawnReason.CHUNK_UNLOAD);
}
}
}
示例11: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
private void onChunkUnload(ChunkUnloadEvent cue) {
Chunk chunk = cue.getChunk();
ConfigurationSection config = configs.get(cue.getChunk());
if(config != null && config.isConfigurationSection("blocks")) {
ConfigurationSection blocks = config.getConfigurationSection("blocks");
for(Map.Entry<String, Object> entry : blocks.getValues(false).entrySet()) {
ConfigurationSection section = (ConfigurationSection) entry.getValue();
String[] locationParts = entry.getKey().split(" ");
int[] locationValues = new int[3];
for(int i = 0; i < 3; i++) {
locationValues[i] = Integer.parseInt(locationParts[i]);
}
BlockConfigUnloadEvent event = new BlockConfigUnloadEvent(plugin, section, cue.getChunk().getBlock(locationValues[0], locationValues[2], locationValues[2]));
Bukkit.getPluginManager().callEvent(event);
}
}
saveConfig(cue.getChunk());
configs.remove(chunk);
blockConfigs.remove(chunk);
}
示例12: onEndChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
/**
* Remove the unloaded EnderDragons from the loaded set
*
* @param event a Chunk Unload Event
*/
@EventHandler(priority = EventPriority.NORMAL)
public void onEndChunkUnload(final ChunkUnloadEvent event) {
if (event.getWorld().getEnvironment() == Environment.THE_END) {
final String worldName = event.getWorld().getName();
final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(worldName));
if (handler != null) {
EndChunk chunk = handler.getChunks().getChunk(event.getChunk());
if (chunk == null) {
chunk = handler.getChunks().addChunk(event.getChunk());
}
for (final Entity e : event.getChunk().getEntities()) {
if (e.getType() == EntityType.ENDER_DRAGON) {
final EnderDragon ed = (EnderDragon)e;
handler.getLoadedDragons().remove(ed.getUniqueId());
chunk.incrementSavedDragons();
}
}
}
}
}
示例13: onChunkProtect
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkProtect(ChunkUnloadEvent e) {
for(Entity entity : e.getChunk().getEntities()) {
if(entity instanceof WitherSkull) {
WitherSkull wither = (WitherSkull) entity;
if(pl.getConfiguration().getDebugConfig().isEnabled()) {
xEssentials.log("removed wither skull at: {" + wither.getWorld().getName() + ", " + wither.getLocation().getBlockX() + ", " + wither.getLocation().getBlockY() + ", " + wither.getLocation().getBlockZ() + "} to prevent lag", LogType.INFO);
}
wither.remove();
} else if(entity instanceof Fireball) {
Fireball fb = (Fireball) entity;
if(pl.getConfiguration().getDebugConfig().isEnabled()) {
xEssentials.log("removed fireball at: {" + fb.getWorld().getName() + ", " + fb.getLocation().getBlockX() + ", " + fb.getLocation().getBlockY() + ", " + fb.getLocation().getBlockZ() + "} to prevent lag", LogType.INFO);
}
fb.remove();
}
}
}
示例14: onChunkUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
ArrayList<Entity> toRemove = new ArrayList<Entity>();
for (Entity e : event.getChunk().getEntities()) {
EffectHolder holder = EffectManager.getInstance().getEffect(e.getUniqueId());
if (holder != null) {
EffectManager.getInstance().clear(holder);
continue;
}
if (e instanceof Item && ItemSpray.UUID_LIST.contains(e.getUniqueId())) {
toRemove.add(e);
}
}
if (!toRemove.isEmpty()) {
Iterator<Entity> i = toRemove.iterator();
while (i.hasNext()) {
i.next().remove();
}
}
}
示例15: onUnload
import org.bukkit.event.world.ChunkUnloadEvent; //导入依赖的package包/类
@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);
}
}
}
}
}