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


Java CreatureSpawnEvent.isCancelled方法代碼示例

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


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

示例1: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event == null || event.isCancelled() || event.getLocation() == null || !plugin.isSkyWorld(event.getLocation().getWorld())) {
        return; // Bail out, we don't care
    }
    if (!event.isCancelled() && ADMIN_INITIATED.contains(event.getSpawnReason())) {
        return; // Allow it, the above method would have blocked it if it should be blocked.
    }
    checkLimits(event, event.getEntity().getType(), event.getLocation());
    if (!event.isCancelled() && event.getEntity() instanceof Squid) {
        Location loc = event.getLocation();
        int z = loc.getBlockZ();
        int x = loc.getBlockX();
        if (loc.getWorld().getBiome(x, z) == Biome.DEEP_OCEAN && LocationUtil.findRoofBlock(loc).getType() == Material.PRISMARINE) {
            loc.getWorld().spawnEntity(loc, EntityType.GUARDIAN);
            event.setCancelled(true);
        }
    }
    if (!event.isCancelled() && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BUILD_WITHER && event.getEntity() instanceof Wither) {
        IslandInfo islandInfo = plugin.getIslandInfo(event.getLocation());
        if (islandInfo != null && islandInfo.getLeader() != null) {
            event.getEntity().setCustomName(I18nUtil.tr("{0}''s Wither", islandInfo.getLeader()));
            event.getEntity().setMetadata("fromIsland", new FixedMetadataValue(plugin, islandInfo.getName()));
        }
    }
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:27,代碼來源:SpawnEvents.java

示例2: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
	if(event.isCancelled())
		return;
	LivingEntity c = event.getEntity();
	if(c instanceof Zombie)
	{
		Zombie a = (Zombie) c;
		
		if(a.isBaby())
		{
			a.setBaby(false);
			//a.remove();
		}
			
	}
	
    // Some code here
}
 
開發者ID:nheir,項目名稱:killBaby,代碼行數:20,代碼來源:KillBaby.java

示例3: onCreatureSpawnEventLowest

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onCreatureSpawnEventLowest(CreatureSpawnEvent event) {
  if (!(event.getEntity() instanceof Monster) || event.isCancelled()) {
    return;
  }
  if (!mythicDrops.getConfigSettings().getEnabledWorlds().contains(event.getEntity().getWorld()
      .getName())) {
    return;
  }
  if (mythicDrops.getConfigSettings().isGiveAllMobsNames()) {
    nameMobs(event.getEntity());
  }
  if (mythicDrops.getConfigSettings().isBlankMobSpawnEnabled()) {
    event.getEntity().getEquipment().clear();
    if (event.getEntity() instanceof Skeleton && !mythicDrops.getConfigSettings()
        .isSkeletonsSpawnWithoutBows()) {
      event.getEntity().getEquipment().setItemInMainHand(new ItemStack(Material.BOW, 1));
    }
  }
  event.getEntity()
      .setCanPickupItems(mythicDrops.getConfigSettings().isMobsPickupEquipment());
}
 
開發者ID:Nunnery,項目名稱:MythicDrops,代碼行數:23,代碼來源:ItemSpawningListener.java

示例4: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
   public void onCreatureSpawn(CreatureSpawnEvent event) {
   	if (event.isCancelled()) {
           return;
       }
   	
   	Entity e = event.getEntity();
   	
   	//spawn arms on armor stands
       if (e instanceof ArmorStand && RPConfig.getBool("hooks.armor-stands.spawn-arms")) {
       	ArmorStand as = (ArmorStand) e;
       	as.setArms(true);
       }        
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:15,代碼來源:RPMine18.java

示例5: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
  public void onCreatureSpawn(CreatureSpawnEvent event) {
RedProtect.get().logger.debug("RPGlobalListener - Is CreatureSpawnEvent event! Cancelled? " + event.isCancelled());
  	if (event.isCancelled()) {
          return;
      }
      Entity e = event.getEntity();
      if (e == null) {
          return;
      }
      
      Location l = event.getLocation();
      Region r = RedProtect.get().rm.getTopRegion(l);
      if (r != null){
      	return;
      }
      
      if (e instanceof Wither && event.getSpawnReason().equals(SpawnReason.BUILD_WITHER) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-wither")){ 
          event.setCancelled(true);
          return;
      }        
      if (e instanceof Monster && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-monsters")) {        	
          if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
          	event.setCancelled(true);
              return;
          }
      }
      if ((e instanceof Animals || e instanceof Villager || e instanceof Golem) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-passives")) {        	
          if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
          	event.setCancelled(true);
	}
      }
  }
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:40,代碼來源:RPGlobalListener.java

