/** * Attempts to load a mod from an input stream. This will parse the manifest * file. * * @param file the file * @param manifest the manifest instance * @return the manifest mod container */ private ManifestModInfo loadMod(File file, Manifest manifest) { ManifestModInfo container = ManifestModInfo.create(file, manifest); if (container == null) { log.error("Found invalid manifest in file " + file); return null; } log.info("Found mod " + container.getName() + " with id " + container.getModID()); if (container.getModID().isEmpty()) { throw new RuntimeException("Empty mod ID for mod '" + container.getName() + "'!"); } for (char c : container.getModID().toCharArray()) { if (c != '-' && c != '_' && !CharSet.ASCII_ALPHA_LOWER.contains(c) && !CharSet.ASCII_NUMERIC.contains(c)) { throw new RuntimeException("Illegal characters in ID '" + container.getModID() + "' for mod '" + container.getName() + "'."); } } if (container.getModID().equals("oml")) { throw new RuntimeException("'oml' is a reserved mod id!"); } if (container.getName() == null || container.getName().isEmpty()) { throw new RuntimeException("The mod must set a non-empty name!"); } container.getVersion(); if (!container.getMinecraftVersion().equals(OpenModLoader.getMinecraftVersion())) { log.warn("Mod '%s' is expecting Minecraft %s, but we are running on Minecraft %s!", container.getName(), container.getMinecraftVersion(), OpenModLoader.getMinecraftVersion()); } if (container.getSide() != Side.UNIVERSAL && container.getSide() != OMLStrippableTransformer.getSide()) { log.info("Invalid side %s for mod %s. The mod will not be loaded.", OMLStrippableTransformer.getSide(), container.getName()); } return container; }
@Test public void charSetDemo() { System.out.println("**CharSetDemo**"); CharSet charSet = CharSet.getInstance("aeiou"); String demoStr = "The quick brown fox jumps over the lazy dog."; int count = 0; for (int i = 0, len = demoStr.length(); i < len; i++) { if (charSet.contains(demoStr.charAt(i))) { count++; } } System.out.println("count: " + count); }