Java Code Examples for org.bukkit.enchantments.Enchantment#getName()

The following examples show how to use org.bukkit.enchantments.Enchantment#getName() . 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: Configuration.java    From NyaaUtils with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
public Configuration(NyaaUtils plugin) {
    this.plugin = plugin;
    this.mailbox = new MailboxLocations(plugin);
    this.repair = new RepairConfig(plugin);
    this.globalLoreBlacklist = new GlobalLoreBlacklist(plugin);
    this.enchantSrcConfig = new EnchantSrcConfig(plugin);
    this.fuelConfig = new FuelConfig(plugin);
    this.timerConfig = new TimerConfig(plugin);
    this.realmConfig = new RealmConfig(plugin);
    this.particleConfig = new ParticleConfig(plugin);
    //TODO: Key based enchantment store
    for (Enchantment e : Enchantment.values()) {
        if (e == null) {
            plugin.getLogger().warning("Bad enchantment: null");
        } else if (e.getName() == null) {
            plugin.getLogger().warning(String.format("Bad enchantment: %s: %s", e.getClass().getName(), e.toString()));
        } else {
            enchantMaxLevel.put(e, e.getMaxLevel());
        }
    }
}
 
Example 2
Source File: AdminResCommand.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
public void enchant_cmd() throws CivException {
	Player player = getPlayer();
	String enchant = getNamedString(1, "Enchant name");
	int level = getNamedInteger(2);
	
	
	ItemStack stack = player.getItemInHand();
	Enchantment ench = Enchantment.getByName(enchant);
	if (ench == null) {
		String out ="";
		for (Enchantment ench2 : Enchantment.values()) {
			out += ench2.getName()+",";
		}
		throw new CivException("No enchantment called "+enchant+" Options:"+out);
	}
	
	stack.addUnsafeEnchantment(ench, level);
	CivMessage.sendSuccess(sender, "Enchanted.");
}
 
Example 3
Source File: LoreGenerator.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
private static String getEnchantmentName(Enchantment enchantment) {

        if (!ConfigValues.itemsDropSettingsConfig.getKeys(true).contains(ItemsDropSettingsConfig.ENCHANTMENT_NAME + enchantment.getName())) {
            Bukkit.getLogger().warning("[EliteMobs] Missing enchantment name " + enchantment.getName());
            Bukkit.getLogger().warning("[EliteMobs] Report this to the dev!");
            return enchantment.getName();
        }

        return ConfigValues.itemsDropSettingsConfig.getString(ItemsDropSettingsConfig.ENCHANTMENT_NAME + enchantment.getName());

    }
 
Example 4
Source File: UMaterial.java    From TradePlus with GNU General Public License v3.0 5 votes vote down vote up
public static UMaterial matchEnchantedBook(ItemStack book) {
  if(book != null && book.getItemMeta() instanceof EnchantmentStorageMeta) {
    final EnchantmentStorageMeta m = (EnchantmentStorageMeta) book.getItemMeta();
    final Map<Enchantment, Integer> s = m.getStoredEnchants();
    if(s.size() == 1) {
      final Enchantment e = (Enchantment) s.keySet().toArray()[0];
      final int l = s.get(e);
      final String n = e.getName(), name =
                                        n.equals("PROTECTION_ENVIRONMENTAL") ? "PROTECTION"
                                            : n.equals("PROTECTION_FIRE") ? "FIRE_PROTECTION"
                                                  : n.equals("PROTECTION_FALL") ? "FEATHER_FALLING"
                                                        : n.equals("PROTECTION_EXPLOSIONS") ? "BLAST_PROTECTION"
                                                              : n.equals("PROTECTION_PROJECTILE") ? "PROJECTILE_PROTECTION"
                                                                    : n.equals("OXYGEN") ? "AQUA_AFFINITY"
                                                                          : n.equals("WATER_WORKER") ? "RESPIRATION"
                                                                                : n.equals("DAMAGE_ALL") ? "SHARPNESS"
                                                                                      : n.equals("DAMAGE_UNDEAD") ? "SMITE"
                                                                                            : n.equals("DAMAGE_ARTHROPODS") ? "BANE_OF_ARTHROPODS"
                                                                                                  : n.equals("LOOT_BONUS_MOBS") ? "LOOTING"
                                                                                                        : n.equals("SWEEPING_EDGE") ? "SWEEPING"
                                                                                                              : n.equals("DIG_SPEED") ? "EFFICIENCY"
                                                                                                                    : n.equals("DURABILITY") ? "UNBREAKING"
                                                                                                                          : n.equals("LOOT_BONUS_BLOCKS") ? "FORTUNE"
                                                                                                                                : n.equals("ARROW_DAMAGE") ? "POWER"
                                                                                                                                      : n.equals("ARROW_KNOCKBACK") ? "PUNCH"
                                                                                                                                            : n.equals("ARROW_FIRE") ? "FLAME"
                                                                                                                                                  : n.equals("ARROW_INFINITE") ? "INFINITY"
                                                                                                                                                        : n.equals("LUCK") ? "LUCK_OF_THE_SEA"
                                                                                                                                                              : n;
      return match("ENCHANTED_BOOK_" + (e.getMaxLevel() != 1 ? name + "_" + l : name));
    }
  }
  return null;
}
 
