Java 类org.bukkit.entity.EntityType 实例源码

项目:Chambers    文件:VillagerManager.java   
/**
 * Spawns a Villager of the given VillagerType at the provided Location
 * 
 * @param type - the Type of the Villager you wish to Spawn
 * @param location - the Location at which you want the Villager to be
 * @return Villager - the Villager that you had set at the provided Location if you wish to use it
 */
public Villager spawnVillager(VillagerType type, Location location) {
    if (!location.getChunk().isLoaded()) {
        location.getChunk().load();
    }
    Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
    villager.setAdult();
    villager.setAgeLock(true);
    villager.setProfession(Profession.FARMER);
    villager.setRemoveWhenFarAway(false);
    villager.setCustomName(type.getColor() + type.getName());
    villager.setCustomNameVisible(true);
    villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
    villager.teleport(location, TeleportCause.PLUGIN);
    villager.setHealth(20.0D);
    return villager;
}
项目:bskyblock    文件:IslandGuard1_8.java   
/**
 * Handle interaction with armor stands V1.8
 * Note - some armor stand protection is done in IslandGuard.java, e.g. against projectiles.
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + e.getEventName());
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ARMOR_STAND)) {
        if (actionAllowed(e.getPlayer(), e.getRightClicked().getLocation(), SettingsFlag.ARMOR_STAND)) {
            return;
        }
        e.setCancelled(true);
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
    }
}
项目:PA    文件:AntiGravity.java   
@Override
public void play(PAUser u) {
    if (isInCooldown(u, getName())) return;

    final ArmorStand as = (ArmorStand) spawnEntity(u.getLoc(), EntityType.ARMOR_STAND);
    as.setGravity(false);
    as.setSmall(true);
    as.setVisible(false);
    as.setHelmet(new ItemStack(Material.SEA_LANTERN));
    as.setPassenger(u.getPlayer());

    as.teleport(as.getLocation().add(0, 5, 0));

    bt = plugin.getServer().getScheduler().runTaskTimer(plugin, ()-> {
        as.teleport(as.getLocation().add(0, 0.2, 0));

        if (count <= 0) {
            remove(u, as);
            bt.cancel();
            return;
        }
        count--;
    }, 0, 20);
}
项目:AsgardAscension    文件:ChallengeListener.java   
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
    if(event.getEntity() instanceof Entity){
        Entity e = (Entity) event.getEntity();
        if(e.hasMetadata("challenge")){
            event.getDrops().clear();
            String[] meta = e.getMetadata("challenge").get(0).asString().split(", ");
            final String player = meta[1];
            plugin.getChallenges().addKill(Bukkit.getPlayer(player));
            Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)));
            if(e.getType().equals(EntityType.MAGMA_CUBE) || e.getType().equals(EntityType.SLIME)) {
                e.remove();
            }
            if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0){
                plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
            }
        }
    }
}
项目:bskyblock    文件:Schematic.java   
/**
 * Spawns a random companion for the player with a random name at the location given
 * @param player
 * @param location
 */
