Java Code Examples for org.bukkit.potion.PotionEffectType#values()

The following examples show how to use org.bukkit.potion.PotionEffectType#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MsgUtil.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
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.");
}
 
Example 2
Source File: PotionEffectUtils.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
private static int getMaxPotionId() {
	int i = 0;
	for (final PotionEffectType t : PotionEffectType.values()) {
		if (t != null && t.getId() > i)
			i = t.getId();
	}
	return i;
}
 
Example 3
Source File: PotionEffectUtils.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@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);
		}
	}
}
 
Example 4
Source File: PotionEffectApplier.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
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;

    }