当前位置: 首页>>代码示例>>Java>>正文


Java CraftEventFactory.callProjectileLaunchEvent方法代码示例

本文整理汇总了Java中org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileLaunchEvent方法的典型用法代码示例。如果您正苦于以下问题:Java CraftEventFactory.callProjectileLaunchEvent方法的具体用法?Java CraftEventFactory.callProjectileLaunchEvent怎么用?Java CraftEventFactory.callProjectileLaunchEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.craftbukkit.event.CraftEventFactory的用法示例。


在下文中一共展示了CraftEventFactory.callProjectileLaunchEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addEntity

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
    if (entity == null) return false;
    // CraftBukkit end

    int i = MathHelper.floor(entity.locX / 16.0D);
    int j = MathHelper.floor(entity.locZ / 16.0D);
    boolean flag = entity.attachedToPlayer;

    if (entity instanceof EntityHuman) {
        flag = true;
    }

    // CraftBukkit start
    org.bukkit.event.Cancellable event = null;
    if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
        boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
        boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;

        if (spawnReason != SpawnReason.CUSTOM) {
            if (isAnimal && !allowAnimals || isMonster && !allowMonsters)  {
                entity.dead = true;
                return false;
            }
        }

        event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
    } else if (entity instanceof EntityItem) {
        event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
    } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
        // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
        event = CraftEventFactory.callProjectileLaunchEvent(entity);
    }

    if (event != null && (event.isCancelled() || entity.dead)) {
        entity.dead = true;
        return false;
    }
    // CraftBukkit end

    if (!flag && !this.isChunkLoaded(i, j)) {
        entity.dead = true; // CraftBukkit
        return false;
    } else {
        if (entity instanceof EntityHuman) {
            EntityHuman entityhuman = (EntityHuman) entity;

            this.players.add(entityhuman);
            this.everyoneSleeping();
            this.b(entity);
        }

        this.getChunkAt(i, j).a(entity);
        this.entityList.add(entity);
        this.a(entity);
        return true;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:58,代码来源:World.java

示例2: addEntity

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
    if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity add!"); // Spigot
    if (entity == null) return false;
    // CraftBukkit end

    int i = MathHelper.floor(entity.locX / 16.0D);
    int j = MathHelper.floor(entity.locZ / 16.0D);
    boolean flag = entity.p;

    if (entity instanceof EntityHuman) {
        flag = true;
    }

    // CraftBukkit start
    org.bukkit.event.Cancellable event = null;
    if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
        boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
        boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;

        if (spawnReason != SpawnReason.CUSTOM) {
            if (isAnimal && !allowAnimals || isMonster && !allowMonsters)  {
                entity.dead = true;
                return false;
            }
        }

        event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
    } else if (entity instanceof EntityItem) {
        event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
    } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
        // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
        event = CraftEventFactory.callProjectileLaunchEvent(entity);
    }
    // Spigot start
    else if (entity instanceof EntityExperienceOrb) {
        EntityExperienceOrb xp = (EntityExperienceOrb) entity;
        double radius = spigotConfig.expMerge;
        if (radius > 0) {
            List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
            for (Entity e : entities) {
                if (e instanceof EntityExperienceOrb) {
                    EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
                    if (!loopItem.dead) {
                        xp.value += loopItem.value;
                        loopItem.die();
                    }
                }
            }
        }
    } // Spigot end

    if (event != null && (event.isCancelled() || entity.dead)) {
        entity.dead = true;
        return false;
    }
    // CraftBukkit end

    if (!flag && !this.isChunkLoaded(i, j)) {
        entity.dead = true; // CraftBukkit
        return false;
    } else {
        if (entity instanceof EntityHuman) {
            EntityHuman entityhuman = (EntityHuman) entity;

            this.players.add(entityhuman);
            this.everyoneSleeping();
        }

        this.getChunkAt(i, j).a(entity);
        this.entityList.add(entity);
        this.a(entity);
        return true;
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:75,代码来源:World.java

示例3: addEntity

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
    org.spigotmc.AsyncCatcher.catchOp( "entity add"); // Spigot
    if (entity == null) return false;
    // CraftBukkit end

    int i = MathHelper.floor(entity.locX / 16.0D);
    int j = MathHelper.floor(entity.locZ / 16.0D);
    boolean flag = entity.attachedToPlayer;

    if (entity instanceof EntityHuman) {
        flag = true;
    }

    // CraftBukkit start
    org.bukkit.event.Cancellable event = null;
    if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
        boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
        boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;

        if (spawnReason != SpawnReason.CUSTOM) {
            if (isAnimal && !allowAnimals || isMonster && !allowMonsters)  {
                entity.dead = true;
                return false;
            }
        }

        event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
    } else if (entity instanceof EntityItem) {
        event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
    } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
        // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
        event = CraftEventFactory.callProjectileLaunchEvent(entity);
    }
    // Spigot start
    else if (entity instanceof EntityExperienceOrb) {
        EntityExperienceOrb xp = (EntityExperienceOrb) entity;
        double radius = spigotConfig.expMerge;
        if (radius > 0) {
            List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
            for (Entity e : entities) {
                if (e instanceof EntityExperienceOrb) {
                    EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
                    if (!loopItem.dead) {
                        xp.value += loopItem.value;
                        loopItem.die();
                    }
                }
            }
        }
    } // Spigot end

    if (event != null && (event.isCancelled() || entity.dead)) {
        entity.dead = true;
        return false;
    }
    // CraftBukkit end

    if (!flag && !this.isChunkLoaded(i, j)) {
        entity.dead = true; // CraftBukkit
        return false;
    } else {
        if (entity instanceof EntityHuman) {
            EntityHuman entityhuman = (EntityHuman) entity;

            this.players.add(entityhuman);
            this.everyoneSleeping();
            this.b(entity);
        }

        this.getChunkAt(i, j).a(entity);
        this.entityList.add(entity);
        this.a(entity);
        return true;
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:76,代码来源:World.java


注:本文中的org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileLaunchEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。