Example 5
Source File: VersionUtils_1_8.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String getEnchantmentKey(Enchantment enchantment){
    return enchantment.getName();
}
 
Example 6
Source File: VersionUtils_1_12.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String getEnchantmentKey(Enchantment enchantment){
    return enchantment.getName();
}
 
Example 7
Source File: ItemWorthCalculator.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
public static double enchantmentWorthGetter(Enchantment enchantment) {

        if (enchantment == null) return 0;

        String enchantmentName = enchantment.getName();

        switch (enchantmentName) {

            case "ARROW_DAMAGE":
                return configGetter(ARROW_DAMAGE);
            case "ARROW_FIRE":
                return configGetter(ARROW_FIRE);
            case "ARROW_INFINITE":
                return configGetter(ARROW_INFINITE);
            case "ARROW_KNOCKBACK":
                return configGetter(ARROW_KNOCKBACK);
            case "BINDING_CURSE":
                return configGetter(BINDING_CURSE);
            case "DAMAGE_ALL":
                return configGetter(DAMAGE_ALL);
            case "DAMAGE_ARTHROPODS":
                return configGetter(DAMAGE_ARTHROPODS);
            case "DAMAGE_UNDEAD":
                return configGetter(DAMAGE_UNDEAD);
            case "DEPTH_STRIDER":
                return configGetter(DEPTH_STRIDER);
            case "DIG_SPEED":
                return configGetter(DIG_SPEED);
            case "DURABILITY":
                return configGetter(DURABILITY);
            case "FIRE_ASPECT":
                return configGetter(FIRE_ASPECT);
            case "FROST_WALKER":
                return configGetter(FROST_WALKER);
            case "KNOCKBACK":
                return configGetter(KNOCKBACK);
            case "LOOT_BONUS_BLOCKS":
                return configGetter(LOOT_BONUS_BLOCKS);
            case "LOOT_BONUS_MOBS":
                return configGetter(LOOT_BONUS_MOBS);
            case "LUCK":
                return configGetter(LUCK_ENCHANTMENT);
            case "LURE":
                return configGetter(LURE);
            case "MENDING":
                return configGetter(MENDING);
            case "OXYGEN":
                return configGetter(OXYGEN);
            case "PROTECTION_ENVIRONMENTAL":
                return configGetter(PROTECTION_ENVIRONMENTAL);
            case "PROTECTION_EXPLOSIONS":
                return configGetter(PROTECTION_EXPLOSIONS);
            case "PROTECTION_FALL":
                return configGetter(PROTECTION_FALL);
            case "PROTECTION_PROJECTILE":
                return configGetter(PROTECTION_PROJECTILE);
            case "PROTECTION_FIRE":
                return configGetter(PROTECTION_FIRE);
            case "SILK_TOUCH":
                return configGetter(SILK_TOUCH);
            case "SWEEPING_EDGE":
                return configGetter(SWEEPING_EDGE);
            case "THORNS":
                return configGetter(THORNS);
            case "VANISHING_CURSE":
                return configGetter(VANISHING_CURSE);
            case "WATER_WORKER":
                return configGetter(WATER_WORKER);
            default:
                return 0;
        }

    }
 
Example 8
Source File: UMaterial.java    From TradePlus with GNU General Public License v3.0 4 votes vote down vote up
UMaterial(String name, Enchantment enchant, int level) {
  names[0] = name;
  versionName = name;
  data = 0;
  attributes = "enchant=" + (Sounds.version < 114 ? enchant.getName() : ItemUtils1_14.getName(enchant)) + ":" + level;
}
 
Example 9
Source File: LanguageHelper.java    From LanguageUtils with MIT License 2 votes vote down vote up
/**
 * Return the unlocalized name of the enchantment(Minecraft convention)
 *
 * @param enchantment The enchantment
 * @return The unlocalized name.
 */
public static String getEnchantmentUnlocalizedName(Enchantment enchantment) {
    EnumEnchantment enumEnch = EnumEnchantment.get(enchantment);
    return (enumEnch != null ? enumEnch.getUnlocalizedName() : enchantment.getName());
}