org.bukkit.entity.Wolf Java Examples
The following examples show how to use
org.bukkit.entity.Wolf.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChildrenLeftUnattended.java From UhcCore with GNU General Public License v3.0 | 6 votes |
private void giveTeamReward(Player player){ Wolf wolf = (Wolf) player.getWorld().spawnEntity(player.getLocation(), EntityType.WOLF); wolf.setTamed(true); wolf.setOwner(player); wolf.setAdult(); ItemStack potion = new ItemStack(Material.POTION); PotionMeta meta = (PotionMeta) potion.getItemMeta(); meta.setMainEffect(PotionEffectType.SPEED); PotionEffect potionEffect = new PotionEffect(PotionEffectType.SPEED, 8*60*20, 0); meta.addCustomEffect(potionEffect, true); meta.setDisplayName(ChatColor.WHITE + "Potion of Swiftness"); potion.setItemMeta(meta); player.getWorld().dropItem(player.getLocation(), potion); }
Example #2
Source File: WolfData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public void set(final Wolf entity) { if (angry != 0) entity.setAngry(angry == 1); if (tamed != 0) entity.setTamed(tamed == 1); // if (owner != null) { // if (owner.isEmpty()) // entity.setOwner(null); // else // entity.setOwner(Bukkit.getOfflinePlayer(owner)); // } }
Example #3
Source File: BeastmastersBow.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@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; }
Example #4
Source File: BukkitCompat.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public boolean checkFood(Entity entity, ItemStack food) { Material type = food.getType(); switch (entity.getType()) { case COW: case SHEEP: case MUSHROOM_COW: return type == Material.WHEAT; case PIG: return (type == Material.CARROT || type == Material.BEETROOT || type == Material.POTATO); case CHICKEN: return type == Material.WHEAT_SEEDS || type == Material.MELON_SEEDS || type == Material.BEETROOT_SEEDS || type == Material.PUMPKIN_SEEDS; case HORSE: return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((Horse)entity).isTamed(); case WOLF: return (type == Material.BEEF || type == Material.CHICKEN || type == Material.COD || type == Material.MUTTON || type == Material.PORKCHOP || type == Material.RABBIT || type == Material.SALMON || type == Material.COOKED_BEEF || type == Material.COOKED_CHICKEN || type == Material.COOKED_COD || type == Material.COOKED_MUTTON || type == Material.COOKED_PORKCHOP || type == Material.COOKED_RABBIT || type == Material.COOKED_SALMON) && ((Wolf) entity).isTamed(); case OCELOT: return (type == Material.SALMON || type == Material.COD || type == Material.PUFFERFISH || type == Material.TROPICAL_FISH) && ((Ocelot) entity).isTamed(); case RABBIT: return type == Material.CARROT || type == Material.GOLDEN_CARROT || type == Material.DANDELION; case LLAMA: return type == Material.HAY_BLOCK; case TURTLE: return type == Material.SEAGRASS; } return false; }
Example #5
Source File: BukkitCompat.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public boolean checkFood(Entity entity, ItemStack food) { Material type = food.getType(); switch (entity.getType()) { case COW: case SHEEP: case MUSHROOM_COW: return type == Material.WHEAT; case PIG: return (type == Material.CARROT || type == Material.BEETROOT || type == Material.POTATO); case CHICKEN: return type == Material.WHEAT_SEEDS || type == Material.MELON_SEEDS || type == Material.BEETROOT_SEEDS || type == Material.PUMPKIN_SEEDS; case HORSE: return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((Horse)entity).isTamed(); case WOLF: return (type == Material.BEEF || type == Material.CHICKEN || type == Material.COD || type == Material.MUTTON || type == Material.PORKCHOP || type == Material.RABBIT || type == Material.SALMON || type == Material.COOKED_BEEF || type == Material.COOKED_CHICKEN || type == Material.COOKED_COD || type == Material.COOKED_MUTTON || type == Material.COOKED_PORKCHOP || type == Material.COOKED_RABBIT || type == Material.COOKED_SALMON) && ((Wolf) entity).isTamed(); case OCELOT: return (type == Material.SALMON || type == Material.COD || type == Material.PUFFERFISH || type == Material.TROPICAL_FISH); case RABBIT: return type == Material.CARROT || type == Material.GOLDEN_CARROT || type == Material.DANDELION; case LLAMA: return type == Material.HAY_BLOCK; case TURTLE: return type == Material.SEAGRASS; case PANDA: return type == Material.BAMBOO; case FOX: return type == Material.SWEET_BERRIES; case CAT: return (type == Material.COD || type == Material.SALMON) && ((Cat) entity).isTamed(); } return false; }
Example #6
Source File: WolfData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override protected boolean init(final @Nullable Class<? extends Wolf> c, final @Nullable Wolf e) { angry = e == null ? 0 : e.isAngry() ? 1 : -1; tamed = e == null ? 0 : e.isTamed() ? 1 : -1; return true; }
Example #7
Source File: WolfData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public boolean match(final Wolf entity) { return (angry == 0 || entity.isAngry() == (angry == 1)) && (tamed == 0 || entity.isTamed() == (tamed == 1)); // && (owner == null || owner.isEmpty() && entity.getOwner() == null || entity.getOwner() != null && entity.getOwner().getName().equalsIgnoreCase(owner)); }
Example #8
Source File: WolfData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public Class<Wolf> getType() { return Wolf.class; }
Example #9
Source File: EntityWolfPet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public Wolf getBukkitEntity() { return (Wolf) super.getBukkitEntity(); }
Example #10
Source File: DGamePlayer.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@Override public Wolf getWolf() { return wolf; }
Example #11
Source File: DGamePlayer.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@Override public void setWolf(Wolf wolf) { this.wolf = wolf; }
Example #12
Source File: DGamePlayer.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@Override public void update(boolean updateSecond) { boolean locationValid = true; Location teleportLocation = player.getLocation(); boolean teleportWolf = false; boolean offline = false; boolean kick = false; boolean triggerAllInDistance = false; if (!updateSecond) { if (!getPlayer().getWorld().equals(getWorld())) { locationValid = false; if (getGameWorld() != null) { teleportLocation = getLastCheckpoint(); if (teleportLocation == null) { teleportLocation = getGameWorld().getStartLocation(getGroup()); } // Don't forget Doge! if (getWolf() != null) { teleportWolf = true; } } } } else if (getGameWorld() != null) { // Update Wolf if (getWolf() != null) { if (getWolf().isDead()) { if (getWolfRespawnTime() <= 0) { setWolf((Wolf) getWorld().spawnEntity(getPlayer().getLocation(), EntityType.WOLF)); getWolf().setTamed(true); getWolf().setOwner(getPlayer()); setWolfRespawnTime(30); } wolfRespawnTime--; } // TODO Is doge even DMob? DungeonMob dMob = plugin.getDungeonMob(getWolf()); if (dMob != null) { getGameWorld().removeMob(dMob); } } // Kick offline players if (getOfflineTimeMillis() > 0) { offline = true; if (getOfflineTimeMillis() < System.currentTimeMillis()) { kick = true; } } triggerAllInDistance = true; } DInstancePlayerUpdateEvent event = new DInstancePlayerUpdateEvent(this, locationValid, teleportWolf, offline, kick, triggerAllInDistance); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return; } if (!locationValid) { getPlayer().teleport(teleportLocation); } if (teleportWolf) { getWolf().teleport(teleportLocation); } if (kick) { GroupPlayerKickEvent groupPlayerKickEvent = new GroupPlayerKickEvent(getGroup(), this, GroupPlayerKickEvent.Cause.OFFLINE); Bukkit.getPluginManager().callEvent(groupPlayerKickEvent); if (!groupPlayerKickEvent.isCancelled()) { leave(); } } if (triggerAllInDistance) { DistanceTrigger.triggerAllInDistance(getPlayer(), (DGameWorld) getGameWorld()); } }
Example #13
Source File: PlayerInteractListener.java From PetMaster with GNU General Public License v3.0 | 4 votes |
/** * Displays a hologram, and automatically delete it after a given delay. * * @param player * @param owner * @param tameable */ @SuppressWarnings("deprecation") private void displayHologramAndMessage(Player player, AnimalTamer owner, Tameable tameable) { if (hologramMessage) { double offset = HORSE_OFFSET; if (tameable instanceof Ocelot || version >= 14 && tameable instanceof Cat) { if (!displayCat || !player.hasPermission("petmaster.showowner.cat")) { return; } offset = CAT_OFFSET; } else if (tameable instanceof Wolf) { if (!displayDog || !player.hasPermission("petmaster.showowner.dog")) { return; } offset = DOG_OFFSET; } else if (version >= 11 && tameable instanceof Llama) { if (!displayLlama || !player.hasPermission("petmaster.showowner.llama")) { return; } offset = LLAMA_OFFSET; } else if (version >= 12 && tameable instanceof Parrot) { if (!displayParrot || !player.hasPermission("petmaster.showowner.parrot")) { return; } offset = PARROT_OFFSET; } else if (!displayHorse || !player.hasPermission("petmaster.showowner.horse")) { return; } Location eventLocation = tameable.getLocation(); // Create location with offset. Location hologramLocation = new Location(eventLocation.getWorld(), eventLocation.getX(), eventLocation.getY() + offset, eventLocation.getZ()); final Hologram hologram = HologramsAPI.createHologram(plugin, hologramLocation); hologram.appendTextLine( ChatColor.GRAY + plugin.getPluginLang().getString("petmaster-hologram", "Pet owned by ") + ChatColor.GOLD + owner.getName()); // Runnable to delete hologram. new BukkitRunnable() { @Override public void run() { hologram.delete(); } }.runTaskLater(plugin, hologramDuration); } String healthInfo = ""; if (showHealth) { Animals animal = (Animals) tameable; String currentHealth = String.format("%.1f", animal.getHealth()); String maxHealth = version < 9 ? String.format("%.1f", animal.getMaxHealth()) : String.format("%.1f", animal.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); healthInfo = ChatColor.GRAY + ". " + plugin.getPluginLang().getString("petmaster-health", "Health: ") + ChatColor.GOLD + currentHealth + "/" + maxHealth; } if (chatMessage) { player.sendMessage(plugin.getChatHeader() + plugin.getPluginLang().getString("petmaster-chat", "Pet owned by ") + ChatColor.GOLD + owner.getName() + healthInfo); } if (actionBarMessage) { try { FancyMessageSender.sendActionBarMessage(player, "&o" + ChatColor.GRAY + plugin.getPluginLang().getString("petmaster-action-bar", "Pet owned by ") + ChatColor.GOLD + owner.getName() + healthInfo); } catch (Exception e) { plugin.getLogger().warning("Errors while trying to display action bar message for pet ownership."); } } }
Example #14
Source File: GamePlayer.java From DungeonsXL with GNU General Public License v3.0 | 2 votes |
/** * Returns the player's wolf or null if he does not have one. * * @return the player's wolf or null if he does not have one * @deprecated More dynamic pet features might make this obsolete in the future. */ @Deprecated Wolf getWolf();
Example #15
Source File: GamePlayer.java From DungeonsXL with GNU General Public License v3.0 | 2 votes |
/** * Gives the player a wolf. * * @param wolf the wolf * @deprecated More dynamic pet features might make this obsolete in the future. */ @Deprecated void setWolf(Wolf wolf);