/** * Change the type of mob being hatched by the egg * * @param hatchType The type of the mob being hatched by the egg */ public void setHatchingType(EntityType hatchType) { if(!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!"); this.hatchType = hatchType; }
} else if (entityType != null && (!entityType.isSpawnable() && !Summonable.class .isAssignableFrom(EntityRegistry.getEntity(entityType)))) { if (sender != null) {
/** * Change the type of mob being hatched by the egg * * @param hatchType The type of the mob being hatched by the egg */ public void setHatchingType(EntityType hatchType) { if(!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!"); this.hatchType = hatchType; }
/** * Get a list of creature names. * * @param requireSpawnable Whether to only show entries that are spawnable * @return */ public static String getCreatureNameList(boolean requireSpawnable) { StringBuilder str = new StringBuilder(); for (EntityType type : EntityType.values()) { Class<?> entityClass = type.getEntityClass(); if (entityClass == null) { continue; } if (!LivingEntity.class.isAssignableFrom(entityClass)) { continue; } if (!requireSpawnable || type.isSpawnable()) { if (str.length() > 0) { str.append(", "); } str.append(type.getName()); } } return str.toString(); } }
@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());
if (clazz == null) continue; if (!LivingEntity.class.isAssignableFrom(clazz)) continue; if (requireSpawnable && !type.isSpawnable()) continue; || (type.getName() != null && type.getName() .equalsIgnoreCase(filter)) && (type.isSpawnable() || !requireSpawnable)) { return type;
for (EntityType entityType : types) if (entityType.isSpawnable())
/** * 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())
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());