Skip to content

Commit

Permalink
Fix bug with enchantment api
Browse files Browse the repository at this point in the history
  • Loading branch information
Trophonix committed May 22, 2020
1 parent 55882c9 commit 35f7c2a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<properties>
<res>${project.basedir}/res/</res>
<revision>3.68.3</revision>
<revision>3.68.4</revision>
</properties>

<repositories>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/trophonix/tradeplus/TradePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void onEnable() {
InvUtils.reloadItems(this);
typeEmpty =
ChatColor.translateAlternateColorCodes(
'&', config.getString("extras.type.empty"));
'&', config.getString("extras.type.empty", "&eHow much %EXTRA% to offer?"));
typeValid =
ChatColor.translateAlternateColorCodes(
'&', config.getString("extras.type.valid"));
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/trophonix/tradeplus/util/ItemUtils1_14.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.trophonix.tradeplus.util;

import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

Expand All @@ -13,4 +15,13 @@ public static int getCustomModelData(ItemStack stack) {
public static void applyCustomModelData(ItemMeta meta, int customModelData) {
meta.setCustomModelData(customModelData);
}

public static String getName(Enchantment enchantment) {
return enchantment.getKey().getKey();
}

public static Enchantment getEnchantment(String key) {
return Enchantment.getByKey(NamespacedKey.minecraft(key));
}

}
4 changes: 2 additions & 2 deletions src/main/java/com/trophonix/tradeplus/util/UMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ public enum UMaterial implements Versionable {
names[0] = name;
versionName = name;
data = 0;
attributes = "enchant=" + enchant.getName() + ":" + level;
attributes = "enchant=" + (Sounds.version < 114 ? enchant.getName() : ItemUtils1_14.getName(enchant)) + ":" + level;
}
UMaterial(int data, String ...names) {
this.names = names;
Expand All @@ -1434,7 +1434,7 @@ public ItemStack getItemStack() {
} else if(s.startsWith("enchant=")) {
final String[] e = s.split("=")[1].split(":");
final EnchantmentStorageMeta sm = (EnchantmentStorageMeta) is.getItemMeta();
sm.addStoredEnchant(Enchantment.getByName(e[0]), Integer.parseInt(e[1]), true);
sm.addStoredEnchant(Sounds.version < 114 ? Enchantment.getByName(e[0]) : ItemUtils1_14.getEnchantment(e[0]), Integer.parseInt(e[1]), true);
is.setItemMeta(sm);
} else if(s.startsWith("upotion=")) {
final String[] p = s.split("=")[1].split(":");
Expand Down

0 comments on commit 35f7c2a

Please sign in to comment.