org.bukkit.entity.Mob Java Examples
The following examples show how to use
org.bukkit.entity.Mob.
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: DropTools.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
private Collection<ItemStack> generateLoot(LivingEntity dead, List<ItemStack> drops){ if(sm.getHookManager().isHookRegistered(PluginCompat.CUSTOMDROPS)){ CustomDropsHook cdh = (CustomDropsHook) sm.getHookManager().getHook(PluginCompat.CUSTOMDROPS); if(cdh.hasCustomDrops(dead)){ return cdh.getDrops(dead); } } if(dead instanceof Ageable){ if(!((Ageable) dead).isAdult()){ return Collections.emptySet(); } } // Default to true to keep the usual behaviour if (sm.getConfig().getBoolean("use-loot-table-for-drops", true)) { LootContext lootContext = new LootContext.Builder(dead.getLocation()).lootedEntity(dead).killer(dead.getKiller()).build(); return ((Mob) dead).getLootTable().populateLoot(ThreadLocalRandom.current(), lootContext); } else return drops; }
Example #2
Source File: StackTask.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
@Override public void run(){ for(Entity entity : world.getLivingEntities()){ if(!(entity instanceof Mob)){ continue; } if(sm.getLogic().incrementWaiting(entity)){ continue; } if(StackTools.hasNotEnoughNear(entity)) { if(sm.getLogic().notEnoughNearby(entity)){ continue; } } if(sm.getLogic().notSuitableForStacking(entity)){ continue; } sm.getLogic().foundMatch(entity); } }
Example #3
Source File: SpawnEvent.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent e){ LivingEntity entity = e.getEntity(); // IEntityTools before running task if(!(entity instanceof Mob)){ return; } if(sm.getLogic().doSpawnChecks(entity, e.getSpawnReason().toString())){ return; } if(sm.getLogic().makeWaiting(entity, e.getSpawnReason())){ return; } // BukkitRunnable to delay this, so the needed metadata can be set before attempting to merge. new SpawnTask(sm, entity).runTask(sm); }
Example #4
Source File: StickInteractEvent.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onStickInteract(PlayerInteractEntityEvent event){ Player player = event.getPlayer(); Entity entity = event.getRightClicked(); if(!(entity instanceof Mob)){ return; } if(event.getHand() != EquipmentSlot.HAND) { return; } if (sm.getStickTools().isStackingStick(player.getInventory().getItemInMainHand())) { if (player.isSneaking()) { sm.getStickTools().toggleMode(player); } else { if(!(StackTools.hasValidMetadata(player, GlobalValues.STICK_MODE))){ player.setMetadata(GlobalValues.STICK_MODE, new FixedMetadataValue(sm, 1)); } sm.getStickTools().performAction(player, entity); } } }
Example #5
Source File: LoadEvent.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onChunkLoad(ChunkLoadEvent e) { if(sm.getCustomConfig().getStringList("no-stack-worlds") .contains(e.getWorld().getName())){ return; } for(Entity currentEntity : e.getChunk().getEntities()){ if(!(currentEntity instanceof Mob)){ continue; } // Check if has been cached. if(sm.getCache().containsKey(currentEntity.getUniqueId())){ int cacheSize = sm.getCache().get(currentEntity.getUniqueId()); sm.getCache().remove(currentEntity.getUniqueId()); StackTools.setSize(currentEntity, cacheSize); continue; } if(currentEntity.getCustomName() != null){ continue; } if(sm.getTraitManager().checkTraits(currentEntity)){ continue; } if(sm.getHookManager().cantStack(currentEntity)){ continue; } if(sm.getLogic().doChecks(currentEntity)){ continue; } StackTools.setSize(currentEntity, GlobalValues.NOT_ENOUGH_NEAR); } }
Example #6
Source File: PlayerAttackListener.java From PetMaster with GNU General Public License v3.0 | 5 votes |
private boolean isDamagedTargettingDamager(Entity damager, Entity damaged) { if (damaged instanceof Mob) { Mob mob = (Mob) damaged; return mob.getTarget() != null && mob.getTarget().getUniqueId().equals(damager.getUniqueId()); } return false; }
Example #7
Source File: TagTask.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
public void run() { MythicMobsHook mobsHook = (MythicMobsHook) sm.getHookManager().getHook(PluginCompat.MYTHICMOBS); for (Entity e : WorldTools.getLoadedEntities()) { if (!sm.getCustomConfig().getStringList("no-stack-worlds").contains(e.getWorld().getName())) { if(!(e instanceof Mob)){ continue; } if (StackTools.hasValidStackData(e)) { String typeString = e.getType().toString(); int stackSize = StackTools.getSize(e); int removeAt = sm.getCustomConfig().getInt("tag.remove-at"); if (sm.getCustomConfig().isString("custom." + typeString + ".tag.remove-at")) { removeAt = sm.getCustomConfig().getInt("custom." + typeString + ".tag.remove-at"); } if (stackSize > removeAt) { String format = sm.getCustomConfig().getString("tag.format"); if (sm.getCustomConfig().isString("custom." + typeString + ".tag.format")) { format = sm.getCustomConfig().getString("custom." + typeString + ".tag.format"); } // Change if it is a mythic mob. if (sm.getHookManager().isHookRegistered(PluginCompat.MYTHICMOBS) && mobsHook.isMythicMob(e)) { typeString = mobsHook.getDisplayName(e); } else if (sm.getCustomConfig().getBoolean("tag.use-translations")) { typeString = "" + sm.getTranslationConfig().getString(e.getType().toString()); } String formattedType = WordUtils.capitalizeFully(typeString.replaceAll("[^A-Za-z0-9]", " ")); String nearlyFinal = StringUtils.replace(StringUtils.replace(StringUtils.replace(format, "%bukkit_type%", e.getType().toString()), "%type%", formattedType), "%size%", String.valueOf(stackSize)); String finalString = ChatColor.translateAlternateColorCodes('&', nearlyFinal); if(!finalString.equals(e.getCustomName())){ e.setCustomName(finalString); } if(!(sm.getHookManager().isHookRegistered(PluginCompat.PROCOTOLLIB))){ boolean alwaysVisible = sm.getCustomConfig().getBoolean("tag.always-visible"); if (sm.getCustomConfig().isString("custom." + typeString + ".tag.always-visible")) { alwaysVisible = sm.getCustomConfig().getBoolean("custom." + typeString + ".tag.always-visible"); } e.setCustomNameVisible(alwaysVisible); } } } } } }