List of usage examples for org.apache.commons.lang WordUtils capitalize
public static String capitalize(String str)
Capitalizes all the whitespace separated words in a String.
From source file:uk.ac.ebi.phenotype.web.controller.ImagesController.java
private String humanizeStrings(String[] filterField, String queryTerms) { List<String> terms = new ArrayList<String>(); for (String filter : filterField) { // System.out.println("filterField="+filter); if (!filter.equals("annotationTermId:M*")) {// dont add M* to human // readable form terms.add(WordUtils.capitalize(filter.replaceAll(".*:", "").replaceAll("\"", ""))); }//from w w w. ja v a 2s. co m } queryTerms += ": " + StringUtils.join(terms, ", "); return queryTerms; }
From source file:uk.ac.kcl.iop.brc.core.pipeline.common.utils.StringTools.java
private static void loadSurnames() { InputStream resourceAsStream = StringTools.class.getClassLoader() .getResourceAsStream("anonymisation/lastnames"); try (BufferedReader br = new BufferedReader(new InputStreamReader(resourceAsStream))) { String line;/* w w w . j a v a 2 s . c om*/ while ((line = br.readLine()) != null) { lastNames.add(WordUtils.capitalize(line)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:uk.ac.kcl.iop.brc.core.pipeline.common.utils.StringTools.java
private static void loadFemaleNames() { InputStream resourceAsStream = StringTools.class.getClassLoader() .getResourceAsStream("anonymisation/femaleNames"); try (BufferedReader br = new BufferedReader(new InputStreamReader(resourceAsStream))) { String line;/*from w w w. j a v a2s . com*/ while ((line = br.readLine()) != null) { femaleNames.add(WordUtils.capitalize(line)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:uk.ac.kcl.iop.brc.core.pipeline.common.utils.StringTools.java
private static void loadMaleNames() { InputStream resourceAsStream = StringTools.class.getClassLoader() .getResourceAsStream("anonymisation/maleNames"); try (BufferedReader br = new BufferedReader(new InputStreamReader(resourceAsStream))) { String line;//from w w w . jav a 2s .c om while ((line = br.readLine()) != null) { maleNames.add(WordUtils.capitalize(line)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:wa.was.blastradius.managers.TNTEffectsManager.java
public void loadEffect(File effectFile) { if (!(effectFile.exists())) { return;// w w w .j a va 2 s.co m } YamlConfiguration effect = new YamlConfiguration(); Map<String, Object> effectInfo = new HashMap<String, Object>(); try { effect.load(effectFile); String effectName = effect.getString("effect-name", "DEFAULT").toUpperCase(); effectInfo.put("type", effectName); effectInfo.put("fuseTicks", effect.getInt("fuse-ticks", 80)); effectInfo.put("vaultCost", effect.getDouble("cost", 10.0)); if (Double.compare(effect.getDouble("worth", 10), 0.1) > 0) { effectInfo.put("vaultWorth", effect.getDouble("worth", 0.1)); } else { Bukkit.getServer().getLogger().warning("Vault Worth cannot be less than 0.1. Vault cost entered: " + effect.get("worth") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("vaultWorth", 0.1); } int tTexture = effect.getInt("tnt-texture-value", 1); int dTexture = effect.getInt("detonator-texture-value", 1); short ntTexture = tTexture > Short.MAX_VALUE ? Short.MAX_VALUE : tTexture < Short.MIN_VALUE ? Short.MIN_VALUE : (short) tTexture; short ndTexture = dTexture > Short.MAX_VALUE ? Short.MAX_VALUE : dTexture < Short.MIN_VALUE ? Short.MIN_VALUE : (short) dTexture; effectInfo.put("explosiveTexture", ntTexture); effectInfo.put("detonatorTexture", ndTexture); effectInfo.put("remoteDetonation", effect.getBoolean("remote-detonation", false)); if (Material.valueOf(effect.getString("remote-detonator-material", "STONE_BUTTON")) != null) { effectInfo.put("remoteDetonator", Material.valueOf(effect.getString("remote-detonator-material", "STONE_BUTTON"))); } else { Bukkit.getServer().getLogger() .warning("Remote Detonator Material Invalid: " + effect.get("remote-detonator-material") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("remoteDetonator", Material.STONE_BUTTON); } effectInfo.put("displayName", ChatColor.translateAlternateColorCodes('&', effect.getString("display-name", "TNT"))); String detonatorName = effect.getString("display-name", "TNT") + " " + effect.getString("remote-detonator-tag", "&6Detonator"); effectInfo.put("remoteDetonatorName", ChatColor.translateAlternateColorCodes('&', detonatorName)); remoteDetonators.put(ChatColor.translateAlternateColorCodes('&', detonatorName), effectName); if (Sound.valueOf(effect.getString("detonator-effect", "BLOCK_NOTE_PLING")) != null) { effectInfo.put("detonatorEffect", Sound.valueOf(effect.getString("detonator-effect", "BLOCK_NOTE_PLING"))); } else { Bukkit.getServer().getLogger().warning("Detonator Effect Invalid: " + effect.get("detonator-effect") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("detonatorEffect", Sound.BLOCK_NOTE_PLING); } double effectDetonatorPitch = effect.getDouble("detonaor-effect-pitch", 1.5); if (Double.compare(effectDetonatorPitch, 2.0) > 0) { Bukkit.getServer().getLogger().warning("Detonator Effect Pitch is too high: " + effectDetonatorPitch + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("detonatorEffectPitch", (float) 1.0); } else if (Double.compare(effectDetonatorPitch, 0.5) < 0) { Bukkit.getServer().getLogger().warning("Detonator Effect Pitch is too low: " + effectDetonatorPitch + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("detonatorEffectPitch", (float) 1.5); } else { effectInfo.put("detonatorEffectPitch", (float) effectDetonatorPitch); } double effectDetonatorVolume = effect.getDouble("detonator-effect-volume", 1.0); if (Double.compare(effectDetonatorVolume, 12.0) > 0) { Bukkit.getServer().getLogger().warning("Detonator Effect Volume is too high: " + effectDetonatorVolume + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("detontorEffectVolume", (float) 1.0); } else if (Double.compare(effectDetonatorVolume, 0.5) < 0) { Bukkit.getServer().getLogger().warning("Detonator Effect Volume is too high: " + effectDetonatorVolume + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("detonatorEffectVolume", (float) 1.0); } else { effectInfo.put("detonatorEffectVolume", (float) effectDetonatorVolume); } effectInfo.put("tntReceivable", effect.getBoolean("tnt-receivable", true)); displayNames.put(ChatColor.translateAlternateColorCodes('&', (String) effectInfo.get("displayName")), effectName); List<String> effectLore = effect.getStringList("lore"); List<String> lores = new ArrayList<String>(); if (effectLore.size() > 0) { for (String line : effectLore) { lores.add(ChatColor.translateAlternateColorCodes('&', line)); } effectInfo.put("lore", lores); } if (Sound.valueOf(effect.getString("fuse-effect", "ENTITY_TNT_PRIMED")) != null) { effectInfo.put("fuseEffect", Sound.valueOf(effect.getString("fuse-effect", "ENTITY_TNT_PRIMED"))); } else { Bukkit.getServer().getLogger().warning("Fuse Effect Invalid: " + effect.get("fuse-effect") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("fuseEffect", Sound.ENTITY_TNT_PRIMED); } double effectPitch = effect.getDouble("fuse-effect-pitch", 1.0); if (Double.compare(effectPitch, 2.0) > 0) { Bukkit.getServer().getLogger().warning("Fuse Effect Pitch is too high: " + effectPitch + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("fuseEffectPitch", (float) 1.0); } else if (Double.compare(effectPitch, 0.5) < 0) { Bukkit.getServer().getLogger().warning("Fuse Effect Pitch is too low: " + effectPitch + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("fuseEffectPitch", (float) 1.0); } else { effectInfo.put("fuseEffectPitch", (float) effectPitch); } double effectVolume = effect.getDouble("fuse-effect-volume", 1.0); if (Double.compare(effectVolume, 12.0) > 0) { Bukkit.getServer().getLogger().warning("Fuse Effect Volume is too high: " + effectVolume + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("fuseEffectVolume", (float) 1.0); } else if (Double.compare(effectVolume, 0.5) < 0) { Bukkit.getServer().getLogger().warning("Fuse Effect Volume is too high: " + effectVolume + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("fuseEffectVolume", (float) 1.0); } else { effectInfo.put("fuseEffectVolume", (float) effectVolume); } double explosionVolume = effect.getDouble("sound-explosion-volume", 2); if (Double.compare(explosionVolume, 12.0) > 0) { Bukkit.getServer().getLogger().warning("Sound Explosion volume is too high: " + explosionVolume + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("explosionVolume", (float) 2); } else { effectInfo.put("explosionVolume", (float) explosionVolume); } effectInfo.put("tamperProof", effect.getBoolean("tamper-proof", false)); effectInfo.put("doWaterDamage", effect.getBoolean("tnt-water-damage", false)); effectInfo.put("doFires", effect.getBoolean("blast-fires", true)); effectInfo.put("doSmoke", effect.getBoolean("blast-smoke", false)); effectInfo.put("obliterate", effect.getBoolean("obliterate-obliterables", false)); effectInfo.put("ellipsis", effect.getBoolean("elliptical-radius", true)); if (Double.compare(effect.getDouble("blast-yield-multiplier", 1F), 20.0) < 0) { effectInfo.put("yieldMultiplier", (float) effect.getDouble("blast-yield-multiplier", 1F)); } else { Bukkit.getServer().getLogger() .warning("Blast Multiplier out of Range: " + effect.get("blast-yield-multiplier") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("yieldMultiplier", (float) 1F); } if (effect.getInt("blast-radius", 10) <= 50) { effectInfo.put("blastRadius", effect.getInt("blast-radius", 10)); } else { Bukkit.getServer().getLogger().warning("Dead Zone out of Range: " + effect.get("blast-radius") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("blastRadius", (int) 10); } if (effect.getInt("fire-radius", 9) <= 50) { effectInfo.put("fireRadius", effect.getInt("fire-radius", 9)); } else { Bukkit.getServer().getLogger().warning("Fire Radius out of Range: " + effect.get("fire-radius") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("fireRadius", (int) 9); } if (effect.getInt("smoke-count", 10) <= 100) { effectInfo.put("smokeCount", effect.getInt("smoke-count", 10)); } else { Bukkit.getServer().getLogger().warning("Smoke Count out of Range: " + effect.get("smoke-count") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("smokeCount", (int) 10); } if (Double.compare(effect.getDouble("smoke-offset", 0.25), 10) < 0) { effectInfo.put("smokeOffset", effect.getDouble("smoke-offset", 0.25)); } else { Bukkit.getServer().getLogger().warning("Smoke Offset out of Range: " + effect.get("smoke-offset") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("smokeOffset", (double) 0.25); } effectInfo.put("tntTossable", effect.getBoolean("tnt-tossable", false)); if (effect.getInt("tnt-tossable-height", 3) < 256) { effectInfo.put("tossHeightGain", effect.getInt("tnt-tossed-height", 3)); } else { Bukkit.getServer().getLogger().warning("TNT Tossable Height gain out of Range: " + effect.get("tnt-tossable-height") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("tossHeightGain", (int) 3); } if (Double.compare(effect.getDouble("tnt-tossable-force", 1.5), 5.0) < 0) { effectInfo.put("tossForce", effect.getDouble("tnt-tossable-force", 1.5)); } else { Bukkit.getServer().getLogger().warning("TNT Force to Strong. Forced used: " + effect.get("tnt-tossable-force") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("tossForce", (double) 1.5); } if (effect.getInt("tnt-tossable-cooldown", 10) < 1) { Bukkit.getServer().getLogger() .warning("TNT Tossable Cooldown must be above 1. Value found: " + effect.get("tnt-tossable-cooldown") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("tossCooldown", (int) 10); } else { effectInfo.put("tossCooldown", effect.getInt("tnt-tossable-cooldown", 10)); } effectInfo.put("doCluster", effect.getBoolean("tnt-cluster-effect", false)); if (effect.getInt("tnt-cluster-effect-amount", 3) > 10) { Bukkit.getServer().getLogger() .warning("TNT Cluster Effect Amount must be between 1 - 10: " + effect.get("tnt-cluster-effect-amount") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("clusterAmount", (int) 3); } else { effectInfo.put("clusterAmount", effect.getInt("tnt-cluster-effect-amount", 3)); } effectInfo.put("clusterType", effect.getString("tnt-cluster-effect-type", "DEFAULT")); if (Double.compare(effect.getDouble("tnt-cluster-effect-height-offset", 10.0), 30.0) > 0) { Bukkit.getServer().getLogger() .warning("TNT Cluster Effect Amount must be between 1 - 10: " + effect.get("tnt-cluster-effect-amount") + " for TNT Effect: " + effectName + ". Defaulting..."); effectInfo.put("clusterOffset", (double) 10.0); } else { effectInfo.put("clusterOffset", effect.getDouble("tnt-cluster-effect-height-offset", 10.0)); } effectInfo.put("doPotions", effect.getBoolean("potion-effect", true)); effectInfo.put("consecPotions", effect.getBoolean("consecutive-potion-effects", false)); effectInfo.put("showPotionMsg", effect.getBoolean("show-potion-message", true)); effectInfo.put("potionMsg", effect.getString("potoin-message", "&1You have been &2effected &1with &c{TYPE} &1for &6{TIME} &rseconds")); List<PotionEffect> potionEffects = new ArrayList<PotionEffect>(); List<String> messages = new ArrayList<String>(); if (effect.getConfigurationSection("potion-effects").getKeys(false).size() > 0) { for (String type : effect.getConfigurationSection("potion-effects").getKeys(false)) { if (effectTypes .containsKey(effect.getString("potion-effects." + type + ".type").toUpperCase())) { if (effect.getString("potion-effects." + type + ".color") != null && colors.containsKey(effect.getString("potion-effects." + type + ".color"))) { potionEffects.add(new PotionEffect( effectTypes.get( effect.getString("potion-effects." + type + ".type").toUpperCase()), effect.getInt("potion-effects." + type + ".duration"), effect.getInt("potion-effects." + type + ".amplifier"), effect.getBoolean("potion-effects." + type + ".ambient"), effect.getBoolean("potion-effects." + type + ".particles"), colors.get(effect.getString("potion-effects." + type + ".color")))); } else { potionEffects.add(new PotionEffect( effectTypes.get( effect.getString("potion-effects." + type + ".type").toUpperCase()), effect.getInt("potion-effects." + type + ".duration"), effect.getInt("potion-effects." + type + ".amplifier"), effect.getBoolean("potion-effects." + type + ".ambient"), effect.getBoolean("potion-effects." + type + ".particles"))); } messages.add(effect .getString("potion-message", "&1You have been &2effected &1with &c{TYPE} &1for &6{TIME} &rseconds") .replace("{TYPE}", WordUtils.capitalize( effect.getString("potion-effects." + type + ".type").toLowerCase())) .replace("{TIME}", "" + (effect.getInt("potion-effects." + type + ".duration") / 20))); } } } potionEffectsManager.addMessages(effectName, messages); potionEffectsManager.addAllEffects(effectName, potionEffects); List<Material> innerMaterials = new ArrayList<Material>(); if (effect.getStringList("inner-blast-materials").size() > 0) { for (String mat : effect.getStringList("inner-blast-materials")) { if (Material.valueOf(mat) != null) { innerMaterials.add(Material.valueOf(mat)); } else { Bukkit.getServer().getLogger().warning("[BlastRadius] Invalid Inner Material: " + mat + " for TNT Effect: " + effectName + ". Skipping..."); } } } effectInfo.put("innerMaterials", innerMaterials); List<Material> outerMaterials = new ArrayList<Material>(); if (effect.getStringList("outer-blast-materials").size() > 0) { for (String mat : effect.getStringList("outer-blast-materials")) { if (Material.valueOf(mat) != null) { outerMaterials.add(Material.valueOf(mat)); } else { Bukkit.getServer().getLogger().warning("[BlastRadius] Invalid Outer Material: " + mat + " for TNT Effect: " + effectName + ". Skipping..."); } } } effectInfo.put("outerMaterials", outerMaterials); List<Material> protectedMaterials = new ArrayList<Material>(); if (effect.getStringList("protected-materials").size() > 0) { for (String mat : effect.getStringList("protected-materials")) { if (Material.valueOf(mat) != null) { protectedMaterials.add(Material.valueOf(mat)); } else { Bukkit.getServer().getLogger().warning("[BlastRadius] Invalid Protected Material: " + mat + " for TNT Effect: " + effectName + ". Skipping..."); } } } effectInfo.put("protectedMaterials", protectedMaterials); List<Material> obliterateMaterials = new ArrayList<Material>(); if (effect.getStringList("obliterate-materials").size() > 0) { for (String mat : effect.getStringList("obliterate-materials")) { if (Material.valueOf(mat) != null) { obliterateMaterials.add(Material.valueOf(mat)); } else { Bukkit.getServer().getLogger().warning("[BlastRadius] Invalid Obliterate Material: " + mat + " for TNT Effect: " + effectName + ". Skipping..."); } } } effectInfo.put("obliterateMaterials", obliterateMaterials); Bukkit.getServer().getLogger().warning("[BlastRadius] Added BlastR Brand TNT Effect: " + ConsoleColor.YELLOW + ConsoleColor.BOLD + effectName + ConsoleColor.RESET); effects.put(effectName, effectInfo); } catch (IOException | InvalidConfigurationException e) { e.printStackTrace(); } }