Java Code Examples for org.bukkit.entity.EntityType#SHEEP
The following examples show how to use
org.bukkit.entity.EntityType#SHEEP .
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: ShearObjective.java From BetonQuest with GNU General Public License v3.0 | 7 votes |
@EventHandler(ignoreCancelled = true) public void onShear(PlayerShearEntityEvent event) { if (event.getEntity().getType() != EntityType.SHEEP) return; String playerID = PlayerConverter.getID(event.getPlayer()); if (!containsPlayer(playerID)) return; if (name != null && (event.getEntity().getCustomName() == null || !event.getEntity().getCustomName().equals(name))) return; if (color != null && !((Sheep) event.getEntity()).getColor().toString().equalsIgnoreCase(color)) return; SheepData data = (SheepData) dataMap.get(playerID); if (checkConditions(playerID)) { data.shearSheep(); // complete quest or notify if (data.getAmount() <= 0) completeObjective(playerID); else if (notify && data.getAmount() % notifyInterval == 0) Config.sendNotify(playerID, "sheep_to_shear", new String[]{String.valueOf(data.getAmount())}, "sheep_to_shear,info"); } }
Example 2
Source File: RegionInteractListener.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerClickEntityEvent(PlayerInteractEntityEvent event) { Player player = event.getPlayer(); NovaPlayer nPlayer = PlayerManager.getPlayer(player); Entity entity = event.getEntity(); List<String> denyDamage = Config.REGION_DENYMOBDAMAGE.getStringList(); if(entity instanceof Player ) { return; } if(RegionManager.get(entity) != null) { if(event.getAction() == EntityUseAction.ATTACK) { if(!plugin.getRegionManager().canInteract(player, entity) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_ATTACK)) && denyDamage.contains(entity.getType().name())) { event.setCancelled(true); Message.CHAT_REGION_DENY_ATTACKMOB.send(player); } } else if(!plugin.getRegionManager().canInteract(player, entity) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_RIDE)) && entity.getType() == EntityType.SHEEP && CompatibilityUtils.getItemInMainHand(player).getType() == Material.SHEARS) { event.setCancelled(true); Message.CHAT_REGION_DENY_RIDEMOB.send(player); } } }
Example 3
Source File: ItemListener.java From Carbon with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityKilled(EntityDeathEvent e) { if (e.getEntity().getType() != EntityType.SHEEP || !plugin.getConfig().getBoolean("options.sheep.dropMutton", true) || !e.getEntity().getWorld().isGameRule("doMobLoot") || !(e.getEntity() instanceof Ageable)) { return; } Ageable entity = (Ageable) e.getEntity(); if (!entity.isAdult()) { return; } boolean fireaspect = false; int looting = 1; if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent dEvent = (EntityDamageByEntityEvent) entity.getLastDamageCause(); if (dEvent.getDamager() != null && dEvent.getDamager() instanceof Player) { ItemStack hand = ((Player) dEvent.getDamager()).getItemInHand(); fireaspect = hand.containsEnchantment(Enchantment.FIRE_ASPECT); if (hand.containsEnchantment(Enchantment.LOOT_BONUS_MOBS)) looting += hand.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS); if (looting < 1) //Incase a plugin sets an enchantment level to be negative looting = 1; } else if (dEvent.getDamager() != null && dEvent.getDamager() instanceof Arrow) { Arrow a = (Arrow) dEvent.getDamager(); if (a.getFireTicks() > 0) fireaspect = true; } } if (entity.getLastDamageCause().getCause() == DamageCause.FIRE_TICK || entity.getLastDamageCause().getCause() == DamageCause.FIRE || entity.getLastDamageCause().getCause() == DamageCause.LAVA || fireaspect) e.getDrops().add(new ItemStack(Carbon.injector().cookedMuttonItemMat, random.nextInt(2) + 1 + random.nextInt(looting))); else e.getDrops().add(new ItemStack(Carbon.injector().muttonItemMat, random.nextInt(2) + 1 + random.nextInt(looting))); }
Example 4
Source File: CraftSheep.java From Kettle with GNU General Public License v3.0 | 4 votes |
public EntityType getType() { return EntityType.SHEEP; }
Example 5
Source File: SentinelVersionCompat.java From Sentinel with MIT License | 4 votes |
static EntityType[] v1_8_passive() { return new EntityType[]{ EntityType.PIG, EntityType.OCELOT, EntityType.COW, EntityType.RABBIT, EntityType.SHEEP, EntityType.CHICKEN, EntityType.MUSHROOM_COW, EntityType.HORSE, EntityType.IRON_GOLEM, EntityType.SQUID, EntityType.VILLAGER, EntityType.WOLF, EntityType.SNOWMAN }; }
Example 6
Source File: SuperSheep.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
public SuperSheep() { this.name = ConfigValues.translationConfig.getString(TranslationConfig.NAME_SHEEP); this.entityType = EntityType.SHEEP; this.defaultMaxHealth = 8; this.isEnabled = ConfigValues.validMobsConfig.getBoolean(ValidMobsConfig.VALID_SUPERMOBS + getEntityType().toString()) && ConfigValues.validMobsConfig.getBoolean(ValidMobsConfig.ALLOW_PASSIVE_SUPERMOBS); if (this.isEnabled) { superMobTypeList.add(this.entityType); superMobData.add(this); } }
Example 7
Source File: CraftSheep.java From Thermos with GNU General Public License v3.0 | 4 votes |
public EntityType getType() { return EntityType.SHEEP; }
Example 8
Source File: TNTSheep.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") public void run(Location startLocation) { ItemStack usedStack = null; if (BedwarsRel.getInstance().getCurrentVersion().startsWith("v1_8")) { usedStack = player.getInventory().getItemInHand(); if (((SpawnEgg) usedStack.getData()).getSpawnedType() != EntityType.SHEEP) { return; } usedStack.setAmount(usedStack.getAmount() - 1); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), usedStack); } else { if (player.getInventory().getItemInOffHand().getType() == this.getItemMaterial()) { usedStack = player.getInventory().getItemInOffHand(); usedStack.setAmount(usedStack.getAmount() - 1); player.getInventory().setItemInOffHand(usedStack); } else if (player.getInventory().getItemInMainHand().getType() == this.getItemMaterial()) { usedStack = player.getInventory().getItemInMainHand(); usedStack.setAmount(usedStack.getAmount() - 1); player.getInventory().setItemInMainHand(usedStack); } } player.updateInventory(); final Team playerTeam = this.game.getPlayerTeam(this.player); Player targetPlayer = this.findTargetPlayer(this.player); if (targetPlayer == null) { this.player.sendMessage(ChatWriter .pluginMessage( ChatColor.RED + BedwarsRel ._l(this.player, "ingame.specials.tntsheep.no-target-found"))); return; } BedwarsUseTNTSheepEvent event = new BedwarsUseTNTSheepEvent(this.game, this.player, targetPlayer, startLocation); BedwarsRel.getInstance().getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } final Player target = event.getTargetPlayer(); final Location start = event.getStartLocation(); // as task new BukkitRunnable() { @Override public void run() { final TNTSheep that = TNTSheep.this; try { // register entity Class<?> tntRegisterClass = BedwarsRel.getInstance() .getVersionRelatedClass("TNTSheepRegister"); ITNTSheepRegister register = (ITNTSheepRegister) tntRegisterClass.newInstance(); TNTSheep.this.sheep = register.spawnCreature(that, start, TNTSheep.this.player, target, playerTeam.getColor().getDyeColor()); new BukkitRunnable() { @Override public void run() { that.getGame().getRegion() .removeRemovingEntity(that.getSheep().getTNT().getVehicle()); that.getGame().getRegion().removeRemovingEntity(that.getSheep().getTNT()); } }.runTaskLater(BedwarsRel.getInstance(), (long) (( BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.fuse-time", 8.0) * 20) - 5)); new BukkitRunnable() { @Override public void run() { that.getSheep().getTNT().remove(); that.getSheep().remove(); that.getGame().removeSpecialItem(that); } }.runTaskLater(BedwarsRel.getInstance(), (long) (( BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.fuse-time", 8.0) * 20) + 13)); TNTSheep.this.game.addSpecialItem(that); } catch (Exception ex) { BedwarsRel.getInstance().getBugsnag().notify(ex); ex.printStackTrace(); } } }.runTask(BedwarsRel.getInstance()); }
Example 9
Source File: ScrubEntityType.java From skRayFall with GNU General Public License v3.0 | 4 votes |
/** * Convert a string to a bukkit entity type. * * @param exprs The string to be converted. */ public static EntityType getType(String exprs) { switch (exprs.replace("\"", "").toLowerCase().replace("_", " ").replaceFirst("the ", "")) { case "player": case "the player": return EntityType.PLAYER; case "pig": return EntityType.PIG; case "blaze": return EntityType.BLAZE; case "bat": return EntityType.BAT; case "chicken": return EntityType.CHICKEN; case "creeper": return EntityType.CREEPER; case "cow": return EntityType.COW; case "enderman": return EntityType.ENDERMAN; case "ender dragon": return EntityType.ENDER_DRAGON; case "ghast": return EntityType.GHAST; case "giant": return EntityType.GIANT; case "iron golem": return EntityType.IRON_GOLEM; case "magma cube": return EntityType.MAGMA_CUBE; case "mushroom cow": return EntityType.MUSHROOM_COW; case "ocelot": return EntityType.OCELOT; case "pig zombie": return EntityType.PIG_ZOMBIE; case "sheep": return EntityType.SHEEP; case "silverfish": return EntityType.SILVERFISH; case "squid": return EntityType.SQUID; case "snowman": return EntityType.SNOWMAN; case "wolf": return EntityType.WOLF; case "skeleton": return EntityType.SKELETON; case "slime": return EntityType.SLIME; case "spider": return EntityType.SPIDER; case "witch": return EntityType.WITCH; case "wither": return EntityType.WITHER; case "villager": return EntityType.VILLAGER; case "zombie": return EntityType.ZOMBIE; case "armor stand": return EntityType.ARMOR_STAND; case "guardian": return EntityType.GUARDIAN; default: return EntityType.PLAYER; } }