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

项目:SuperiorCraft    文件:HoverBike.java   
public static Pig create(Location l) {
    Pig hov = (Pig) l.getWorld().spawnEntity(l, EntityType.PIG);

    hov.setSaddle(true);
    hov.setCustomName("HoverBike");
    hov.addScoreboardTag("speed:10");
    hov.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 30, true, false));
    hov.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, true, false));
    //hov.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1, true, false));
    hov.setAI(false);
    hov.setGravity(true);
    hov.setSilent(true);

    hov.setMaxHealth(100);
    hov.setHealth(100);

    return hov;
}
项目:Debuggery    文件:InputFormatterTest.java   
@Test
public void testBukkitClasses() throws InputException {
    Class[] inputTypes = {Class[].class};
    String[] input = {"Zombie,Creeper,Pig"};

    Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null);

    // First let's make sure we didn't lose anything, or get anything
    assertEquals(inputTypes.length, output.length);

    // Next let's make sure everything is the right type
    for (Object object : output) {
        assertTrue(object instanceof Class[]);
    }

    // Finally, let's make sure the values are correct
    Class[] classes = (Class[]) output[0];
    assertEquals(classes[0], Zombie.class);
    assertEquals(classes[1], Creeper.class);
    assertEquals(classes[2], Pig.class);
}
项目:SuperiorCraft    文件:HoverBike.java   
public static Pig create(Location l) {
    Pig hov = (Pig) l.getWorld().spawnEntity(l, EntityType.PIG);

    hov.setSaddle(true);
    hov.setCustomName("HoverBike");
    hov.addScoreboardTag("speed:10");
    hov.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 30, true, false));
    hov.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, true, false));
    //hov.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1, true, false));
    hov.setAI(false);
    hov.setGravity(true);
    hov.setSilent(true);

    hov.setMaxHealth(100);
    hov.setHealth(100);

    return hov;
}
项目:PerWorldInventory    文件:EntityPortalEventListenerTest.java   
@Test
public void shouldTeleportBecauseNotItem() {
    // given
    Pig entity = mock(Pig.class);
    World world = mock(World.class);
    Location from = new Location(world, 1, 2, 3);
    World worldNether = mock(World.class);
    Location to = new Location(worldNether, 1, 2, 3);
    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
}
项目:buildinggame    文件:PigMenu.java   
/**
 * {@inheritDoc}
 */