示例6: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    if (!event.isCancelled())
    {
        Location loc = event.getLocation();
        if (event.getEntity() instanceof Monster)
        {
            if (Math.abs(loc.getBlockX()) < CoreData.getSpawnSize() && Math.abs(loc.getBlockZ()) < CoreData.getSpawnSize())
            {
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:Vanillacraft,項目名稱:vanillacraft,代碼行數:16,代碼來源:MobControl.java

示例7: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
/**
 * Comes AFTER the SpawnEvents{@link #onCreatureSpawn(CreatureSpawnEvent)} - so cancelled will have effect
 * @param e
 */
@EventHandler(priority = EventPriority.HIGH)
public void onCreatureSpawn(CreatureSpawnEvent e) {
    if (!spawnEnabled || e == null || e.isCancelled() || e.getSpawnReason() != CreatureSpawnEvent.SpawnReason.NATURAL || e.getEntity() == null) {
        return;
    }
    if (!plugin.isSkyNether(e.getLocation().getWorld())) {
        return;
    }
    if (e.getLocation().getBlockY() > plugin.getSkyBlockNetherWorld().getMaxHeight()) {
        // Block spawning above nether...
        e.setCancelled(true);
        return;
    }
    if (e.getEntity() instanceof PigZombie) {
        Block block = e.getLocation().getBlock().getRelative(BlockFace.DOWN);
        if (isNetherFortressWalkway(block)) {
            e.setCancelled(true);
            double p = RND.nextDouble();
            if (p <= chanceWither) {
                entitySpawner.spawnWitherSkeleton(e.getLocation());
            } else if (p <= chanceWither+chanceBlaze) {
                entitySpawner.spawnBlaze(e.getLocation());
            } else if (p <= chanceWither+chanceBlaze+chanceSkeleton) {
                entitySpawner.spawnSkeleton(e.getLocation());
            } else {
                e.setCancelled(false); // Spawn PigZombie
            }
        }
    }
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:35,代碼來源:NetherTerraFormEvents.java

示例8: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onCreatureSpawn(CreatureSpawnEvent event)
{
	if (event.isCancelled())
		return;

	Entity entity = event.getEntity();
	if (entity instanceof LivingEntity)
	{
		plugin.getHealthBarHandler().updateHealth((LivingEntity) entity);
	}
}
 
開發者ID:dmulloy2,項目名稱:SwornRPG,代碼行數:13,代碼來源:EntityListener.java

示例9: captureSpawnEvent

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void captureSpawnEvent(CreatureSpawnEvent event) {
    if (!event.isCancelled())
        logAndSend(getLoggableEntityEvent(EntityEventAction.SPAWN, event));
}
 
開發者ID:PowerSchill,項目名稱:LogToSplunk,代碼行數:6,代碼來源:CreatureEventLogger.java

示例10: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
	public void onEntitySpawn(CreatureSpawnEvent event) {
		if (event.isCancelled())
			return;
		
		// Don't mess with other Plugins or Spawn Eggs
		// REMEMBER: Our own Mod throws CUSTOM spawn events when we cancel the old spawn 
		//           and schedule a new one in this handler
		if ((SpawnReason.CUSTOM == event.getSpawnReason()) ||
			(SpawnReason.DISPENSE_EGG == event.getSpawnReason()))
			return;
		
		if (SpawnReason.BREEDING == event.getSpawnReason()) {
			event.getEntity().setMetadata("domesticated", new FixedMetadataValue(p, "true"));
			// BetterPassives used to assign a CustomName here on passives
			// TODO: Do over-crowding checks
		}
		
		// If a hostile tried to spawn, change it to a locally acceptable hostile
		if (event.getEntity() instanceof Monster) {
			// If this is not one of the Monsters(Hostile) that is allowed here, change it to one that is
		}
		
		if (PlanetSettings.getInstance().isAllowed(event)) {
			PlanetSettings.getInstance().applyPlanetChanges(event.getEntity());
		} else {
			event.setCancelled(true);
		}
		
//		} else if (event.getSpawnReason() != SpawnReason.CUSTOM) {
//			if (!event.isCancelled()) {
//				List<EntityType> types = p.getAcceptableHostileTypes(event.getEntity().getWorld());
//				if (types == null) {
//					event.setCancelled(true);
//					return;
//				}
//				if (types.size() == 0) {
//					event.setCancelled(true);
//					return;
//				}
//				if (types.contains(event.getEntity().getType()) && !event.getEntity().getWorld().getName().equalsIgnoreCase("Ceharram")){
//					hostileQueue.add(event.getEntity());
//					if(hostileQueue.size() > MAX_HOSTILES){
//						hostileQueue.remove().remove();
//					}
//					return;
//				}
//					
//
//				Collections.shuffle(types);
//				EntityType type = types.get(0);
//				Entity e = event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), type);
//				String n = e.getWorld().getName().toLowerCase();
//				if (e.getType() == EntityType.SKELETON && n.equals("inaris")) {
//					Skeleton s = (Skeleton) e;
//					s.setSkeletonType(SkeletonType.WITHER);
//				} else if (e.getType() == EntityType.CREEPER && n.equals("acualis")) {
//					Creeper c = (Creeper) e;
//					c.setPowered(true);
//					permaVanish(c);
//				} else if (e.getType() == EntityType.SKELETON && n.equals("krystallos")) {
//					createRobot((Skeleton) e);
//				} else if (e.getType() == EntityType.ZOMBIE && n.equals("emera")) {
//					createSpiritBlock((Zombie) e);
//				}
//				event.setCancelled(true);
//				hostileQueue.add(e);
//				if(hostileQueue.size() > MAX_HOSTILES){
//					hostileQueue.remove().remove();
//				}
//			}
//		}
	}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:74,代碼來源:EntityListener.java


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