當前位置: 首頁>>代碼示例>>Java>>正文


Java CreatureSpawnEvent.setCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.CreatureSpawnEvent.setCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java CreatureSpawnEvent.setCancelled方法的具體用法?Java CreatureSpawnEvent.setCancelled怎麽用?Java CreatureSpawnEvent.setCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.CreatureSpawnEvent的用法示例。


在下文中一共展示了CreatureSpawnEvent.setCancelled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SLIME_SPLIT) { // allow slimes to always split
        return;
    }

    switch (event.getSpawnReason()) {
    case NATURAL:
        if (event.getLocation().getChunk().getEntities().length > MAX_NATURAL_CHUNK_ENTITIES) {
            event.setCancelled(true);
        }
        break;
    case CHUNK_GEN:
        if (event.getLocation().getChunk().getEntities().length > MAX_CHUNK_GENERATED_ENTITIES) {
            event.setCancelled(true);
        }
        break;
    default:
        break;
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:EntityLimitListener.java

示例2: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    LivingEntity entity = event.getEntity();
    if(!this.isMonster(entity)) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG)
    {
        entity.setMetadata(this.ALLOW_TARGET_TAG, new FixedMetadataValue(GPFlags.instance, new Boolean(true)));
        return;
    }
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
開發者ID:BigScary,項目名稱:GriefPreventionFlags,代碼行數:19,代碼來源:FlagDef_NoMonsterSpawns.java

示例3: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    if(!(event.getEntity() instanceof LivingEntity)) return;
    
    if(event.getLocation() == null) return;
    
    EntityType type = event.getEntityType();
    if(type == EntityType.PLAYER) return;
    if(type == EntityType.ARMOR_STAND) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) return;
    
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
開發者ID:BigScary,項目名稱:GriefPreventionFlags,代碼行數:21,代碼來源:FlagDef_NoMobSpawns.java

示例4: on

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void on(CreatureSpawnEvent event) {
    if (!entityChecker.isEntityOfClassExact(event.getEntity(), toCheck)) return;

    if (skips.contains(event.getSpawnReason())) return;

    Location loc = event.getEntity().getLocation();
    plugin.getLogger().severe(
            String.format("Invalid spawn occured for entity type %s at x:%f y:%f z:%f, automatically cancelling...",
                    toCheck.getName(),
                    loc.getX(),
                    loc.getY(),
                    loc.getZ()
            )
    );

    event.setCancelled(true);
}
 
開發者ID:Eluinhost,項目名稱:UberHardcore,代碼行數:19,代碼來源:InvalidSpawnListener.java

示例5: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
	//these rules apply only to creative worlds
	if(!GriefPrevention.instance.creativeRulesApply(event.getLocation())) return;
	
	//chicken eggs and breeding could potentially make a mess in the wilderness, once griefers get involved
	SpawnReason reason = event.getSpawnReason();
	if(reason != SpawnReason.SPAWNER_EGG && reason != SpawnReason.BUILD_IRONGOLEM && reason != SpawnReason.BUILD_SNOWMAN)
	{
		event.setCancelled(true);
		return;
	}

	//otherwise, just apply the limit on total entities per claim (and no spawning in the wilderness!)
	Claim claim = this.dataStore.getClaimAt(event.getLocation(), false, null);
	if(claim == null || claim.allowMoreEntities() != null)
	{
		event.setCancelled(true);
		return;
	}
}
 
開發者ID:john01dav,項目名稱:GriefPreventionPlus,代碼行數:23,代碼來源:EntityEventHandler.java

示例6: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    Chunk chunk = entity.getLocation().getChunk();
    if (chunk == lastChunk) {
        event.getEntity().remove();
        event.setCancelled(true);
        return;
    }
    if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
        return;
    }
    Entity[] entities = chunk.getEntities();
    if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
        event.getEntity().remove();
        event.setCancelled(true);
        lastChunk = chunk;
    }
    else {
        lastChunk = null;
    }
}
 
開發者ID:Mayomi,項目名稱:PlotSquared-Chinese,代碼行數:23,代碼來源:ChunkListener.java

示例7: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
	LivingEntity e = event.getEntity();
	WorldSettings set = plugin.getWorlds().get(event.getEntity().getWorld().getName());
	if (set == null) {
		return;
	}
	if (!set.getEntities().contains(e.getType())) {
		return;
	}
	if (!set.shouldExist(e)) {
		event.setCancelled(true);
	} else if (rand.nextDouble() > set.getRatio(e.getType())) {
		event.setCancelled(true);
	} else {
		AttributeInstance maxHealth = e.getAttribute(Attribute.GENERIC_MAX_HEALTH);
		maxHealth.setBaseValue(maxHealth.getBaseValue() * set.getHealth(e.getType()));
		e.setHealth(e.getMaxHealth());
	}
}
 
開發者ID:Co0sh,項目名稱:Hordes,代碼行數:21,代碼來源:Blocker.java

示例8: cancelMobSpawning

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void cancelMobSpawning(CreatureSpawnEvent event){
	if(Minigame.getCurrentMinigame()!=null){
		switch(Minigame.getCurrentMinigame().getMap().getType()){
		case CIRCLE_OF_BOOM:
			event.setCancelled(true);
			break;
		case KEY_QUEST:
			break;
		case WATER_THE_MONUMENT:
			break;
		default:
			break;
		}
	}
}
 
開發者ID:tatanpoker09,項目名稱:TCMinigames,代碼行數:17,代碼來源:EntityListener.java

