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"); } } } } } } } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onCreatureSpawn(final CreatureSpawnEvent event) { if (event.getEntity() instanceof PigZombie) { // Ok so an entity portal event begins // Find the nearest gate! final WorldCoord entityCoord = new WorldCoord(event.getEntity().getLocation()); final Gate nearestGate = GateUtil.nearestGate(entityCoord, false); if (nearestGate != null) { event.setCancelled(true); } } }
/** * Comes AFTER the SpawnEvents{@link #onCreatureSpawn(CreatureSpawnEvent)} - so cancelled will have effect * @param e */ @EventHandler(priority = EventPriority.HIGH) public void onCreatureSpawn(CreatureSpawnEvent e) { if (!spawnEnabled || e == null || e.isCancelled() || e.getSpawnReason() != CreatureSpawnEvent.SpawnReason.NATURAL || e.getEntity() == null) { return; } if (!plugin.isSkyNether(e.getLocation().getWorld())) { return; } if (e.getLocation().getBlockY() > plugin.getSkyBlockNetherWorld().getMaxHeight()) { // Block spawning above nether... e.setCancelled(true); return; } if (e.getEntity() instanceof PigZombie) { Block block = e.getLocation().getBlock().getRelative(BlockFace.DOWN); if (isNetherFortressWalkway(block)) { e.setCancelled(true); double p = RND.nextDouble(); if (p <= chanceWither) { entitySpawner.spawnWitherSkeleton(e.getLocation()); } else if (p <= chanceWither+chanceBlaze) { entitySpawner.spawnBlaze(e.getLocation()); } else if (p <= chanceWither+chanceBlaze+chanceSkeleton) { entitySpawner.spawnSkeleton(e.getLocation()); } else { e.setCancelled(false); // Spawn PigZombie } } } }
@Override public boolean effect(Event event, Player player) { // List<String> lore = e.getBow().getItemMeta().getLore(); // if(!lore.contains(placeHolder)) { // for(int i = descriptionSize; i != 0; i--) // lore.remove(i); // e.getProjectile().setMetadata("ce." + this.getOriginalName(), new FixedMetadataValue(main, writeType(lore))); // player.setMetadata("ce.CanUnleashBeasts", null); // } else // e.getProjectile().setMetadata("ce." + this.getOriginalName(), null); if(event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; if(e.getDamager() != player) return false; Entity ent = e.getEntity(); Location loc = ent.getLocation(); World w = ent.getWorld(); if(ent instanceof Silverfish || ent instanceof EnderDragon || ent instanceof Spider || ent instanceof Slime || ent instanceof Ghast || ent instanceof MagmaCube || ent instanceof CaveSpider || (ent instanceof Wolf && ((Wolf) ent).isAngry()) || ent instanceof PigZombie) { e.setDamage(e.getDamage()*DamageMultiplication); w.playEffect(loc, Effect.SMOKE, 50); w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 50); EffectManager.playSound(loc, "BLOCK_PISTON_RETRACT", 1.3f, 3f); return true; } else if (ent instanceof Player) { for(int i = 0; i < MaximumMobs; i++) { if(rand.nextInt(100) < MobAppearanceChance) { w.spawnEntity(loc, rand.nextInt(2) == 1 ? EntityType.SPIDER : EntityType.SLIME); w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 30); w.playEffect(loc, Effect.SMOKE, 30); EffectManager.playSound(loc, "BLOCK_ANVIL_BREAK", 0.3f, 0.1f); } } } } return false; }
public static Entity addlProps(Entity entity) { EntityType entityType = entity.getType(); if (entityType == EntityType.SKELETON && ((Skeleton) entity).getSkeletonType().getId() == 1) { ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.STONE_SWORD)); } else if (entityType == EntityType.SKELETON && ((Skeleton) entity).getSkeletonType().getId() == 0) { ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW)); } else if (entityType == EntityType.PIG_ZOMBIE) { ((PigZombie) entity).getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD)); } return entity; }
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; }
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; }
public static PigZombie create(Location l, Player p) { PigZombie a = create(l); a.setTarget(p); return a; }
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) { super(pig); this.bolt = bolt; this.pigzombie = pigzombie; }
public CanaryPigZombie(net.canarymod.api.entity.living.monster.PigZombie entity) { super(entity); }
@Override protected net.canarymod.api.entity.living.monster.PigZombie getHandle() { return (net.canarymod.api.entity.living.monster.PigZombie) super.getHandle(); }
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; }
/** * 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)); } }
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)); } } }
/** Checks that player is not trying to combatlog/is allowed to teleport * Returns an error message to be displayed if the player is not allowed * to teleport * Returns null if the player is allowed to teleport */ private static String teleportCheck(Player player) { Location pLoc = player.getLocation(); World world = player.getWorld(); /* Check if there are any players within 50 blocks */ for (Player p : world.getPlayers()) { if (!p.equals(player) && p.getLocation().distance(pLoc) < 50 && player.canSee(p) && !p.isDead()) { return ChatColor.RED + "You cannot use this command while within 50 blocks of any other players."; } } /* Check if there are any hostile mobs within 5 blocks */ for (Entity entity : world.getEntitiesByClasses( Blaze.class, CaveSpider.class, Creeper.class, Enderman.class, Ghast.class, MagmaCube.class, PigZombie.class, Skeleton.class, Silverfish.class, Slime.class, Spider.class, Witch.class, Zombie.class)) { if (entity.getLocation().distance(pLoc) < 5) { return ChatColor.RED + "You cannot use this command while within 5 blocks of any hostile mobs."; } } /* Check if the player is falling */ if (player.getVelocity().getY() < -0.079 || player.getVelocity().getY() > 0.08) { return ChatColor.RED + "You cannot use this command while falling."; } /* Check if the player is burning */ if (player.getFireTicks() > 0 && !player.hasPotionEffect( PotionEffectType.FIRE_RESISTANCE)) { return ChatColor.RED + "You cannot use this command while on fire."; } /* Default to allow teleport */ return null; }
@Override public PigZombie getPigZombie() { throw new NotImplementedException("TODO"); }
public PigZapEvent(Pig pig, LightningStrike bolt, PigZombie pigzombie) { }
public PigZombie getPigZombie() { return null; }