本文整理汇总了Java中org.bukkit.event.entity.CreatureSpawnEvent.getEntityType方法的典型用法代码示例。如果您正苦于以下问题:Java CreatureSpawnEvent.getEntityType方法的具体用法?Java CreatureSpawnEvent.getEntityType怎么用?Java CreatureSpawnEvent.getEntityType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.CreatureSpawnEvent
的用法示例。
在下文中一共展示了CreatureSpawnEvent.getEntityType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason() != SpawnReason.NATURAL) { //TODO: Should check for Custom instead of checking against natural?
return;
}
EntityType type = event.getEntityType();
World world = event.getLocation().getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_SPAWNING) && worldConfig.getStringList(Config.FEATURE_MORE_SPAWNING_MOBS).contains(type.getName().toUpperCase())) {
for (int i = 0; i < Math.max(worldConfig.getInt(Config.FEATURE_MORE_SPAWNING_MULTIPLIER), 1); ++i) {
for (BloodMoonEntityType bloodMoonEntity : BloodMoonEntityType.values()) {
if (type == bloodMoonEntity.getEntityType()) {
bloodMoonEntity.spawnEntity(event.getLocation().add((random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5));
return;
}
}
}
}
}
示例3: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event)
{
//Replace spawned villager if new one spawns
if (event.getEntityType() == EntityType.VILLAGER)
{
final Entity villager = event.getEntity();
if (!NMSVillagerManager.isCustomVillager(villager))
{
Bukkit.getScheduler().runTask(TradeCraftPlugin.instance, new Runnable() {
@Override
public void run() {
NMSVillagerManager.convert(villager);
}
});
}
}
}
示例4: 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);
}
}
示例5: 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());
}
}
}
}
}
示例6: onChickenSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onChickenSpawn(CreatureSpawnEvent e)
{
if(e.getEntityType() == EntityType.CHICKEN)
{
if(e.getSpawnReason() == SpawnReason.BREEDING)
{
e.setCancelled(true);
Random rand = new Random();
Location loc = e.getLocation();
loc.getWorld().dropItem(loc, new ItemStack(Material.EGG, rand.nextInt(4) + 1));
loc.getWorld().playSound(loc, Sound.ENTITY_CHICKEN_EGG, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
}
}
}
示例7: onArmorSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onArmorSpawn(CreatureSpawnEvent evt) {
if (evt.getEntityType() != EntityType.ARMOR_STAND || placing == null)
return;
ArmorStand as = (ArmorStand) evt.getEntity();
as.setArms(placing.isArms());
as.setSmall(placing.isSmall());
placing = null;
}
示例8: onEntitySpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent e) {
if (e.getEntityType().isAlive() && e.getEntityType() != EntityType.PLAYER
&& e.getEntityType() != EntityType.ZOMBIE && e.getEntityType() != EntityType.ENDERMAN
&& e.getEntityType() != EntityType.PIG && e.getEntityType() != EntityType.COW
&& e.getEntityType() != EntityType.SHEEP && e.getEntityType() != EntityType.HORSE
&& e.getEntityType() != EntityType.SQUID) {
e.setCancelled(true);
e.getLocation().getWorld().spawn(e.getLocation(), Zombie.class);
}
}
示例9: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e)
{
if (e.getEntityType() != EntityType.PLAYER && e.getEntityType() != EntityType.WITHER)
{
if (MWAPI.getConfig().stopEntitySpawn())
{
e.setCancelled(true);
}
}
}
示例10: CreatureSpawnBlock
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST)
public void CreatureSpawnBlock(CreatureSpawnEvent event){
try{
final EntityType creature = event.getEntityType();
for(EntityType blocked : Main.moblist){
if(blocked == creature){
event.setCancelled(true);
}
}
}catch(NullPointerException e){}
}
示例11: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e) {
LivingEntity en = e.getEntity();
EntityType type = e.getEntityType();
Location loc = en.getLocation();
// Return without doing anything if we're in a whitelisted world, or if it's a blaze spawner
// in the configured blaze world
if (SpawnerGuard.config.getList("creative_worlds").contains(loc.getWorld().getName()) ||
(SpawnerGuard.config.getString("blaze_world_name").equals(loc.getWorld().getName()) &&
type == EntityType.BLAZE)) {
return;
}
// If entity was created by a spawner
if (e.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)) {
// If the entity is on our invalid creature list (it isn't allowed to come from a spawner)
if (SpawnerGuard.config.getList("invalid_creatures").contains(type.toString()) || SpawnerGuard.config.getString("blaze_world_name").equals(loc.getWorld().getName())) {
// Cancel the spawn!
e.setCancelled(true);
SpawnerGuard.log.warning(type.toString() + " generation by spawner prevented near " +
loc.getBlockX() + "," +
loc.getBlockY() + "," +
loc.getBlockZ() +
" in world: " + loc.getWorld().getName());
// Reset the spawner if that option is enabled
if (SpawnerGuard.config.getBoolean("reset_invalid_spawners")) {
plugin.changeBadSpawner(en.getLocation(), type);
}
}
}
}
示例12: onEntitySpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntitySpawn(final CreatureSpawnEvent event){
if(event.getEntityType() == EntityType.WOLF){
// Avoid a double iteration (a "contains" and "remove" call)
Iterator<Location> iter = getWolfSpawnLocSet().iterator();
while(iter.hasNext()){
if(iter.next().equals(event.getLocation())){
event.setCancelled(false);
iter.remove();
return;
}
}
}
}
示例13: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@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);
}
}
示例14: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
void onCreatureSpawn(CreatureSpawnEvent event) {
if (nextSpawnLocation == null) return;
if (event.getEntityType() == nextEntityType && event.getLocation().equals(nextSpawnLocation)) {
event.setCancelled(false);
} else {
// this shouldn't normally be reached..
Log.debug("Shopkeeper entity-spawning seems to be out of sync: spawn-force was activated for an entity of type "
+ nextEntityType.name() + " at location " + nextSpawnLocation.toString() + ", but a (different) entity of type "
+ event.getEntityType().name() + " was spawned at location " + event.getLocation().toString() + ".");
}
nextSpawnLocation = null;
nextEntityType = null;
}
示例15: WitherSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void WitherSpawn(CreatureSpawnEvent event){
EntityType eType;
try{
eType = event.getEntityType();
}catch(Exception e){
eType = null;
}
if(eType != null){
if(event.getEntityType() == EntityType.WITHER && plugin.isBlockWitherSpawn()){
event.setCancelled(true);
}
}
}