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


Java SpawnReason.SPAWNER屬性代碼示例

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


在下文中一共展示了SpawnReason.SPAWNER屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onEntityDeath

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) {
    LivingEntity entity = event.getEntity();
    World world = entity.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_EXP)) {
        if (!worldConfig.getBoolean(Config.FEATURE_MORE_EXP_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
            event.setDroppedExp(event.getDroppedExp() * Math.max(worldConfig.getInt(Config.FEATURE_MORE_EXP_MULTIPLIER), 0));
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:12,代碼來源:MoreExpListener.java

示例5: onEntityDeath

@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
    LivingEntity entity = event.getEntity();
    World world = entity.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_DROPS)) {
        if (!worldConfig.getBoolean(Config.FEATURE_MORE_DROPS_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
            for (ItemStack drop : event.getDrops()) {
                drop.setAmount(drop.getAmount() * Math.max(worldConfig.getInt(Config.FEATURE_MORE_DROPS_MULTIPLIER), 0));
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:14,代碼來源:MoreDropsListener.java

示例6: onStart

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStart(BloodMoonStartEvent event) {
    World world = event.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isFeatureEnabled(world, Feature.ZOMBIE_ARMOR)) {
        for (LivingEntity entity : event.getWorld().getLivingEntities()) {
            if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_ARMOR_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
                if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
                    this.giveArmor(entity, worldConfig);
                }
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:15,代碼來源:ZombieArmorListener.java

示例7: onCreatureSpawn

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    World world = event.getLocation().getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.ZOMBIE_ARMOR)) {
        LivingEntity entity = event.getEntity();

        if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_ARMOR_IGNORE_SPAWNERS) || event.getSpawnReason() != SpawnReason.SPAWNER) {
            if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
                this.giveArmor(entity, worldConfig);
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:15,代碼來源:ZombieArmorListener.java

示例8: onStart

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStart(BloodMoonStartEvent event) {
    World world = event.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isFeatureEnabled(world, Feature.ZOMBIE_WEAPON)) {
        for (LivingEntity entity : event.getWorld().getLivingEntities()) {
            if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_WEAPON_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
                if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
                    this.giveWeapon(entity, worldConfig);
                }
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:15,代碼來源:ZombieWeaponListener.java

示例9: onCreatureSpawn

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    World world = event.getLocation().getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.ZOMBIE_WEAPON)) {
        LivingEntity entity = event.getEntity();

        if (!worldConfig.getBoolean(Config.FEATURE_ZOMBIE_WEAPON_IGNORE_SPAWNERS) || event.getSpawnReason() != SpawnReason.SPAWNER) {
            if (entity.getType() == EntityType.ZOMBIE && this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_CHANCE)) {
                this.giveWeapon(entity, worldConfig);
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:15,代碼來源:ZombieWeaponListener.java

示例10: 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

示例11: onSpawn

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

示例12: onMobSpawn

@EventHandler(priority = EventPriority.LOWEST)
public void onMobSpawn(CreatureSpawnEvent event) {
	// Only log spawned mobs if we want to disable earnings
	if (getConfig().getBoolean("global.spawner_earnings", true)) {
		return;
	}
	
	if (event.getSpawnReason() == SpawnReason.SPAWNER) {
		spawnedMobs.add(event.getEntity().getUniqueId());
	}
}
 
開發者ID:vxnick,項目名稱:mobrewards,代碼行數:11,代碼來源:MobRewards.java

示例13: 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

示例14: onEntitySpawn

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent e) {
    if (e.getSpawnReason() == SpawnReason.SPAWNER)
        e.getEntity().setMetadata("isSpawnerMob", new FixedMetadataValue(instance, true));
}
 
開發者ID:Explodncheez,項目名稱:MysteryBags,代碼行數:5,代碼來源:MysteryBagsListener.java

示例15: 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


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