本文整理汇总了Java中org.bukkit.event.entity.CreatureSpawnEvent.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java CreatureSpawnEvent.getLocation方法的具体用法?Java CreatureSpawnEvent.getLocation怎么用?Java CreatureSpawnEvent.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.CreatureSpawnEvent
的用法示例。
在下文中一共展示了CreatureSpawnEvent.getLocation方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
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()));
}
}
}
示例3: onSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event)
{
Entity ent = event.getEntity();
Location loc = event.getLocation();
ZoneWorld world = plugin.getWorld(loc.getWorld());
Zone zone = world.findZone(loc);
if(zone == null)return;
if(!zone.hasFlag(Flag.HOSTILES)){
if(types.contains(ent.getType())){
event.setCancelled(true);
return;
}
}
}
示例4: 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);
}
}
示例5: 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);
}
}
}
示例6: onEntitySpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent ese) {
if (BedwarsRel.getInstance().getGameManager() == null) {
return;
}
if (ese.getLocation() == null) {
return;
}
if (ese.getLocation().getWorld() == null) {
return;
}
Game game = BedwarsRel.getInstance().getGameManager().getGameByLocation(ese.getLocation());
if (game == null) {
return;
}
if (game.getState() == GameState.STOPPED) {
return;
}
if (ese.getEntityType().equals(EntityType.CREEPER)
|| ese.getEntityType().equals(EntityType.CAVE_SPIDER)
|| ese.getEntityType().equals(EntityType.SPIDER)
|| ese.getEntityType().equals(EntityType.ZOMBIE)
|| ese.getEntityType().equals(EntityType.SKELETON)
|| ese.getEntityType().equals(EntityType.SILVERFISH)) {
ese.setCancelled(true);
}
}
示例7: 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);
}
}
}
示例8: 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);
}
}
}
}
示例9: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getEntity() instanceof Monster) {
int range = Floodlight.INTERDICTION_RANGE * Floodlight.INTERDICTION_RANGE;
for (Floodlight light : lights) {
Location loc = event.getLocation();
if (loc.getWorld().equals(light.getLocation().getWorld()) && loc.distanceSquared(light.getLocation()) < range) {
Debugger.getInstance().debug(2, light + " prevents spawn of " + event.getEntity().getType());
event.setCancelled(true);
}
}
}
}
示例10: onSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent e) {
if(e.getEntity() instanceof Monster) {
if(pl.getManagers().getWorldGuardManager().isInRegion(e.getLocation())) {
if(!pl.getManagers().getWorldGuardManager().isFlagAllowed(pl.getManagers().getWorldGuardManager().getMonsterFlag(), e.getLocation())) {
Location loc = e.getLocation();
loc.setY(-10);
e.getEntity().teleport(loc);
}
}
}
}
示例11: onCreatureSpawn
import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler (ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
Location loc = event.getLocation();
if (Util.getQuadtree(loc).contains(loc))
event.setCancelled(true);
}