protected void spawnCompanion(Player player, Location location) {
    // Older versions of the server require custom names to only apply to Living Entities
    //Bukkit.getLogger().info("DEBUG: spawning compantion at " + location);
    if (!islandCompanion.isEmpty() && location != null) {
        Random rand = new Random();
        int randomNum = rand.nextInt(islandCompanion.size());
        EntityType type = islandCompanion.get(randomNum);
        if (type != null) {
            LivingEntity companion = (LivingEntity) location.getWorld().spawnEntity(location, type);
            if (!companionNames.isEmpty()) {
                randomNum = rand.nextInt(companionNames.size());
                String name = companionNames.get(randomNum).replace("[player]", player.getName());
                //plugin.getLogger().info("DEBUG: name is " + name);
                companion.setCustomName(name);
                companion.setCustomNameVisible(true);
            }
        }
    }
}
项目:SurvivalAPI    文件:ThreeArrowModule.java   
/**
 * Launch 2 more arrows when one is launched
 *
 * @param event Event
 */
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event)
{
    if (event.getEntity().getType() != EntityType.ARROW || !(event.getEntity().getShooter() instanceof Player) || event.getEntity().hasMetadata("TAM"))
        return;

    final Vector velocity = event.getEntity().getVelocity();

    for(int i = 0; i < 2; i++)
    {
        this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () ->
        {
            EntityArrow entityArrow = new EntityArrow(((CraftWorld)event.getEntity().getWorld()).getHandle(), ((CraftLivingEntity)event.getEntity().getShooter()).getHandle(), 1F);
            entityArrow.shoot(((CraftLivingEntity)event.getEntity().getShooter()).getHandle().pitch, ((CraftLivingEntity)event.getEntity().getShooter()).getHandle().yaw, 0.0F, 3.0F, 1.0F);
            entityArrow.getBukkitEntity().setMetadata("TAM", new FixedMetadataValue(this.plugin, true));
            entityArrow.getBukkitEntity().setVelocity(velocity);
            ((CraftWorld)event.getEntity().getWorld()).getHandle().addEntity(entityArrow);
        }, 5L * (i + 1));
    }
}
项目:Locked    文件:MerchantListener.java   
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    try {
        int balance = ScrapsUtil.getScraps(player);
        if (entity.getType().equals(EntityType.VILLAGER)) {
            event.setCancelled(true);
            String npc = entity.getName();
            if (MerchantManager.getAllNPCs().contains(npc)) {
                ItemStack selling = MerchantManager.getItem(npc);
                int price = MerchantManager.getPrice(npc);
                if (balance >= price) {
                    player.getInventory().addItem(selling);
                    player.sendMessage(MerchantManager.getSuccessMessage(npc));
                    ScrapsUtil.removeScraps(player, price);
                } else {
                    player.sendMessage(MerchantManager.getDenialMessage(npc));
                }
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
项目:UHC    文件:JoinQuitHandlers.java   
@EventHandler
public void leave(final PlayerQuitEvent event) {
    if(GameState.current() != GameState.LOBBY && event.getPlayer().getGameMode() != GameMode.SPECTATOR){
        event.setQuitMessage(colour("&6" + event.getPlayer().getName() + " has quit! " +
                "They have " + UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds() + "s to reconnect."));

        bukkitRunnable(() -> disqualified(event.getPlayer().getUniqueId(), event.getPlayer().getName(),
                event.getPlayer().getLocation(), event.getPlayer().getInventory())).runTaskLater(UHC.getInstance(),
                TimeUnit.MILLISECONDS.convert(UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds(), TimeUnit.SECONDS));

        //Zombie Spawning
        Zombie zombie = (Zombie) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.ZOMBIE);
        zombie.setCustomName(event.getPlayer().getName());
        zombie.setCustomNameVisible(true);
        //TODO Make no AI and invulnerable cough cough Proxi cough cough
        deadRepresentatives.put(event.getPlayer().getUniqueId(), zombie);
    }
}
项目:Sunscreen    文件:PluginSettings.java   
/**
 * Load the plugin's settings.
 *
 * @author HomieDion
 * @since 1.1.0
 */
public void load() {
    // Variables
    final Sunscreen plugin = Sunscreen.getInstance();
    final CustomConfig config = new CustomConfig("config.yml", plugin);
    final Logger log = plugin.getLogger();

    // Add the disabled worlds
    for (final String world : config.getStringList("disabled_worlds")) {
        worlds.add(world);
        log.info(String.format("%s will not use this plugin.", world));
    }

    // Loop all entities
    for (final EntityType type : EntityType.values()) {
        // Loop all values of the list
        for (final String line : config.getStringList("mobs")) {
            // If the names match
            if (type.name().equalsIgnoreCase(line)) {
                mobs.add(type);
                log.info(String.format("%s will not burn in the sun.", type.name()));
                break;
            }
        }
    }
}
项目:Hub    文件:PaintballDisplayer.java   
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
    if (event.getEntity().getType() != EntityType.SNOWBALL || !event.getEntity().hasMetadata("paintball-ball") || !event.getEntity().getMetadata("paintball-ball").get(0).asString().equals(this.uuid.toString()))
        return;

    for (Block block : getNearbyBlocks(event.getEntity().getLocation(), 2))
    {
        if (block.getType() == Material.AIR || block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
            continue;

        if (this.isBlockGloballyUsed(block.getLocation()))
            continue;

        SimpleBlock simpleBlock = new SimpleBlock(Material.STAINED_CLAY, DyeColor.values()[new Random().nextInt(DyeColor.values().length)].getWoolData());
        this.addBlockToUse(block.getLocation(), simpleBlock);

        block.setType(simpleBlock.getType());
        block.setData(simpleBlock.getData());
    }

    event.getEntity().remove();
}
项目:EchoPet    文件:SpawnUtil.java   
@SuppressWarnings("deprecation")
@Override
// This is kind of a dumb way to do this.. But I'm too lazy to fix my reflection
public org.bukkit.inventory.ItemStack getSpawnEgg(org.bukkit.inventory.ItemStack i, String entityTag){
    EntityType type = null;
    try{
        type = EntityType.valueOf(entityTag.toUpperCase());
    }catch(Exception ex){
        switch (entityTag){
            case "mooshroom":
                type = EntityType.MUSHROOM_COW;
                break;
            case "zombie_pigman":
                type = EntityType.PIG_ZOMBIE;
                break;
            default:
                type = EntityType.BAT;
                System.out.println("Bad tag: " + entityTag);
                break;
        }
    }
    return new ItemStack(i.getType(), i.getAmount(), type.getTypeId());
}
项目:EscapeLag    文件:AntiLongStringCrash.java   
@EventHandler
public void ClickCheckItem(InventoryClickEvent evt){
    if(ConfigPatch.AntiLongStringCrashenable == true){
        if(evt.getWhoClicked().getType() != EntityType.PLAYER){
            return;
        }
        Player player = (Player) evt.getWhoClicked();
        ItemStack item = evt.getCursor();
        if(item != null){
            if(item.hasItemMeta() && item.getItemMeta().getDisplayName() != null){
                if(item.getItemMeta().getDisplayName().length() >= 127){
                    evt.setCancelled(true);
                    evt.setCurrentItem(null);
                    AzureAPI.log(player, ConfigPatch.AntiLongStringCrashWarnMessage);
                }
            }
        }
    }
}
项目:RPGInventory    文件:LocationUtils.java   
public static List<Player> getNearbyPlayers(Location location, double distance) {
    List<Player> nearbyPlayers = new ArrayList<>();
    for (LivingEntity entity : location.getWorld().getLivingEntities()) {
        if (entity.getType() == EntityType.PLAYER && entity.getLocation().distance(location) <= distance) {
            nearbyPlayers.add((Player) entity);
        }
    }

    return nearbyPlayers;
}
项目:ProjectAres    文件:RocketUtils.java   
public static Firework getRandomFirework(Location loc) {
    FireworkMeta fireworkMeta = (FireworkMeta) (new ItemStack(Material.FIREWORK)).getItemMeta();
    Firework firework = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);

    fireworkMeta.setPower(GizmoConfig.FIREWORK_POWER);
    fireworkMeta.addEffect(FireworkEffect.builder()
            .with(RocketUtils.randomFireworkType())
            .withColor(RocketUtils.randomColor())
            .trail(GizmoConfig.FIREWORK_TRAIL)
            .build());

    firework.setFireworkMeta(fireworkMeta);
    return firework;
}
项目:PA    文件:KillAllCMD.java   
private List<Entity> worldEntities(World w, EntityType entityType) {
    List<Entity> entities = new ArrayList<>();

    w.getEntities().forEach(e -> {
        if (e.getType() == entityType) {
            entities.add(e);
        }
    });
    return entities;
}
项目:SuperiorCraft    文件:DamageIndicator.java   
@EventHandler
   public void onEntityDamageEvent(EntityDamageEvent e) {
    if (!(e.getEntity() instanceof ArmorStand) && e.getEntityType() != EntityType.ARMOR_STAND && e.getEntityType() != EntityType.DROPPED_ITEM) {
        Hologram h = new Hologram(ChatColor.RED + "-" + Double.toString(e.getDamage()) + " \u2764", e.getEntity().getLocation());
        h.getHologram().addScoreboardTag("dindicator");
        h.setKillTimer(2);
    }
    if (e.getEntity() instanceof Player) {
        Player player = (Player) e.getEntity();
        player.sendMessage(ChatColor.GRAY + "[DamageIndicator] " + e.getCause().name() + " did " + new DecimalFormat("#0.0").format(((double) Math.round(e.getDamage())) / 2) + ChatColor.RED + " \u2764");
    }
}
项目:mczone    文件:GeneralEvents.java   
@EventHandler
public void onDestroyByEntity(HangingBreakByEntityEvent event) {
    if ((event.getRemover() instanceof Player)) {
        if (event.getEntity().getType() == EntityType.ITEM_FRAME) {
            event.setCancelled(true);
        }
    }
}
项目:Mega-Walls    文件:CreatureSpawnListener.java   
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e)
{
    if (e.getEntityType() != EntityType.PLAYER && e.getEntityType() != EntityType.WITHER)
    {
        if (MWAPI.getConfig().stopEntitySpawn())
        {
            e.setCancelled(true);
        }
    }
}
项目:mczone    文件:PetColorCmd.java   
@Override
public boolean execute(CommandSender sender, String[] args) {       
    if (args.length < 2) {
        Chat.player(sender, "&2[Pets] &cUsage: /pet color [pet name] [color]");
        return true;
    }

    Player p = (Player) sender;
    String username = p.getName();
    for (PetInstance pet : PetInstance.getList()) {
        if (pet.getName().equalsIgnoreCase(args[0])) {
            if (pet.getOwner().equalsIgnoreCase(username)) {
                if (pet.getType() != EntityType.SHEEP) {
                    Chat.player(p, "&2[Pets] &cYou can only change the color of sheep.");
                    return true;
                }
                String[] nameArray = Arrays.copyOfRange(args, 1, args.length);
                String c = Joiner.on("_").join(nameArray);
                DyeColor color = null;
                try {
                    color = DyeColor.valueOf(c.toUpperCase());
                }
                catch (IllegalArgumentException e) {
                    Chat.player(p, "&2[Pets] &cUnknown color: " + c + "!");
                    Chat.player(p, "&cColors: &7&o" + Joiner.on(", ").join(DyeColor.values()).toLowerCase().replace("_", " "));
                    return true;
                }

                Chat.player(p, "&2[Pets] &aYou have changed the color of &e" + pet.getName() + "&a to " + c.replace("_", " "));
                pet.setColor(color);
                return true;
            }
        }
    }

    Chat.player(p, "&2[Pets] &cYou do not own a pet by the name of &e" + args[0] + "\n      &7&oBuy customized pets at www.mczone.co/shop");
       return true;
}
项目:SurvivalAPI    文件:MobOresModule.java   
/**
 * When a player breaks ore, spawn mob
 *
 * @param event Event
 */