public PigMenu(Plot plot, Pig pig) {
    super(plot, pig);

    //saddle
    ItemStack saddle = new ItemStack(Material.SADDLE);
    ItemMeta saddleMeta = saddle.getItemMeta();
    saddleMeta.setDisplayName(ChatColor.GREEN + "Change whether this pig has a saddle");
    saddle.setItemMeta(saddleMeta);

    insertItem(saddle, event -> {
        pig.setSaddle(!pig.hasSaddle());

        event.setCancelled(true);
    }, 0);
}
项目:PerWorldInventory    文件:EntityPortalEventListenerTest.java   
@Test
public void shouldTeleportBecauseNotItem() {
    // given
    Pig entity = mock(Pig.class);
    World world = mock(World.class);
    Location from = new Location(world, 1, 2, 3);
    World worldNether = mock(World.class);
    Location to = new Location(worldNether, 1, 2, 3);
    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
}
项目:SuperiorCraft    文件:StopBlock.java   
public void loop() {
    for (Player p : Bukkit.getOnlinePlayers()) {
        for (Entity bl : p.getNearbyEntities(0.24, 2, 0.24)) {
            if (bl.getCustomName() != null && bl.getCustomName().equals(getName())) {
                for (Entity ent : p.getNearbyEntities(0.2, 0.2, 0.2)) {
                    if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
                        for (String tag : ent.getScoreboardTags()) {
                            if (tag.startsWith("speed:") && Integer.valueOf(tag.split(":")[1]) > 18) {
                                Police.create(p.getLocation().add(-10, 2, -10), p);
                                p.sendMessage("&6[Warning] Don't go past stops!".replace('&', '�'));
                                p.sendMessage("&9[Police] Pull over!".replace('&', '�'));

                                for (Entity pli : p.getNearbyEntities(50, 50, 50)) {
                                    if (pli.getCustomName() != null && pli.getCustomName().equals("Officer")) {
                                        ((PigZombie) pli).setTarget(p);
                                    }
                                }
                            }
                            else {
                                if (!ent.getScoreboardTags().contains("stopcooldown")) {
                                    ((Pig) ent).removePotionEffect(PotionEffectType.SPEED);
                                    ((Pig) ent).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 255, true, false));
                                    ((Pig) ent).setVelocity(new Vector(0, 0, 0));
                                } else {
                                    ent.getScoreboardTags().remove("stopcooldown");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
项目:SuperiorCraft    文件:StopBlock.java   
public void loop() {
    for (Player p : Bukkit.getOnlinePlayers()) {
        for (Entity bl : p.getNearbyEntities(0.24, 2, 0.24)) {
            if (bl.getCustomName() != null && bl.getCustomName().equals(getName())) {
                for (Entity ent : p.getNearbyEntities(0.2, 0.2, 0.2)) {
                    if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
                        for (String tag : ent.getScoreboardTags()) {
                            if (tag.startsWith("speed:") && Integer.valueOf(tag.split(":")[1]) > 18) {
                                Police.create(p.getLocation().add(-10, 2, -10), p);
                                p.sendMessage("&6[Warning] Don't go past stops!".replace('&', '�'));
                                p.sendMessage("&9[Police] Pull over!".replace('&', '�'));

                                for (Entity pli : p.getNearbyEntities(50, 50, 50)) {
                                    if (pli.getCustomName() != null && pli.getCustomName().equals("Officer")) {
                                        ((PigZombie) pli).setTarget(p);
                                    }
                                }
                            }
                            else {
                                if (!ent.getScoreboardTags().contains("stopcooldown")) {
                                    ((Pig) ent).removePotionEffect(PotionEffectType.SPEED);
                                    ((Pig) ent).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 255, true, false));
                                    ((Pig) ent).setVelocity(new Vector(0, 0, 0));
                                } else {
                                    ent.getScoreboardTags().remove("stopcooldown");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
项目:ExilePearl    文件:ExileListenerTest.java   
@Test
public void testOnPlayerDamageMob() {
    List<String> animals = new ArrayList<String>();
    when(config.getProtectedAnimals()).thenReturn(animals);
    dut.loadConfig(config);

    Pig pig = mock(Pig.class);

    EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, pig, null, modifiers, modifierFunctions);
    when(config.canPerform(ExileRule.KILL_MOBS)).thenReturn(true);
    dut.onPlayerDamage(e);
    assertFalse(e.isCancelled());

    e = new EntityDamageByEntityEvent(player, pig, null, modifiers, modifierFunctions);
    when(config.canPerform(ExileRule.KILL_MOBS)).thenReturn(false);
    dut.onPlayerDamage(e);
    assertFalse(e.isCancelled());

    e = new EntityDamageByEntityEvent(player, pig, null, modifiers, modifierFunctions);
    when(config.canPerform(ExileRule.KILL_MOBS)).thenReturn(true);
    when(pearlApi.isPlayerExiled(uid)).thenReturn(true);
    dut.onPlayerDamage(e);
    assertFalse(e.isCancelled());

    e = new EntityDamageByEntityEvent(player, pig, null, modifiers, modifierFunctions);
    when(config.canPerform(ExileRule.KILL_MOBS)).thenReturn(false);
    dut.onPlayerDamage(e);
    assertFalse(e.isCancelled());

    animals.add("Pig");
    dut.loadConfig(config);

    e = new EntityDamageByEntityEvent(player, pig, null, modifiers, modifierFunctions);
    dut.onPlayerDamage(e);
    assertTrue(e.isCancelled());
}
项目:NucleusFramework    文件:PigAnimal.java   
public PigAnimal(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Pig, "org.bukkit.entity.Pig expected.");

    Pig pig = (Pig)entity;

    _hasSaddle = pig.hasSaddle();
}
项目:NucleusFramework    文件:PigAnimal.java   
@Override
public boolean apply(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Pig, "org.bukkit.entity.Pig expected.");

    Pig pig = (Pig)entity;

    pig.setSaddle(_hasSaddle);

    return true;
}
项目:Uranium    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:SuperiorCraft    文件:Police.java   
public static PigZombie create(Location l) {
    PigZombie police = (PigZombie) l.getWorld().spawnEntity(l, EntityType.PIG_ZOMBIE);
    Pig hov = (Pig) l.getWorld().spawnEntity(l, EntityType.PIG);

    police.setMaxHealth(80);
    police.setHealth(80);

    ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
    LeatherArmorMeta helmMeta = (LeatherArmorMeta) helm.getItemMeta();
    helmMeta.setColor(Color.BLACK);
    helmMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Helmet");
    helmMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);

    helm.setItemMeta(helmMeta);

    ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE);
    LeatherArmorMeta chestMeta = (LeatherArmorMeta) chest.getItemMeta();
    chestMeta.setColor(Color.BLACK);
    chestMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Vest");
    chestMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);

    chest.setItemMeta(chestMeta);

    ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS);
    LeatherArmorMeta legMeta = (LeatherArmorMeta) leg.getItemMeta();
    legMeta.setColor(Color.BLACK);
    legMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Leggings");
    legMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);

    leg.setItemMeta(legMeta);

    ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
    LeatherArmorMeta bootsMeta = (LeatherArmorMeta) boots.getItemMeta();
    bootsMeta.setColor(Color.BLACK);
    bootsMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Boots");
    bootsMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
    bootsMeta.addEnchant(Enchantment.PROTECTION_FALL, 15, true);

    boots.setItemMeta(bootsMeta);

    EntityEquipment ee = police.getEquipment();

    ee.setHelmet(helm);
    ee.setChestplate(chest);
    ee.setLeggings(leg);
    ee.setBoots(boots);

    ee.setItemInOffHand(new ItemStack(Material.CARROT_STICK));

    police.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, true, false));
    hov.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4, true, false));

    hov.setPassenger(police);

    police.setCustomName("Officer");
    police.setCustomNameVisible(true);
    police.addScoreboardTag("law");


    return police;
}
项目:SuperiorCraft    文件:Police.java   
public static PigZombie create(Location l) {
    PigZombie police = (PigZombie) l.getWorld().spawnEntity(l, EntityType.PIG_ZOMBIE);
    Pig hov = (Pig) l.getWorld().spawnEntity(l, EntityType.PIG);

    police.setMaxHealth(80);
    police.setHealth(80);

    ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
    LeatherArmorMeta helmMeta = (LeatherArmorMeta) helm.getItemMeta();
    helmMeta.setColor(Color.BLACK);
    helmMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Helmet");
    helmMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);

    helm.setItemMeta(helmMeta);

    ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE);
    LeatherArmorMeta chestMeta = (LeatherArmorMeta) chest.getItemMeta();
    chestMeta.setColor(Color.BLACK);
    chestMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Vest");
    chestMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);

    chest.setItemMeta(chestMeta);

    ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS);
    LeatherArmorMeta legMeta = (LeatherArmorMeta) leg.getItemMeta();
    legMeta.setColor(Color.BLACK);
    legMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Leggings");
    legMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);

    leg.setItemMeta(legMeta);

    ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
    LeatherArmorMeta bootsMeta = (LeatherArmorMeta) boots.getItemMeta();
    bootsMeta.setColor(Color.BLACK);
    bootsMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Boots");
    bootsMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
    bootsMeta.addEnchant(Enchantment.PROTECTION_FALL, 15, true);

    boots.setItemMeta(bootsMeta);

    EntityEquipment ee = police.getEquipment();

    ee.setHelmet(helm);
    ee.setChestplate(chest);
    ee.setLeggings(leg);
    ee.setBoots(boots);

    ee.setItemInOffHand(new ItemStack(Material.CARROT_STICK));

    police.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, true, false));
    hov.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4, true, false));

    hov.setPassenger(police);

    police.setCustomName("Officer");
    police.setCustomNameVisible(true);
    police.addScoreboardTag("law");


    return police;
}
项目:Skript    文件:PigData.java   
@Override
protected boolean init(final @Nullable Class<? extends Pig> c, final @Nullable Pig e) {
    saddled = e == null ? 0 : e.hasSaddle() ? 1 : -1;
    return true;
}
项目:Skript    文件:PigData.java   
@Override
public void set(final Pig entity) {
    if (saddled != 0)
        entity.setSaddle(saddled == 1);
}
项目:Skript    文件:PigData.java   
@Override
protected boolean match(final Pig entity) {
    return saddled == 0 || entity.hasSaddle() == (saddled == 1);
}
项目:Skript    文件:PigData.java   
@Override
public Class<? extends Pig> getType() {
    return Pig.class;
}
项目:ThermosRebased    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Thermos-Bukkit    文件:PigZapEvent.java   
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
    super(pig);
    this.bolt = bolt;
    this.pigzombie = pigzombie;
}
项目:Thermos-Bukkit    文件:PigZapEvent.java   
@Override
public Pig getEntity() {
    return (Pig) entity;
}
项目:SonarPet    文件:EntityPigPet.java   
@Override
public void setSaddled(boolean flag) {
    ((Pig) getBukkitEntity()).setSaddle(flag);
}
项目:SmartPig    文件:SmartPig.java   
public SmartPig(Pig pig){
    this.pig = pig;
}
项目:Thermos    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:KCauldron    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:CauldronGit    文件:PigZapEvent.java   
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
    super(pig);
    this.bolt = bolt;
    this.pigzombie = pigzombie;
}
项目:CauldronGit    文件:PigZapEvent.java   
@Override
public Pig getEntity() {
    return (Pig) entity;
}
项目:CauldronGit    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:CanaryBukkit    文件:CanaryPig.java   
public CanaryPig(net.canarymod.api.entity.living.animal.Pig entity) {
    super(entity);
}
项目:CanaryBukkit    文件:CanaryPig.java   
@Override
protected net.canarymod.api.entity.living.animal.Pig getHandle() {
    return (net.canarymod.api.entity.living.animal.Pig) super.getHandle();
}
项目:Cauldron-Old    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Cauldron-Reloaded    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:AdvancedAchievements    文件:AchieveDistanceRunnable.java   
/**
 * Update distances and store them into server's memory until player disconnects.
 * 
 * @param player
 */
