本文整理汇总了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()));
}
}
}
示例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
}
示例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());
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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
}
}
}
}
示例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);
}
}
示例9: captureSpawnEvent
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void captureSpawnEvent(CreatureSpawnEvent event) {
if (!event.isCancelled())
logAndSend(getLoggableEntityEvent(EntityEventAction.SPAWN, event));
}
示例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();
// }
// }
// }
}