@EventHandler(ignoreCancelled = true)
public void onEntityDeath(BlockBreakEvent event)
{
    EntityType type;

    switch (event.getBlock().getType())
    {
        case COAL_ORE:
            type = EntityType.ZOMBIE;
            break;

        case IRON_ORE:
            type = EntityType.SKELETON;
            break;

        case GOLD_ORE:
            type = EntityType.SPIDER;
            break;

        case DIAMOND_ORE:
            type = EntityType.WITCH;
            break;

        default:
            type = null;
            break;
    }

    Entity entity;

    if (type != null && random.nextDouble() < (double) this.moduleConfiguration.get("chance"))
    {
        entity = event.getBlock().getWorld().spawnEntity(event.getBlock().getLocation(), type);

        if (type == EntityType.SKELETON)
            ((Skeleton) entity).getEquipment().clear(); //Remove skeleton bow
    }
}
项目:SuperiorCraft    文件:CustomTexturedBlock.java   
@Override
public boolean placeBlock(ArmorStand e, Player p) {
    getTexture().placeBlock(e.getLocation().add(0, 0.125, -0.375));
    e.getLocation().getBlock().setType(getMaterial());
    if (getMaterial().equals(Material.MOB_SPAWNER)) {
        CreatureSpawner cs = (CreatureSpawner) e.getLocation().getBlock().getState();
        cs.setSpawnedType(EntityType.DROPPED_ITEM);
        cs.update();
    }
    setLe(e);
    return true;
}
项目:DungeonGen    文件:EntitySpawnTask.java   
/**Constructor, passes arguments to super class and loads special values from config.
 * @param parent    The Room this Task belongs to
 * @param conf      Given config file of this room has entries on tasks.
 * @param taskNr    Task number is needed to load keys correctly.
 */
