diff --git a/pom.xml b/pom.xml
index e712b78..fd55f71 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
me.puyodead1
RPBookGUI
- 2.9.8-h1
+ 2.9.8-rc2
RPBookGUI
diff --git a/src/main/java/io/github/puyodead1/rpbookgui/Commands/RarityInfo.java b/src/main/java/io/github/puyodead1/rpbookgui/Commands/RarityInfo.java
index 7e60361..6064d55 100644
--- a/src/main/java/io/github/puyodead1/rpbookgui/Commands/RarityInfo.java
+++ b/src/main/java/io/github/puyodead1/rpbookgui/Commands/RarityInfo.java
@@ -25,7 +25,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
|| !rpbgConfig.getBoolean("settings.use permissions")) {
String arg = args[0];
arg = arg.substring(0, 1).toUpperCase() + arg.substring(1, arg.length()).toLowerCase();
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(arg);
+ CustomEnchant ce = RPStorage.valueOfCustomEnchant(arg, true);
EnchantRarity rarity = RPStorage.valueOfEnchantRarity(ce);
player.sendMessage(rarity != null
? RPBookGUIUtils
diff --git a/src/main/java/io/github/puyodead1/rpbookgui/Events/InventoryClick.java b/src/main/java/io/github/puyodead1/rpbookgui/Events/InventoryClick.java
index 7a95a6b..e6f736d 100644
--- a/src/main/java/io/github/puyodead1/rpbookgui/Events/InventoryClick.java
+++ b/src/main/java/io/github/puyodead1/rpbookgui/Events/InventoryClick.java
@@ -28,7 +28,8 @@ public class InventoryClick implements Listener {
@EventHandler
public void InventoryClickEvent(InventoryClickEvent e) {
- if (!e.isCancelled() && e.getCurrentItem() != null && !e.getCurrentItem().getType().equals(Material.AIR)
+ if (!e.isCancelled() && e.getCurrentItem() != null
+ && !e.getCurrentItem().getType().equals(Material.AIR)
&& e.getClickedInventory() != null && e.getCursor() != null
&& !e.getClick().equals(ClickType.DOUBLE_CLICK)) {
ItemStack ci = e.getCurrentItem();
@@ -42,31 +43,38 @@ public void InventoryClickEvent(InventoryClickEvent e) {
e.setCancelled(true);
if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.SimpleCategoryItem().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.SimpleCategoryItem().clone()
+ .getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.SimpleEnchants());
} else if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.UniqueCategoryItem().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.UniqueCategoryItem().clone()
+ .getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.UniqueEnchants());
} else if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.EliteCategoryItem().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.EliteCategoryItem().clone()
+ .getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.EliteEnchants());
} else if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.UltimateCategoryItem().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.UltimateCategoryItem().clone()
+ .getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.UltimateEnchants());
} else if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.LegendaryCategoryItem().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.LegendaryCategoryItem().clone()
+ .getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.LegendaryEnchants());
} else if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.SoulCategoryItem().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.SoulCategoryItem().clone()
+ .getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.SoulEnchants());
} else if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.HeroicCategoryItem().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.HeroicCategoryItem().clone()
+ .getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.HeroicEnchants());
}
@@ -77,20 +85,26 @@ public void InventoryClickEvent(InventoryClickEvent e) {
if (invTitle.equals("RPBookGUI Settings")) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back().clone().getItemMeta().getDisplayName()))
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName()))
player.getOpenInventory().close();
if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.KeepMenuOpenSetting().clone().getItemMeta().getDisplayName())) {
+ .equals(ItemStacks.KeepMenuOpenSetting().clone()
+ .getItemMeta().getDisplayName())) {
RPBookGUI.getPlugin.getConfig().set("settings.keepinvopen",
- !RPBookGUI.getPlugin.getConfig().getBoolean("settings.keepinvopen"));
+ !RPBookGUI.getPlugin.getConfig()
+ .getBoolean("settings.keepinvopen"));
player.getOpenInventory().close();
player.openInventory(Inventories.Settings());
}
if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.UsePermissionsSetting().clone().getItemMeta().getDisplayName())) {
- RPBookGUI.getPlugin.getConfig().set("settings.usepermissions",
- !RPBookGUI.getPlugin.getConfig().getBoolean("settings.usepermissions"));
+ .equals(ItemStacks.UsePermissionsSetting().clone()
+ .getItemMeta().getDisplayName())) {
+ RPBookGUI.getPlugin.getConfig().set(
+ "settings.usepermissions",
+ !RPBookGUI.getPlugin.getConfig()
+ .getBoolean("settings.usepermissions"));
player.getOpenInventory().close();
player.openInventory(Inventories.Settings());
@@ -100,16 +114,21 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Heroic inv click
*/
- if (invTitle.equals(RPBookGUIUtils.ChatColor("&d&lHeroic Enchantments"))) {
+ if (invTitle.equals(
+ RPBookGUIUtils.ChatColor("&d&lHeroic Enchantments"))) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().clone().getItemMeta().getDisplayName())) {
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.MainGUI());
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(
- ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
+ CustomEnchant ce = RPStorage
+ .valueOfCustomEnchant(
+ ChatColor.stripColor(e.getCurrentItem()
+ .getItemMeta().getDisplayName()),
+ true);
player.getOpenInventory().close();
player.openInventory(Inventories.Enchant(ce));
}
@@ -118,16 +137,21 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* soul inv click
*/
- if (invTitle.equals(RPBookGUIUtils.ChatColor("&c&lSoul Enchantments"))) {
+ if (invTitle.equals(
+ RPBookGUIUtils.ChatColor("&c&lSoul Enchantments"))) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().clone().getItemMeta().getDisplayName())) {
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.MainGUI());
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(
- ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
+ CustomEnchant ce = RPStorage
+ .valueOfCustomEnchant(
+ ChatColor.stripColor(e.getCurrentItem()
+ .getItemMeta().getDisplayName()),
+ true);
player.getOpenInventory().close();
player.openInventory(Inventories.Enchant(ce));
}
@@ -135,16 +159,21 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Legendary inv click
*/
- if (invTitle.equals(RPBookGUIUtils.ChatColor("&6&lLegendary Enchantments"))) {
+ if (invTitle.equals(
+ RPBookGUIUtils.ChatColor("&6&lLegendary Enchantments"))) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().clone().getItemMeta().getDisplayName())) {
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.MainGUI());
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(
- ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
+ CustomEnchant ce = RPStorage
+ .valueOfCustomEnchant(
+ ChatColor.stripColor(e.getCurrentItem()
+ .getItemMeta().getDisplayName()),
+ true);
player.getOpenInventory().close();
player.openInventory(Inventories.Enchant(ce));
}
@@ -153,16 +182,21 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Ultimate inv click
*/
- if (invTitle.equals(RPBookGUIUtils.ChatColor("&e&lUltimate Enchantments"))) {
+ if (invTitle.equals(
+ RPBookGUIUtils.ChatColor("&e&lUltimate Enchantments"))) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().clone().getItemMeta().getDisplayName())) {
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.MainGUI());
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(
- ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
+ CustomEnchant ce = RPStorage
+ .valueOfCustomEnchant(
+ ChatColor.stripColor(e.getCurrentItem()
+ .getItemMeta().getDisplayName()),
+ true);
player.getOpenInventory().close();
player.openInventory(Inventories.Enchant(ce));
}
@@ -170,16 +204,21 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Elite inv click
*/
- if (invTitle.equals(RPBookGUIUtils.ChatColor("&b&lElite Enchantments"))) {
+ if (invTitle.equals(
+ RPBookGUIUtils.ChatColor("&b&lElite Enchantments"))) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().clone().getItemMeta().getDisplayName())) {
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.MainGUI());
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(
- ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
+ CustomEnchant ce = RPStorage
+ .valueOfCustomEnchant(
+ ChatColor.stripColor(e.getCurrentItem()
+ .getItemMeta().getDisplayName()),
+ true);
player.getOpenInventory().close();
player.openInventory(Inventories.Enchant(ce));
}
@@ -188,16 +227,21 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Unique inv click
*/
- if (invTitle.equals(RPBookGUIUtils.ChatColor("&a&lUnique Enchantments"))) {
+ if (invTitle.equals(
+ RPBookGUIUtils.ChatColor("&a&lUnique Enchantments"))) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().clone().getItemMeta().getDisplayName())) {
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.MainGUI());
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(
- ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
+ CustomEnchant ce = RPStorage
+ .valueOfCustomEnchant(
+ ChatColor.stripColor(e.getCurrentItem()
+ .getItemMeta().getDisplayName()),
+ true);
player.getOpenInventory().close();
player.openInventory(Inventories.Enchant(ce));
}
@@ -205,16 +249,19 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Simple inv click
*/
- if (invTitle.equals(RPBookGUIUtils.ChatColor("&7&lSimple Enchantments"))) {
+ if (invTitle.equals(
+ RPBookGUIUtils.ChatColor("&7&lSimple Enchantments"))) {
e.setCancelled(true);
- if (ci.getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().clone().getItemMeta().getDisplayName())) {
+ if (ci.getItemMeta().getDisplayName().equals(ItemStacks.Back()
+ .clone().getItemMeta().getDisplayName())) {
player.getOpenInventory().close();
player.openInventory(Inventories.MainGUI());
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = RPStorage
- .valueOfCustomEnchant(RPBookGUIUtils.FormatEnchantName(e.getCurrentItem()));
+ .valueOfCustomEnchant(RPBookGUIUtils
+ .FormatEnchantName(e.getCurrentItem()));
player.getOpenInventory().close();
player.openInventory(Inventories.Enchant(ce));
}
@@ -223,58 +270,70 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Enchant inv click
*/
- CustomEnchant enchant = RPStorage.valueOfCustomEnchant(invTitle);
+ CustomEnchant enchant = RPStorage.valueOfCustomEnchant(invTitle,
+ true);
if (enchant != null) {
e.setCancelled(true);
- if (e.getCurrentItem().getItemMeta().getDisplayName()
- .equals(ItemStacks.Back().getItemMeta().getDisplayName())
- && e.getCurrentItem().getType().equals(ItemStacks.Back().clone().clone().getType())) {
+ if (e.getCurrentItem().getItemMeta().getDisplayName().equals(
+ ItemStacks.Back().getItemMeta().getDisplayName())
+ && e.getCurrentItem().getType().equals(
+ ItemStacks.Back().clone().clone().getType())) {
player.getOpenInventory().close();
- switch (RPStorage.valueOfEnchantRarity(enchant).getIdentifier()) {
- case "SIMPLE":
- player.openInventory(Inventories.SimpleEnchants());
- break;
- case "UNIQUE":
- player.openInventory(Inventories.UniqueEnchants());
- break;
- case "ELITE":
- player.openInventory(Inventories.EliteEnchants());
- break;
- case "ULTIMATE":
- player.openInventory(Inventories.UltimateEnchants());
- break;
- case "LEGENDARY":
- player.openInventory(Inventories.LegendaryEnchants());
- break;
- case "SOUL":
- player.openInventory(Inventories.SoulEnchants());
- break;
- case "HEROIC":
- player.openInventory(Inventories.HeroicEnchants());
- break;
+ switch (RPStorage.valueOfEnchantRarity(enchant)
+ .getIdentifier()) {
+ case "SIMPLE" :
+ player.openInventory(Inventories.SimpleEnchants());
+ break;
+ case "UNIQUE" :
+ player.openInventory(Inventories.UniqueEnchants());
+ break;
+ case "ELITE" :
+ player.openInventory(Inventories.EliteEnchants());
+ break;
+ case "ULTIMATE" :
+ player.openInventory(
+ Inventories.UltimateEnchants());
+ break;
+ case "LEGENDARY" :
+ player.openInventory(
+ Inventories.LegendaryEnchants());
+ break;
+ case "SOUL" :
+ player.openInventory(Inventories.SoulEnchants());
+ break;
+ case "HEROIC" :
+ player.openInventory(Inventories.HeroicEnchants());
+ break;
}
}
- if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
+
+ if (e.getCurrentItem().getType()
+ .equals(UMaterial.match("BOOK").getMaterial())) {
e.setCancelled(true);
- if (RPBookGUI.getPlugin.getConfig().getBoolean("settings.try to apply to item in hand")
- && RPBookGUIUtils.isOnCorrectItem(enchant, player.getItemInHand())) {
+ if (RPBookGUI.getPlugin.getConfig()
+ .getBoolean("settings.try to apply to item in hand")
+ && RPBookGUIUtils.isOnCorrectItem(enchant,
+ player.getItemInHand())) {
CustomEnchant ce = RPStorage.valueOfCustomEnchant(ci);
- EnchantRarity rarity = RPStorage.valueOfEnchantRarity(ce);
+ EnchantRarity rarity = RPStorage
+ .valueOfEnchantRarity(ce);
ItemStack o = player.getInventory().getItemInMainHand();
ItemMeta m = o.getItemMeta();
if (m.getLore() == null) {
ArrayList lores = new ArrayList();
- lores.add(
- rarity.getApplyColors() + ChatColor.stripColor(ci.getItemMeta().getDisplayName()));
+ lores.add(rarity.getApplyColors()
+ + ChatColor.stripColor(
+ ci.getItemMeta().getDisplayName()));
m.setLore(lores);
} else {
ArrayList lores = new ArrayList();
lores.addAll(m.getLore());
- lores.add(
- rarity.getApplyColors() + ChatColor.stripColor(ci.getItemMeta().getDisplayName()));
+ lores.add(rarity.getApplyColors()
+ + ChatColor.stripColor(
+ ci.getItemMeta().getDisplayName()));
m.setLore(lores);
}
@@ -282,27 +341,42 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.updateInventory();
player.sendMessage(RPBookGUIUtils
- .ChatColor(RPBookGUI.getPlugin.getConfig().getString("messages.added enchant")
- .replace("{NAME}", ci.getItemMeta().getDisplayName())
- .replace("{ITEM}", player.getItemInHand().getType().name())));
+ .ChatColor(RPBookGUI.getPlugin.getConfig()
+ .getString("messages.added enchant")
+ .replace("{NAME}",
+ ci.getItemMeta()
+ .getDisplayName())
+ .replace("{ITEM}",
+ player.getItemInHand().getType()
+ .name())));
} else {
- for (EnchantConstructor ec : EnchantConstructor.getEnchants().values()) {
- if (!ChatColor.stripColor(ec.getRevealItem().getItemMeta().getDisplayName())
- .equals(ChatColor.stripColor(ci.getItemMeta().getDisplayName()))) {
- EnchantConstructor.getEnchants().remove(ec.getCustomEnchant().getIdentifier());
+ for (EnchantConstructor ec : EnchantConstructor
+ .getEnchants().values()) {
+ if (!ChatColor
+ .stripColor(ec.getRevealItem().getItemMeta()
+ .getDisplayName())
+ .equals(ChatColor.stripColor(ci
+ .getItemMeta().getDisplayName()))) {
+ EnchantConstructor.getEnchants().remove(
+ ec.getCustomEnchant().getIdentifier());
}
}
- if (RPBookGUI.getPlugin.getConfig().getBoolean("settings.use success destroy configuration")) {
+ if (RPBookGUI.getPlugin.getConfig().getBoolean(
+ "settings.use success destroy configuration")) {
player.getOpenInventory().close();
- player.openInventory(Inventories.SuccessDestroySelection(ci));
+ player.openInventory(
+ Inventories.SuccessDestroySelection(ci));
} else {
player.getInventory().addItem(ci);
- if (!RPBookGUI.getPlugin.getConfig().getBoolean("settings.keep inventory open"))
+ if (!RPBookGUI.getPlugin.getConfig()
+ .getBoolean("settings.keep inventory open"))
player.getOpenInventory().close();
player.sendMessage(RPBookGUIUtils
- .ChatColor(RPBookGUI.getPlugin.getConfig().getString("messages.added book")
- .replace("{NAME}", ci.getItemMeta().getDisplayName())));
+ .ChatColor(RPBookGUI.getPlugin.getConfig()
+ .getString("messages.added book")
+ .replace("{NAME}", ci.getItemMeta()
+ .getDisplayName())));
}
}
}
@@ -315,51 +389,84 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.getOpenInventory().close();
} else {
// TODO: prevent negatives
- String incrementType = ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName())
+ String incrementType = ChatColor.stripColor(
+ e.getCurrentItem().getItemMeta().getDisplayName())
.substring(0, 1);
- String[] split = ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName())
+ String[] split = ChatColor.stripColor(
+ e.getCurrentItem().getItemMeta().getDisplayName())
.substring(1).split(" ");
int amount = Integer.parseInt(split[0]);
String type = split[1].toLowerCase();
-
+
int currentSuccess = Integer.parseInt(ChatColor
- .stripColor(e.getInventory().getItem(22).getItemMeta().getLore().get(0)).split("%")[0]);
+ .stripColor(e.getInventory().getItem(22)
+ .getItemMeta().getLore().get(0))
+ .split("%")[0]);
int currentDestroy = Integer.parseInt(ChatColor
- .stripColor(e.getInventory().getItem(22).getItemMeta().getLore().get(1)).split("%")[0]);
+ .stripColor(e.getInventory().getItem(22)
+ .getItemMeta().getLore().get(1))
+ .split("%")[0]);
- Entry entry = EnchantConstructor.getEnchants().entrySet().iterator()
- .next();
- CustomEnchant ce = RPStorage.valueOfCustomEnchant(entry.getKey());
+ Entry entry = EnchantConstructor
+ .getEnchants().entrySet().iterator().next();
+ CustomEnchant ce = RPStorage
+ .valueOfCustomEnchant(entry.getKey(), true);
if (type.equals("success")) {
if (incrementType.equals("+")) {
final int newAmount = (currentSuccess + amount);
- ItemStack eb = CustomEnchants.getCustomEnchants().getRevealedItem(ce,
- EnchantConstructor.getEnchants().get(ce.getIdentifier()).getEnchantLevel(),
- newAmount > 0 && newAmount <= 100 ? newAmount : currentSuccess, currentDestroy, true, true);
+ ItemStack eb = CustomEnchants.getCustomEnchants()
+ .getRevealedItem(ce,
+ EnchantConstructor.getEnchants()
+ .get(ce.getIdentifier())
+ .getEnchantLevel(),
+ newAmount > 0 && newAmount <= 100
+ ? newAmount
+ : currentSuccess,
+ currentDestroy, true, true);
e.getInventory().setItem(22, eb);
player.updateInventory();
} else if (incrementType.equals("-")) {
final int newAmount = (currentSuccess - amount);
- ItemStack eb = CustomEnchants.getCustomEnchants().getRevealedItem(ce,
- EnchantConstructor.getEnchants().get(ce.getIdentifier()).getEnchantLevel(),
- newAmount > 0 && newAmount <= 100 ? newAmount : currentSuccess, currentDestroy, true, true);
+ ItemStack eb = CustomEnchants.getCustomEnchants()
+ .getRevealedItem(ce,
+ EnchantConstructor.getEnchants()
+ .get(ce.getIdentifier())
+ .getEnchantLevel(),
+ newAmount > 0 && newAmount <= 100
+ ? newAmount
+ : currentSuccess,
+ currentDestroy, true, true);
e.getInventory().setItem(22, eb);
player.updateInventory();
}
} else if (type.equals("destroy")) {
if (incrementType.equals("+")) {
final int newAmount = (currentDestroy + amount);
- ItemStack eb = CustomEnchants.getCustomEnchants().getRevealedItem(ce,
- EnchantConstructor.getEnchants().get(ce.getIdentifier()).getEnchantLevel(),
- currentSuccess, newAmount > 0 && newAmount <= 100 ? newAmount : currentDestroy, true, true);
+ ItemStack eb = CustomEnchants.getCustomEnchants()
+ .getRevealedItem(ce,
+ EnchantConstructor.getEnchants()
+ .get(ce.getIdentifier())
+ .getEnchantLevel(),
+ currentSuccess,
+ newAmount > 0 && newAmount <= 100
+ ? newAmount
+ : currentDestroy,
+ true, true);
e.getInventory().setItem(22, eb);
player.updateInventory();
} else if (incrementType.equals("-")) {
final int newAmount = (currentDestroy - amount);
- ItemStack eb = CustomEnchants.getCustomEnchants().getRevealedItem(ce,
- EnchantConstructor.getEnchants().get(ce.getIdentifier()).getEnchantLevel(),
- currentSuccess, newAmount > 0 && newAmount <= 100 ? newAmount : currentDestroy, true, true);
+ ItemStack eb = CustomEnchants.getCustomEnchants()
+ .getRevealedItem(ce,
+ EnchantConstructor.getEnchants()
+ .get(ce.getIdentifier())
+ .getEnchantLevel(),
+ currentSuccess,
+ newAmount > 0 && newAmount <= 100
+ ? newAmount
+ : currentDestroy,
+ true, true);
e.getInventory().setItem(22, eb);
player.updateInventory();
}
diff --git a/src/main/java/io/github/puyodead1/rpbookgui/Utils/RPBookGUIUtils.java b/src/main/java/io/github/puyodead1/rpbookgui/Utils/RPBookGUIUtils.java
index d2c9354..388caf9 100644
--- a/src/main/java/io/github/puyodead1/rpbookgui/Utils/RPBookGUIUtils.java
+++ b/src/main/java/io/github/puyodead1/rpbookgui/Utils/RPBookGUIUtils.java
@@ -15,7 +15,9 @@
******************************************************************************/
package io.github.puyodead1.rpbookgui.Utils;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -58,7 +60,8 @@ public static boolean isOnCorrectItem(CustomEnchant enchant, ItemStack is) {
}
public static List getCustomEnchants(String rarity) {
- return CustomEnchants.getCustomEnchants().getEnchantRarity(rarity.toUpperCase()).getEnchants();
+ List enchants = CustomEnchants.getCustomEnchants().getEnchantRarity(rarity.toUpperCase()).getEnchants();
+ return enchants.stream().filter(e -> e.isEnabled()).collect(Collectors.toList());
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 8303c13..8e7aef6 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: RPBookGUI
-version: 2.9.8-hf1
+version: 2.9.8-rc2
author: Puyodead1
main: io.github.puyodead1.rpbookgui.RPBookGUI
depend: [RandomPackage]