@Override public boolean isValidMobType(String type) { final EntityType entityType = EntityType.fromName(type); return entityType != null && entityType.isAlive(); }
public void add(EntityType... entities) { init(false); for (EntityType entity : entities) { if (entity.isAlive()) items.add(entity); } }
public boolean isMisc() { return getEntityType() != null && !getEntityType().isAlive(); }
public boolean isMob() { return getEntityType() != null && getEntityType().isAlive() && !isPlayer(); }
@Override public Collection<String> onTabComplete(CommandSender sender, String commandName, String[] args) { List<String> options = new ArrayList<>(); if (!sender.hasPermission("Magic.commands.mmob")) return options; if (args.length == 1) { options.add("spawn"); options.add("list"); options.add("clear"); } else if (args.length == 2 && (args[0].equalsIgnoreCase("spawn") || args[0].equalsIgnoreCase("clear"))) { options.addAll(api.getController().getMobKeys()); for (EntityType entityType : EntityType.values()) { if (entityType.isAlive() && entityType.isSpawnable()) { options.add(entityType.name().toLowerCase()); } } } else if (args.length == 3 && args[0].equalsIgnoreCase("clear")) { List<World> worlds = api.getPlugin().getServer().getWorlds(); for (World world : worlds) { options.add(world.getName()); } } return options; } }
options.addAll(api.getController().getMobKeys()); for (EntityType entityType : EntityType.values()) { if (entityType.isAlive() && entityType.isSpawnable()) { options.add(entityType.name().toLowerCase());
for (EntityType loop : EntityType.values()) if (loop.isAlive())
if (entities[i].isAlive()) entity = entities[i]; else
private final void setSpawner(CityWorldGenerator generator, SupportBlocks blocks, Odds odds, int x, int y, int z, EntityType entity) { if (entity.isAlive() && odds.playOdds(generator.getSettings().spawnBaddies)) { Block block = blocks.getActualBlock(x, y, z); block.setType(Material.SPAWNER); block.getState().update(true); // for good measure if (block.getType() == Material.SPAWNER) { // make sure it happened! CreatureSpawner spawner = (CreatureSpawner) block.getState(); spawner.setSpawnedType(entity); spawner.update(true); } } }
@Override protected void loadKeys() { if (config.getConfigurationSection("Treasures") != null) { backup(); return; } loadTreasures("Fishing"); loadTreasures("Excavation"); loadTreasures("Hylian_Luck"); loadEnchantments(); for (EntityType entity : EntityType.values()) { if (entity.isAlive()) { loadTreasures("Shake." + entity.toString()); } } }
type.name().toLowerCase().replace('_', ' '))); if (requirements.livingEntity() && !type.isAlive()) { throw new RequirementMissingException( Messaging.tr(CommandMessages.REQUIREMENTS_MUST_BE_LIVING_ENTITY, methodArgs));
/** * Spawn all the creatures */ public void doCreatureSpawns(Field field) { int minx = field.getX() - field.getRadius(); int maxx = field.getX() + field.getRadius(); int minz = field.getZ() - field.getRadius(); int maxz = field.getZ() + field.getRadius(); int miny = field.getY() - (int) Math.floor(((double) field.getHeight()) / 2); int maxy = field.getY() + (int) Math.ceil(((double) field.getHeight()) / 2); Random r = new Random(); FieldSettings fs = field.getSettings(); for (int i = 0; i < fs.getCreatureCount(); i++) { int x = r.nextInt(maxx - minx) + minx; int z = r.nextInt(maxz - minz) + minz; int y = field.getY(); World world = field.getBlock().getWorld(); int floorType = world.getBlockTypeIdAt(x, y, z); while (!plugin.getSettingsManager().isThroughType(floorType) && y < 256) { floorType = world.getBlockTypeIdAt(x, ++y, z); } EntityType entity = getEntity(fs); if (entity == null || !entity.isAlive() || !entity.isSpawnable()) { continue; } world.spawnEntity(new Location(world, x, y, z), entity); } }
/** * Tests if we have an entry for every Bukkit entry. */ @Test public void testBukkitTypesExistInMobNames() { for (EntityType type : EntityType.values()) { if (type.isAlive() && type.isSpawnable() && type != EntityType.ARMOR_STAND) { // Throws IllegalArgumentException if no entry exists MobNames.valueOf(type.toString()); } } }
if (!type.isSpawnable() || !type.isAlive())
/** * Spawns the mob. * * @return the spawned mob */ public LivingEntity spawn() { Location spawnLoc = getSign().getLocation().add(0.5, 0, 0.5); LivingEntity spawned = null; if (provider == null) { ExMob type = plugin.getCaliburn().getExMob(mob); if (type == null || !type.getSpecies().isAlive()) { return null; } spawned = (LivingEntity) type.toEntity(spawnLoc); spawned.setRemoveWhenFarAway(false); } else { provider.summon(mob, spawnLoc); for (Entity entity : spawnLoc.getChunk().getEntities()) { Location entityLoc = entity.getLocation(); if (entityLoc.getX() >= spawnLoc.getX() - 1 && entityLoc.getX() <= spawnLoc.getX() + 1 && entityLoc.getY() >= spawnLoc.getY() - 1 && entityLoc.getY() <= spawnLoc.getY() + 1 && entityLoc.getZ() >= spawnLoc.getZ() - 1 && entityLoc.getZ() <= spawnLoc.getZ() + 1 && entity instanceof LivingEntity && !spawnedMobs.contains((LivingEntity) entity) && !(entity instanceof Player)) { spawned = (LivingEntity) entity; } } } spawnedMobs.add(spawned); return spawned; }
if (!entityType.isAlive() || !entityType.isSpawnable()) return false; if (CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(), new Acceptable<MobSelector.MobImpl>() { @Override if (entityType.isAlive() && entityType.isSpawnable()) commandSender.sendMessage("- " + entityType.name());
private final void spawnEntity(CityWorldGenerator generator, SupportBlocks blocks, Odds odds, int x, int y, int z, EntityType entity, boolean ignoreFlood, boolean ensureSpace) { if (blocks.insideXYZ(x, y, z) && entity != null && entity.isAlive()) {
return; if (!event.getEntityType().isAlive()) { return;