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


Java SpawnReason.SPAWNER_EGG屬性代碼示例

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


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

示例1: onSpawn

@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawnerEggs") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawners") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySummonCommand") == true) {
  if (event.getSpawnReason() == SpawnReason.DEFAULT) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
  if (event.getSpawnReason() == SpawnReason.CUSTOM) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
}
 
開發者ID:AnonymousDr,項目名稱:ADR,代碼行數:21,代碼來源:mobs.java

示例2: onEntitySpawn

@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,代碼行數:18,代碼來源:FlagDef_NoMonsterSpawns.java

示例3: onEntitySpawn

@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,代碼行數:20,代碼來源:FlagDef_NoMobSpawns.java

示例4: onEntitySpawn

@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,代碼行數:22,代碼來源:EntityEventHandler.java

示例5: onEnderDragonSpawn

/**
 * - 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,代碼行數:29,代碼來源:EnderDragonListener.java

示例6: onMobSpawnEgg

@EventHandler
public void onMobSpawnEgg(CreatureSpawnEvent event){
	if(event.getSpawnReason() == SpawnReason.SPAWNER_EGG){
		if(event.getEntity() instanceof Creature){
			Creature creature = (Creature) event.getEntity();
			creature.setAI(false);
		}
	}
}
 
開發者ID:DamoclesProject,項目名稱:Damocles,代碼行數:9,代碼來源:EventCanceller.java

示例7: onSpawn

@EventHandler
public void onSpawn(CreatureSpawnEvent event)
{
    if(event.getSpawnReason() != SpawnReason.SPAWNER 
            && event.getSpawnReason() != SpawnReason.SPAWNER_EGG){
        return;
    }
    
    if(!this.entityTypes.contains(event.getEntityType())){
        return;
    }
    
    LivingEntity ent = event.getEntity();
    ent.setMetadata("spawned", new FixedMetadataValue(plugin, true));
}
 
開發者ID:sabersamus,項目名稱:Bytecraft,代碼行數:15,代碼來源:RareDropListener.java

示例8: onCreatureSpawn

@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    if (event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
        event.setCancelled(true);
    }
}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:7,代碼來源:GameMagic.java

示例9: onCreatureSpawn

@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
	EntityType type = event.getEntityType();
	MobPermission permission = plugin.getMobPermission(type);

	if (permission == MobPermission.ENABLED) {
		// do nothing
	} else if (permission == MobPermission.DISABLED) {
		event.setCancelled(true);
	} else if (permission == MobPermission.ALLOWED_WITH_EGG) {
		if (event.getSpawnReason() != SpawnReason.SPAWNER_EGG) event.setCancelled(true);
	}
}
 
開發者ID:trew,項目名稱:DisableMobs,代碼行數:13,代碼來源:SpawnListener.java

示例10: onCreatureSpawn

@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
	if (event.getSpawnReason()!=SpawnReason.SPAWNER_EGG)
		event.setCancelled(true);
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:5,代碼來源:Events.java

示例11: onCreatureSpawn

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent e) {
	if (!cm.spawnLimitEnabled) {
		return;
	}
	// 如果開啟了TPS閥值,當TPS大於閥值,就不限製
	if (cm.spawnLimitTpsThreshold > 0 && cm.spawnLimitTpsThreshold <= 20 &&
		NeverLag.getTpsWatcher().getAverageTPS() >= cm.spawnLimitTpsThreshold) {
		return;
	}
	// 實體有自定義名字的不限製,兼容MM怪物等插件
	LivingEntity creature = e.getEntity();
	if (creature.getCustomName() != null) {
		return;
	}
	// 不限製插件、刷怪蛋、刷怪籠刷出的實體和凋零、鐵傀儡、雪人
	if (creature.getType() != EntityType.IRON_GOLEM && creature.getType() != EntityType.SNOWMAN && creature.getType() != EntityType.WITHER
		&& e.getSpawnReason() != SpawnReason.SPAWNER_EGG && e.getSpawnReason() != SpawnReason.SPAWNER
		&& e.getSpawnReason() != SpawnReason.CUSTOM) {
		if (creature instanceof Animals) {
			if (this.getMobCount() >= cm.spawnLimitAnimalThreshold) {
				e.setCancelled(true);
			}
		} else if (creature instanceof Monster) {
			if (this.getMobCount() >= cm.spawnLimitMonsterThreshold) {
				e.setCancelled(true);
			}
		}
	}
	// 刷怪籠不按照總數量限製,而是按照區塊內實體數量
	if (SpawnReason.SPAWNER == e.getSpawnReason()) {
		int count = 0;
		for (Entity entity : e.getLocation().getChunk().getEntities()) {
			if (creature instanceof Monster && entity instanceof Monster) {
				count++;
			} else if (creature instanceof Animals && entity instanceof Animals) {
				count++;
			} else if (entity instanceof Monster) {
				count++;
			}
			if (count > cm.maxSpawnEntityPerChunk) {
				e.setCancelled(true);
				break;
			}
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:47,代碼來源:MobLimtier.java

示例12: onVillagerSpawn

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onVillagerSpawn(final CreatureSpawnEvent e) {
    // If not an villager
    if (!(e.getEntity() instanceof Villager)) {
        return;
    }
    if (DEBUG3) {
        plugin.getLogger().info("Villager spawn event! " + e.getEventName());
        plugin.getLogger().info("Reason:" + e.getSpawnReason().toString());
        plugin.getLogger().info("Entity:" + e.getEntityType().toString());
    }
    // Only cover overworld
    if (!e.getEntity().getWorld().equals(ASkyBlock.getIslandWorld())) {
        return;
    }
    // If there's no limit - leave it
    if (Settings.villagerLimit <= 0) {
        return;
    }
    // We only care about villagers breeding, being cured or coming from a spawn egg, etc.
    if (e.getSpawnReason() != SpawnReason.SPAWNER && e.getSpawnReason() != SpawnReason.BREEDING
            && e.getSpawnReason() != SpawnReason.DISPENSE_EGG && e.getSpawnReason() != SpawnReason.SPAWNER_EGG
            && e.getSpawnReason() != SpawnReason.CURED) {
        return;
    }
    Island island = plugin.getGrid().getProtectedIslandAt(e.getLocation());
    if (island == null || island.getOwner() == null || island.isSpawn()) {
        // No island, no limit
        return;
    }
    int limit = Settings.villagerLimit * Math.max(1,plugin.getPlayers().getMembers(island.getOwner()).size());
    //plugin.getLogger().info("DEBUG: villager limit = " + limit);
    //long time = System.nanoTime();
    int pop = island.getPopulation();
    //plugin.getLogger().info("DEBUG: time = " + ((System.nanoTime() - time)*0.000000001));
    if (pop >= limit) {
        plugin.getLogger().warning(
                "Island at " + island.getCenter().getBlockX() + "," + island.getCenter().getBlockZ() + " hit the island villager limit of "
                        + limit);
        //plugin.getLogger().info("Stopped villager spawning on island " + island.getCenter());
        // Get all players in the area
        List<Entity> players = e.getEntity().getNearbyEntities(10,10,10);
        for (Entity player: players) {
            if (player instanceof Player) {
                Player p = (Player) player;
                Util.sendMessage(p, ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit)));
            }
        }
        plugin.getMessages().tellTeam(island.getOwner(), ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit)));
        if (e.getSpawnReason().equals(SpawnReason.CURED)) {
            // Easter Egg. Or should I say Easter Apple?
            ItemStack goldenApple = new ItemStack(Material.GOLDEN_APPLE);
            // Nerfed
            //goldenApple.setDurability((short)1);
            e.getLocation().getWorld().dropItemNaturally(e.getLocation(), goldenApple);
        }
        e.setCancelled(true);
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:59,代碼來源:EntityLimits.java

示例13: onDisableSpawnEggs

@EventHandler
public void onDisableSpawnEggs(CreatureSpawnEvent e) {
	if(e.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
		e.setCancelled(true);
	}
}
 
開發者ID:xEssentials,項目名稱:xEssentials-deprecated-bukkit,代碼行數:6,代碼來源:DisableSpawnEggEvent.java


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