private void validateMovementAndUpdateDistance(Player player) {
    String uuid = player.getUniqueId().toString();
    Location previousLocation = playerLocations.get(uuid);

    // Update new location.
    playerLocations.put(uuid, player.getLocation());

    // If player location not found or if player has changed world, ignore previous location.
    // Evaluating distance would give an exception.
    if (previousLocation == null || !previousLocation.getWorld().getName().equals(player.getWorld().getName())) {
        return;
    }

    // If player is in restricted game mode or is in a blocked world, don't update distances.
    if (!shouldIncreaseBeTakenIntoAccountNoPermissions(player)) {
        return;
    }

    int difference = getDistanceDifference(player, previousLocation);
    // Player has not moved.
    if (difference == 0L) {
        return;
    }

    if (player.getVehicle() instanceof Horse) {
        updateDistance(difference, player, NormalAchievements.DISTANCEHORSE);
    } else if (player.getVehicle() instanceof Pig) {
        updateDistance(difference, player, NormalAchievements.DISTANCEPIG);
    } else if (player.getVehicle() instanceof Minecart) {
        updateDistance(difference, player, NormalAchievements.DISTANCEMINECART);
    } else if (player.getVehicle() instanceof Boat) {
        updateDistance(difference, player, NormalAchievements.DISTANCEBOAT);
    } else if (plugin.getServerVersion() >= 11 && player.getVehicle() instanceof Llama) {
        updateDistance(difference, player, NormalAchievements.DISTANCELLAMA);
    } else if (!player.isFlying() && (plugin.getServerVersion() < 9 || !player.isGliding())) {
        updateDistance(difference, player, NormalAchievements.DISTANCEFOOT);
    } else if (plugin.getServerVersion() >= 9 && player.isGliding()) {
        updateDistance(difference, player, NormalAchievements.DISTANCEGLIDING);
    }
}
项目:FFoKC    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(Entity pig, Entity lightning, Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:SimpleEgg    文件:LorePacker.java   
/**
 * Assembles an ArrayList of the properties for the specified Entity that
 * is to be used for a spawn egg. All instanceof checks are done internally
 * by the LorePackager, so no type checking is required prior to calling
 * this method. Null Entities will throw an IllegalArgumentException. <b>The
 * actual ArrayList is returned by {@link #getLore() LorePacker.getLore()}.
 * </b>
 * @param livingEntity - The Entity to assemble a lore for.
 * @return An ArrayList of Strings
 * @throws IllegalArgumentException If entity parameter is null
 */
public LorePacker(LivingEntity livingEntity) throws IllegalArgumentException {
    if (livingEntity == null) {
        throw new IllegalArgumentException("Can't assemble lore for a null entity!");
    }

    lore = new ArrayList<String>();
    // This needs to always be on top of an egg's lore
    lore.add("Identifier: SimpleEgg." + livingEntity.getType().getEntityClass().getSimpleName() + "." + Main.getSelf().getDescription().getVersion());
    lore.addAll(livingEntity(livingEntity));

    if (livingEntity instanceof Ageable) {
        lore.addAll(ageable((Ageable) livingEntity));

        if (livingEntity instanceof Sheep) {
            lore.addAll(sheep((Sheep) livingEntity));
        } else if (livingEntity instanceof Pig) {
            lore.addAll(pig((Pig) livingEntity));
        } else if (livingEntity instanceof Rabbit) {
            lore.addAll(rabbit((Rabbit) livingEntity));
        } else if (livingEntity instanceof Villager) {
            lore.addAll(villager((Villager) livingEntity));
        } else if (livingEntity instanceof Tameable) {
            lore.addAll(tameable((Tameable) livingEntity));

            if (livingEntity instanceof AbstractHorse) {
                lore.addAll(abstractHorse((AbstractHorse) livingEntity));

                if (livingEntity instanceof Horse) {
                    lore.addAll(horse((Horse) livingEntity));
                } else if (livingEntity instanceof ChestedHorse) {
                    lore.addAll(chestedHorse((ChestedHorse) livingEntity));

                    if (livingEntity instanceof Llama) {
                        lore.addAll(llama((Llama) livingEntity));
                    }
                }
            } else if (livingEntity instanceof Sittable) {
                lore.addAll(sittable((Sittable) livingEntity));

                if (livingEntity instanceof Wolf) {
                    lore.addAll(wolf((Wolf) livingEntity));
                } else if (livingEntity instanceof Ocelot) {
                    lore.addAll(ocelot((Ocelot) livingEntity));
                } else if (livingEntity instanceof Parrot) {
                    lore.addAll(parrot((Parrot) livingEntity));
                }
            }
        }
    } else if (livingEntity instanceof Slime) {
        lore.addAll(slime((Slime) livingEntity));
    } else if (livingEntity instanceof Creeper) {
        lore.addAll(creeper((Creeper) livingEntity));
    } else if (livingEntity instanceof Zombie) {
        lore.addAll(zombie((Zombie) livingEntity));

        if (livingEntity instanceof PigZombie) {
            lore.addAll(pigZombie((PigZombie) livingEntity));
        } else if (livingEntity instanceof ZombieVillager) {
            lore.addAll(zombieVillager((ZombieVillager) livingEntity));
        }
    } else if (livingEntity instanceof Spellcaster) {
        lore.addAll(spellCaster((Spellcaster) livingEntity));
    } else if (livingEntity instanceof IronGolem) {
        lore.addAll(ironGolem((IronGolem) livingEntity));
    } else if (livingEntity instanceof Snowman) {
        lore.addAll(snowman((Snowman) livingEntity));
    }
}
项目:AncientGates    文件:EntityUtil.java   
public static String getEntityTypeData(final Entity entity) {
    String data = "";

    if (entity instanceof LivingEntity) {
        data += String.valueOf(((LivingEntity) entity).getHealth()) + ",";
        data += String.valueOf(((LivingEntity) entity).getMaxHealth()) + ",";
        data += String.valueOf(((LivingEntity) entity).getCustomName()) + ",";
        if (entity instanceof Animals) {
            data += String.valueOf(((Animals) entity).getAge()) + ",";
            if (entity instanceof Sheep) {
                data += String.valueOf(((Sheep) entity).isSheared()) + ",";
                data += ((Sheep) entity).getColor().name() + ",";
            } else if (entity instanceof Wolf) {
                data += String.valueOf(((Wolf) entity).isAngry()) + ",";
                if (((Wolf) entity).isTamed()) {
                    data += ((Tameable) entity).getOwner().getName() + ",";
                    data += String.valueOf(((Wolf) entity).getCollarColor()) + ",";
                }
            } else if (entity instanceof Ocelot) {
                if (((Ocelot) entity).isTamed()) {
                    data += ((Tameable) entity).getOwner().getName() + ",";
                    data += String.valueOf(((Ocelot) entity).getCatType().name()) + ",";
                }
            } else if (entity instanceof Pig) {
                data += String.valueOf(((Pig) entity).hasSaddle()) + ",";
            } else if (entity instanceof Horse) {
                data += "deprecated" + ",";
                data += String.valueOf(((Horse) entity).getStyle().name()) + ",";
                data += String.valueOf(((Horse) entity).getColor().name()) + ",";
                data += String.valueOf(((Horse) entity).getDomestication()) + ",";
                data += String.valueOf(((Horse) entity).getMaxDomestication()) + ",";
                data += String.valueOf(((Horse) entity).getJumpStrength()) + ",";
                if (((Horse) entity).isTamed()) {
                    data += (((Tameable) entity).getOwner() != null ? ((Tameable) entity).getOwner().getName() : null) + ",";
                    data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getSaddle()) + ",";
                    data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getArmor()) + ",";
                    if (((Horse) entity).isCarryingChest()) {
                        data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getContents()) + ",";
                    }
                }
            }
        } else if (entity instanceof Villager) {
            data += String.valueOf(((Villager) entity).getProfession().name()) + ",";
            data += String.valueOf(((Villager) entity).getAge()) + ",";
        } else if (entity instanceof Creeper) {
            data += String.valueOf(((Creeper) entity).isPowered()) + ",";
        } else if (entity instanceof Slime) {
            data += String.valueOf(((Slime) entity).getSize()) + ",";
        } else if (entity instanceof Skeleton) {
            data += String.valueOf(((Skeleton) entity).getSkeletonType().name()) + ",";
        }
    }

    return data;
}
项目:AncientGates    文件:EntityUtil.java   
public static void setEntityTypeData(final Entity entity, final String data) {
    if (data == "")
        return;

    final String parts[] = data.split(",");
    if (entity instanceof LivingEntity) {
        ((LivingEntity) entity).setMaxHealth(Double.parseDouble(parts[1]));
        ((LivingEntity) entity).setHealth(Double.parseDouble(parts[0]));
        if (!parts[2].equals("null"))
            ((LivingEntity) entity).setCustomName(parts[2]);
        if (entity instanceof Animals) {
            ((Animals) entity).setAge(Integer.parseInt(parts[3]));
            if (entity instanceof Sheep) {
                ((Sheep) entity).setSheared(Boolean.parseBoolean(parts[4]));
                ((Sheep) entity).setColor(sheepColors.get(parts[5]));
            } else if (entity instanceof Wolf) {
                if (Boolean.parseBoolean(parts[4])) {
                    ((Wolf) entity).setAngry(Boolean.parseBoolean(parts[4]));
                } else if (parts.length > 5) {
                    ((Tameable) entity).setTamed(true);
                    ((Tameable) entity).setOwner(getPlayer(parts[5]));
                    ((Wolf) entity).setCollarColor(DyeColor.valueOf(parts[6]));
                }
            } else if (entity instanceof Ocelot) {
                if (parts.length > 4) {
                    ((Tameable) entity).setTamed(true);
                    ((Tameable) entity).setOwner(getPlayer(parts[4]));
                    ((Ocelot) entity).setCatType(catTypes.get(parts[5]));
                }
            } else if (entity instanceof Pig) {
                ((Pig) entity).setSaddle(Boolean.parseBoolean(parts[4]));
            } else if (entity instanceof Horse) {
                // ((Horse) entity).setVariant(horseVariants.get(parts[4]));
                ((Horse) entity).setStyle(horseStyles.get(parts[5]));
                ((Horse) entity).setColor(horseColors.get(parts[6]));
                ((Horse) entity).setDomestication(Integer.parseInt(parts[7]));
                ((Horse) entity).setMaxDomestication(Integer.parseInt(parts[8]));
                ((Horse) entity).setJumpStrength(Double.parseDouble(parts[9]));
                if (parts.length > 10) {
                    ((Tameable) entity).setTamed(true);
                    if (!parts[10].equals("null"))
                        ((Tameable) entity).setOwner(getPlayer(parts[10]));
                    ((Horse) entity).getInventory().setSaddle(ItemStackUtil.stringToItemStack(parts[11])[0]);
                    ((Horse) entity).getInventory().setArmor(ItemStackUtil.stringToItemStack(parts[12])[0]);
                    if (parts.length > 13) {
                        ((Horse) entity).setCarryingChest(true);
                        ((Horse) entity).getInventory().setContents(ItemStackUtil.stringToItemStack(parts[13]));
                    }
                }
            }
        } else if (entity instanceof Villager) {
            ((Villager) entity).setProfession(villagerProfessions.get(parts[3]));
            ((Villager) entity).setAge(Integer.parseInt(parts[4]));
        } else if (entity instanceof Creeper) {
            ((Creeper) entity).setPowered(Boolean.parseBoolean(parts[3]));
        } else if (entity instanceof Slime) {
            ((Slime) entity).setSize(Integer.parseInt(parts[3]));
        } else if (entity instanceof Skeleton) {
            ((Skeleton) entity).setSkeletonType(skeletonTypes.get(parts[3]));
            if (parts[3].equals("0")) {
                ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
            } else {
                ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
            }
        } else if (entity instanceof PigZombie) {
            ((LivingEntity) entity).getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD));
        }
    }
}
项目:Craftbukkit    文件:CraftEventFactory.java   
public static PigZapEvent callPigZapEvent(Entity pig, Entity lightning, Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
项目:PwnBreeding    文件:FeedListener.java   
@EventHandler(ignoreCancelled = true)
  public void onAnimalClick(PlayerInteractEntityEvent e)
  {
// THIS EVENT FIRES TOO FAST WE NEED A TIMER


World eworld = e.getPlayer().getLocation().getWorld();

// If plugin is not enabled in this world, return
if (!PwnBreeding.isEnabledIn(eworld.getName())) return; 

      Player player = e.getPlayer(); 
      String thisItem = player.getItemInHand().getType().toString();

      if(e.getRightClicked() instanceof Chicken)
      {          

        e.setCancelled(true);

          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
          if (player.getItemInHand().getType() == Material.SEEDS) 
          {
              if(player.getItemInHand().getAmount() > 1) 
              {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
              } 
              else 
              {
                  player.getItemInHand().setAmount(0);
              }
          }
      }
      else if(e.getRightClicked() instanceof Cow)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Sheep)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Pig)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Horse)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Wolf)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Ocelot)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Rabbit)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }        
  }