public EntitySpawnTask(Room parent, FileConfiguration conf, int taskNr) {
    super(parent, conf, taskNr);
    this.type = TaskType.ENTITYSPAWN;

    // loading values for this Task type:
    String path = "tasks.task" + this.taskNr + ".";
    grp = new EntityGroup();
    grp.type = EntityType.valueOf(conf.getString( path + "entityType"));
    grp.count =                   conf.getInt(    path + "count");
    //TODO: maxCount noch einbauen -> bei jedem Spawning z�hlen, bei Tod runterz�hlen
    grp.maxCount =                conf.getInt(    path + "maxCount");
    grp.isTarget =                conf.getBoolean(path + "isTarget");
}
项目:bskyblock    文件:IslandGuard1_8.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void ArmorStandDestroy(EntityDamageByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + "IslandGuard New " + e.getEventName());
    }
    if (!(e.getEntity() instanceof LivingEntity)) {
        return;
    }
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    final LivingEntity livingEntity = (LivingEntity) e.getEntity();
    if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) {
        return;
    }
    if (e.getDamager() instanceof Player) {
        Player p = (Player) e.getDamager();
        if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        // Check if on island
        if (plugin.getIslands().playerIsOnIsland(p)) {
            return;
        }
        // Check island
        Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation());
        if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        if (island != null && island.getFlag(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
项目:PA    文件:KillAllCMD.java   
private List<Entity> worldClassEntities(World w, EntityType entityType) {
    List<Entity> entities = new ArrayList<>();

    w.getEntitiesByClass(entityType.getEntityClass()).forEach(e -> {
        if (e.getType() == entityType) {
            entities.add(e);
        }
    });
    return entities;
}
项目:mczone    文件:GeneralEvents.java   
@EventHandler
public void onEntityInteractEntity(PlayerInteractEntityEvent event) {
    if (event.getRightClicked().getType() == EntityType.ITEM_FRAME) {
        event.setCancelled(true);
        ItemFrame frame = (ItemFrame) event.getRightClicked();
        frame.setRotation(Rotation.NONE);
    }

}
项目:EchoPet    文件:WrappedEntityType.java   
public EntityType get() {
    try {
        return EntityType.valueOf(this.entityTypeName);
    } catch (Exception exception) {
        return null;
    }
}
项目:bskyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    ItemStack egg = new ItemStack(Material.MONSTER_EGG, amount);
    SpawnEggMeta spm = (SpawnEggMeta)egg.getItemMeta();
    spm.setSpawnedType(type);
    egg.setItemMeta(spm);
    return egg;
}
项目:MT_Core    文件:MobListener.java   
@EventHandler
public void onBurn(EntityCombustEvent e) {
    if (e.getEntityType() == EntityType.ZOMBIE) {
        long time = e.getEntity().getWorld().getTime();
        if (e.getEntity().getLocation().getBlock().getLightFromSky() == 15 && time > 0 && time < 12000) {
            e.getEntity().setFireTicks(0);
            e.setDuration(0);
            e.setCancelled(true);
        }
    }
}
项目:Kineticraft    文件:Frilda.java   
public Frilda(Dungeon d) {
    super(new Location(d.getWorld(), -5, 11, 56, 90, 0), EntityType.ZOMBIE, "Frilda", true);
    setGear(Material.STONE_SWORD, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS);
    addStage(new MeleeAttack(5, 2)); // TODO: Fireball.
    addStage(.65, "Argh! How dare you! You're going to regret this!",
            new MeleeAttack(6, 2.75), new AttackFlameWheel());
}
项目:SurvivalPlus    文件:Chairs.java   
private ArmorStand dropSeat(Block chair, Stairs stairs)
{
    Location location = chair.getLocation().add(0.5, (-0.7 - 0.5), 0.5);

    switch(stairs.getDescendingDirection())
    {
        case NORTH:
            location.setYaw(180);
            break;
        case EAST:
            location.setYaw(270);
            break;
        case SOUTH:
            location.setYaw(0);
            break;
        case WEST:
            location.setYaw(90);
        default:
    }

    ArmorStand drop = (ArmorStand)location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
    drop.setCustomName("Chair");
    drop.setVelocity(new Vector(0, 0, 0));
    drop.setGravity(false);
    drop.setVisible(false);

    return drop;
}
项目:MultiLineAPI    文件:Tag.java   
public PacketContainer refreshName(Entity forWhat, Player forWho) {
    if (this.name == null) return null;
    this.name.setWatcher(createArmorStandWatcher(
            getName((forWhat.getCustomName() != null && forWhat.getType() != EntityType.PLAYER) ?
                    forWhat.getCustomName() : forWhat.getName(), forWhat, forWho),
            forWhat.isCustomNameVisible() || forWhat.getType().equals(EntityType.PLAYER)
    ));
    return PacketUtil.getMetadataPacket(name);
}
项目:Kineticraft    文件:Flight.java   
/**
 * Is the player in a state or situation that we should deem them not flying?
 * @param player
 * @return immune
 */
private static boolean isImmune(Player player) {
    return player.getGameMode() != GameMode.SURVIVAL
            || Utils.getRank(player).isAtLeast(EnumRank.MEDIA) // Don't bypass this check.
            || player.isGliding() // Not using Elytra
            || player.hasPotionEffect(PotionEffectType.LEVITATION) // Doesn't have a levitation potion
            || player.getVehicle() != null // Not in a vehicle
            || player.getVelocity().getY() > 0 // Not being launched up
            || player.getNearbyEntities(1, 2, 1).stream().anyMatch(e -> e.getType() == EntityType.BOAT) // Not standing on a boat.
            || player.getLocation().getBlock().isLiquid(); // Not in water.
}
项目:KingdomFactions    文件:BlockPlace.java   
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {

    if (event.getItemInHand().getType() != Material.MOB_SPAWNER)
        return;

    ItemStack is = event.getItemInHand();
    if (!is.hasItemMeta())
        return;

    ItemMeta im = is.getItemMeta();

    if (!im.hasLore())
        return;

    String lore = im.getLore().toString();

    if (!lore.contains("Spawner:"))
        return;

    EntityType entity = getEntity(lore);

    if (entity == EntityType.AREA_EFFECT_CLOUD) {
        event.setCancelled(true);
        return;
    }

    setSpawner(event.getBlock(), entity);
}
项目:SurvivalPlus    文件:ChickenSpawn.java   
@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);
        }
    }
}
项目:Hub    文件:SonicSquid.java   
@EventHandler
public void onEntityDismount(EntityDismountEvent event)
{
    if (event.getEntity().getType() != EntityType.PLAYER)
        return;

    if (!this.hasPlayer((Player) event.getEntity()))
        return;

    event.getDismounted().setPassenger(event.getEntity());
}
项目:Uranium    文件:CraftCreatureSpawner.java   
public void setCreatureTypeByName(String creatureType) {
    // Verify input
    EntityType type = EntityType.fromName(creatureType);
    if (type == null) {
        return;
    }
    setSpawnedType(type);
}
项目:Uranium    文件:CraftStatistic.java   
public static net.minecraft.stats.StatBase getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) {
    EntityEggInfo entityEggInfo = (EntityEggInfo) EntityList.entityEggs.get(Integer.valueOf(entity.getTypeId()));

    if (entityEggInfo != null) {
        return entityEggInfo.field_151512_d;
    }
    return null;
}
项目:SuperiorCraft    文件:CustomBlockTexture.java   
public ArmorStand placeBlock(Location l) {
    ArmorStand block = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
    block.setSmall(true);
    block.setGravity(false);
    block.setCustomName("CustomBlock");
    block.setCustomNameVisible(false);
    block.setInvulnerable(true);
    block.setVisible(false);
    block.setMarker(true);
    block.setSilent(true);

    ItemStack a = new ItemStack(Material.LEATHER_BOOTS);
    a.setDurability((short) primary.getTexture());
    LeatherArmorMeta am = (LeatherArmorMeta) a.getItemMeta();
    am.setColor(primary.getColor());
    am.setUnbreakable(true);
    if (primary.isGlowing()) {
        am.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
    }
    a.setItemMeta(am);
    block.setHelmet(a);

    if (secondary != null) {
        ItemStack b = new ItemStack(Material.LEATHER_BOOTS);
        b.setDurability((short) secondary.getTexture());
        LeatherArmorMeta bm = (LeatherArmorMeta) b.getItemMeta();
        bm.setColor(secondary.getColor());
        bm.setUnbreakable(true);
        if (secondary.isGlowing()) {
            System.out.println("H");
            bm.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
        }
        b.setItemMeta(bm);
        block.getEquipment().setItemInMainHand(b);
    }

    return block;
}
项目:bskyblock    文件:IslandGuard1_9.java   
/**
 * Handle interaction with end crystals 1.9
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onHitEndCrystal(final PlayerInteractAtEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " +e.getEventName());
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
        return;
    }
    if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ENDER_CRYSTAL)) {
        // Check island
        Island island = plugin.getIslands().getIslandAt(e.getRightClicked().getLocation());
        if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        if (island !=null) {
            if (island.getMembers().contains(e.getPlayer().getUniqueId()) || island.getFlag(SettingsFlag.BREAK_BLOCKS)) {
                return;
            }
        }
        e.setCancelled(true);
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
    }
}
项目:SurvivalAPI    文件:SuperheroesModule.java   
/**
 * Cancel fall damages
 *
 * @param event Event instance
 */
@EventHandler
public void onDamage(EntityDamageEvent event)
{
    if (event.getEntityType() == EntityType.PLAYER && event.getCause() == EntityDamageEvent.DamageCause.FALL)
    {
        event.setCancelled(true);
        event.setDamage(0);
    }
}