示例9: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    Entity entity = event.getEntity();
    String world = entity.getWorld().getUID().toString();
    Integer x = entity.getLocation().getChunk().getX(), z = entity.getLocation().getChunk().getZ();
    if (QuickChecks.isWorldChunkClaimed(serverdata.get("worldmap").get(world), x, z, "cla")) {
        String pvillage = ((HashMap) ((HashMap) serverdata.get("worldmap").get(world).get(x)).get(z)).get("cla").toString();
        if (serverdata.get("villages").get(pvillage).containsKey("mobs")) {
            if (serverdata.get("villages").get(pvillage).get("mobs").equals("off")) {
                event.setCancelled(true);
            }
        } else if (Config.getString("Village Settings.Toggle Settings.Mobs Enabled").equals("off")) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:N1T3SLAY3R,項目名稱:Empirecraft,代碼行數:17,代碼來源:OnCreatureSpawn.java

示例10: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    Chunk chunk = entity.getLocation().getChunk();
    if (chunk == this.lastChunk) {
        event.getEntity().remove();
        event.setCancelled(true);
        return;
    }
    if (!PS.get().hasPlotArea(chunk.getWorld().getName())) {
        return;
    }
    Entity[] entities = chunk.getEntities();
    if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
        event.getEntity().remove();
        event.setCancelled(true);
        this.lastChunk = chunk;
    } else {
        this.lastChunk = null;
    }
}
 
開發者ID:IntellectualSites,項目名稱:PlotSquared,代碼行數:22,代碼來源:ChunkListener.java

示例11: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    Entity entity = event.getEntity();

    Location location = event.getLocation();
    Point pos = new Point(location.getBlockX(), location.getBlockZ());

    ZoneWorld world = plugin.getWorld(entity.getWorld());
    Zone zone = world.findZone(pos);

    if (zone == null || zone.hasHostiles()) {
        return;
    }

    if (!allowedMobs.contains(event.getEntityType()) &&
        event.getSpawnReason() == SpawnReason.NATURAL) {

        event.setCancelled(true);
    }
}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:22,代碼來源:ZoneEntityListener.java

示例12: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent e) {
	if (e.getEntity().getWorld().getName() != "Christmas"){
		return;
	}

	if(e.getEntityType() == EntityType.GIANT ||
			e.getEntityType() == EntityType.VILLAGER ||
			e.getEntityType() == EntityType.WITCH){
		return;
	}
	
	if (e.getEntityType() == EntityType.ZOMBIE || 
			e.getEntityType() == EntityType.SKELETON) {
		setHelmet(e.getEntity());
		setChest(e.getEntity());
		setLegs(e.getEntity());
		setBoots(e.getEntity());
		setHand(e.getEntity());
	}else if (e.getEntity().getCustomName() == null){
		e.setCancelled(true);
	}
}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:24,代碼來源:SpawnListener.java

示例13: onEnderDragonSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
/**
 * - Prevents natural spawn of EnderDragon
 * - Prevents too many Dragons in the End world
 * - Handle custom health and take care of this new Dragon
 *
 * @param event a CreatureSpawnEvent
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonSpawn(final CreatureSpawnEvent event) {
    if (event.getEntityType() == EntityType.ENDER_DRAGON) {
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getLocation().getWorld().getName()));
        if (handler != null) {
            if (handler.getNumberOfAliveEnderDragons() >= handler.getConfig().getRespawnNumber()) {
                event.setCancelled(true);
            } else {
                if (event.getSpawnReason() != SpawnReason.CUSTOM && event.getSpawnReason() != SpawnReason.SPAWNER_EGG) {
                    event.setCancelled(true);
                } else {
                    if (!handler.getDragons().containsKey(event.getEntity().getUniqueId())) {
                        handler.getDragons().put(event.getEntity().getUniqueId(), new HashMap<String, Double>());
                        event.getEntity().setMaxHealth(handler.getConfig().getEdHealth());
                        event.getEntity().setHealth(event.getEntity().getMaxHealth());
                    }
                    handler.getLoadedDragons().add(event.getEntity().getUniqueId());
                }
            }
        }
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:30,代碼來源:EnderDragonListener.java

示例14: onMobSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onMobSpawn(CreatureSpawnEvent evt) {
    switch (evt.getSpawnReason()) {
        case NATURAL:
        case JOCKEY:
        case CHUNK_GEN:
        case SPAWNER:
        case BUILD_WITHER:
        case VILLAGE_DEFENSE:
        case VILLAGE_INVASION:
        case REINFORCEMENTS:
        case NETHER_PORTAL:
            if (Statics.ARENA_WORLD_NAME.equals(evt.getLocation().getWorld().getName())) {
                evt.setCancelled(true);
            }
            break;
        default:
            break;
    }
}
 
開發者ID:SkyWars,項目名稱:SkyWars,代碼行數:21,代碼來源:MobSpawnDisable.java

示例15: onMobSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
/**
 * Prevents mobs spawning at spawn or in an island
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMobSpawn(final CreatureSpawnEvent e) {
    if (DEBUG2) {
        plugin.getLogger().info("on Mob spawn" + e.getEventName());
    }
    // if grid is not loaded yet, return.
    if (plugin.getIslands() == null) {
        return;
    }
    // If not in the right world, return
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    // Deal with natural spawning
    if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
        if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) {
            if (DEBUG2)
                plugin.getLogger().info("Natural monster spawn cancelled.");
            // Mobs not allowed to spawn
            e.setCancelled(true);
            return;
        }
    }
    if (e.getEntity() instanceof Animals) {
        if (!actionAllowed(e.getLocation(), SettingsFlag.ANIMAL_SPAWN)) {
            // Animals are not allowed to spawn
            if (DEBUG2)
                plugin.getLogger().info("Natural animal spawn cancelled.");
            e.setCancelled(true);
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:38,代碼來源:IslandGuard.java


注:本文中的org.bukkit.event.entity.CreatureSpawnEvent.setCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。