下面列出了org.bukkit.potion.PotionEffectType#values ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void loadPotioni18n() {
plugin.getLogger().info("Starting loading potions translation...");
File potioni18nFile = new File(plugin.getDataFolder(), "potioni18n.yml");
if (!potioni18nFile.exists()) {
plugin.getLogger().info("Creating potioni18n.yml");
plugin.saveResource("potioni18n.yml", false);
}
// Store it
potioni18n = YamlConfiguration.loadConfiguration(potioni18nFile);
potioni18n.options().copyDefaults(false);
YamlConfiguration potioni18nYAML =
YamlConfiguration.loadConfiguration(
new InputStreamReader(Objects.requireNonNull(plugin.getResource("potioni18n.yml"))));
potioni18n.setDefaults(potioni18nYAML);
Util.parseColours(potioni18n);
for (PotionEffectType potion : PotionEffectType.values()) {
String potionI18n = potioni18n.getString("potioni18n." + potion.getName().trim());
if (potionI18n != null && !potionI18n.isEmpty()) {
continue;
}
String potionName = gameLanguage.getPotion(potion);
plugin.getLogger().info("Found new potion [" + potionName + "] , adding it to the config...");
potioni18n.set("potioni18n." + potion.getName(), potionName);
}
try {
potioni18n.save(potioni18nFile);
} catch (IOException e) {
e.printStackTrace();
plugin
.getLogger()
.log(
Level.WARNING,
"Could not load/save transaction potionname from potioni18n.yml. Skipping.");
}
plugin.getLogger().info("Complete to load potions effect translation.");
}
private static int getMaxPotionId() {
int i = 0;
for (final PotionEffectType t : PotionEffectType.values()) {
if (t != null && t.getId() > i)
i = t.getId();
}
return i;
}
@Override
public void onLanguageChange() {
types.clear();
for (final PotionEffectType t : PotionEffectType.values()) {
if (t == null)
continue;
final String[] ls = Language.getList("potions." + t.getName());
names[t.getId()] = ls[0];
for (final String l : ls) {
types.put(l.toLowerCase(), t);
}
}
}
public List<String> loreDeobfuscator(ItemStack itemStack) {
List<String> lore = itemStack.getItemMeta().getLore();
List<String> deobfuscatedPotionEffect = new ArrayList<>();
if (lore.isEmpty()) return deobfuscatedPotionEffect;
String deobfuscatedString = lore.get(0).replace("§", "");
if (!deobfuscatedString.contains(LoreGenerator.OBFUSCATED_POTIONS)) return deobfuscatedPotionEffect;
for (PotionEffectType potionEffectType : PotionEffectType.values())
if (potionEffectType != null)
for (String spaceSeparation : deobfuscatedString.split(",")) {
//individual potion effects are separated at this level
List<String> amplifierSeparation = Arrays.asList(spaceSeparation.split(":"));
if (amplifierSeparation.size() > 1 && amplifierSeparation.get(0).equals(potionEffectType.getName()))
deobfuscatedPotionEffect.add(spaceSeparation);
}
return deobfuscatedPotionEffect;
}