本文整理汇总了Java中org.bukkit.event.entity.CreatureSpawnEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java CreatureSpawnEvent.setCancelled方法的具体用法?Java CreatureSpawnEvent.setCancelled怎么用?Java CreatureSpawnEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.CreatureSpawnEvent
的用法示例。
在下文中一共展示了CreatureSpawnEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SLIME_SPLIT) { // allow slimes to always split
return;
}
switch (event.getSpawnReason()) {
case NATURAL:
if (event.getLocation().getChunk().getEntities().length > MAX_NATURAL_CHUNK_ENTITIES) {
event.setCancelled(true);
}
break;
case CHUNK_GEN:
if (event.getLocation().getChunk().getEntities().length > MAX_CHUNK_GENERATED_ENTITIES) {
event.setCancelled(true);
}
break;
default:
break;
}
}
示例2: onEntitySpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@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);
}
示例3: 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);
}
示例4: on
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void on(CreatureSpawnEvent event) {
if (!entityChecker.isEntityOfClassExact(event.getEntity(), toCheck)) return;
if (skips.contains(event.getSpawnReason())) return;
Location loc = event.getEntity().getLocation();
plugin.getLogger().severe(
String.format("Invalid spawn occured for entity type %s at x:%f y:%f z:%f, automatically cancelling...",
toCheck.getName(),
loc.getX(),
loc.getY(),
loc.getZ()
)
);
event.setCancelled(true);
}
示例5: onEntitySpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@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;
}
}
示例6: onEntitySpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk();
if (chunk == lastChunk) {
event.getEntity().remove();
event.setCancelled(true);
return;
}
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
return;
}
Entity[] entities = chunk.getEntities();
if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
event.getEntity().remove();
event.setCancelled(true);
lastChunk = chunk;
}
else {
lastChunk = null;
}
}
示例7: onSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
LivingEntity e = event.getEntity();
WorldSettings set = plugin.getWorlds().get(event.getEntity().getWorld().getName());
if (set == null) {
return;
}
if (!set.getEntities().contains(e.getType())) {
return;
}
if (!set.shouldExist(e)) {
event.setCancelled(true);
} else if (rand.nextDouble() > set.getRatio(e.getType())) {
event.setCancelled(true);
} else {
AttributeInstance maxHealth = e.getAttribute(Attribute.GENERIC_MAX_HEALTH);
maxHealth.setBaseValue(maxHealth.getBaseValue() * set.getHealth(e.getType()));
e.setHealth(e.getMaxHealth());
}
}
示例8: cancelMobSpawning
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void cancelMobSpawning(CreatureSpawnEvent event){
if(Minigame.getCurrentMinigame()!=null){
switch(Minigame.getCurrentMinigame().getMap().getType()){
case CIRCLE_OF_BOOM:
event.setCancelled(true);
break;
case KEY_QUEST:
break;
case WATER_THE_MONUMENT:
break;
default:
break;
}
}
}
示例9: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
Entity entity = event.getEntity();
String world = entity.getWorld().getUID().toString();
Integer x = entity.getLocation().getChunk().getX(), z = entity.getLocation().getChunk().getZ();
if (QuickChecks.isWorldChunkClaimed(serverdata.get("worldmap").get(world), x, z, "cla")) {
String pvillage = ((HashMap) ((HashMap) serverdata.get("worldmap").get(world).get(x)).get(z)).get("cla").toString();
if (serverdata.get("villages").get(pvillage).containsKey("mobs")) {
if (serverdata.get("villages").get(pvillage).get("mobs").equals("off")) {
event.setCancelled(true);
}
} else if (Config.getString("Village Settings.Toggle Settings.Mobs Enabled").equals("off")) {
event.setCancelled(true);
}
}
}
示例10: onEntitySpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk();
if (chunk == this.lastChunk) {
event.getEntity().remove();
event.setCancelled(true);
return;
}
if (!PS.get().hasPlotArea(chunk.getWorld().getName())) {
return;
}
Entity[] entities = chunk.getEntities();
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
event.getEntity().remove();
event.setCancelled(true);
this.lastChunk = chunk;
} else {
this.lastChunk = null;
}
}
示例11: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event)
{
Entity entity = event.getEntity();
Location location = event.getLocation();
Point pos = new Point(location.getBlockX(), location.getBlockZ());
ZoneWorld world = plugin.getWorld(entity.getWorld());
Zone zone = world.findZone(pos);
if (zone == null || zone.hasHostiles()) {
return;
}
if (!allowedMobs.contains(event.getEntityType()) &&
event.getSpawnReason() == SpawnReason.NATURAL) {
event.setCancelled(true);
}
}
示例12: 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);
}
}
示例13: 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());
}
}
}
}
}
示例14: onMobSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onMobSpawn(CreatureSpawnEvent evt) {
switch (evt.getSpawnReason()) {
case NATURAL:
case JOCKEY:
case CHUNK_GEN:
case SPAWNER:
case BUILD_WITHER:
case VILLAGE_DEFENSE:
case VILLAGE_INVASION:
case REINFORCEMENTS:
case NETHER_PORTAL:
if (Statics.ARENA_WORLD_NAME.equals(evt.getLocation().getWorld().getName())) {
evt.setCancelled(true);
}
break;
default:
break;
}
}
示例15: onMobSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
/**
* Prevents mobs spawning at spawn or in an island
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMobSpawn(final CreatureSpawnEvent e) {
if (DEBUG2) {
plugin.getLogger().info("on Mob spawn" + e.getEventName());
}
// if grid is not loaded yet, return.
if (plugin.getIslands() == null) {
return;
}
// If not in the right world, return
if (!Util.inWorld(e.getEntity())) {
return;
}
// Deal with natural spawning
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) {
if (DEBUG2)
plugin.getLogger().info("Natural monster spawn cancelled.");
// Mobs not allowed to spawn
e.setCancelled(true);
return;
}
}
if (e.getEntity() instanceof Animals) {
if (!actionAllowed(e.getLocation(), SettingsFlag.ANIMAL_SPAWN)) {
// Animals are not allowed to spawn
if (DEBUG2)
plugin.getLogger().info("Natural animal spawn cancelled.");
e.setCancelled(true);
}
}
}