diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index ce56abd6..30c808c0 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -38,6 +38,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.potion.PotionType; @@ -563,6 +564,20 @@ public class ConfigManager { } else skullMeta.setOwner(skullOwner); GUIitem.setItemMeta(skullMeta); + } else if (guiSection.contains("Enchantments") && Jobs.getGCManager().JobsGUIEnableEnchants) { + List enchants = guiSection.getStringList("Enchantments"); + if (enchants.size() > 0) { + for (String str4 : enchants) { + String[] id = str4.split(":"); + if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) { + EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta(); + enchantMeta.addStoredEnchant(Enchantment.getByName(id[0]), Integer.parseInt(id[1]), true); + GUIitem.setItemMeta(enchantMeta); + } else { + GUIitem.addUnsafeEnchantment(Enchantment.getByName(id[0]), Integer.parseInt(id[1])); + } + } + } } else Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!"); } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 9c21fe4a..96d382a7 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -102,7 +102,7 @@ public class GeneralConfigManager { public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, - JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; + JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin, JobsGUIEnableEnchants; private int JobsGUIRows, JobsGUIBackButton, JobsGUIStartPosition, @@ -916,6 +916,8 @@ public class GeneralConfigManager { c.getW().addComment("JobsGUI.SwitcheButtons", "With true left mouse button will join job and right will show more info", "With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file"); JobsGUISwitcheButtons = c.get("JobsGUI.SwitcheButtons", false); + c.getW().addComment("JobsGUI.EnableEnchants", "Enables the enchantment for items"); + JobsGUIEnableEnchants = c.get("JobsGUI.EnableEnchants", true); c.getW().addComment("JobsGUI.Rows", "Defines size in rows of GUI"); JobsGUIRows = c.get("JobsGUI.Rows", 5); c.getW().addComment("JobsGUI.BackButtonSlot", "Defines back button slot in GUI"); diff --git a/src/main/java/jobConfig.yml b/src/main/java/jobConfig.yml index 5d2d8cc9..af981e03 100644 --- a/src/main/java/jobConfig.yml +++ b/src/main/java/jobConfig.yml @@ -85,6 +85,9 @@ Jobs: Id: 17 # data of block, usualy its 0, but in example Diorite will have id of 1 and data of 3 Data: 2 + # enchants in the item + Enchantments: + - 'DURABILITY:1' # Defines maximum amount of daily quests player can have from THIS job # This will not have effect on overall quest amount player will have maxDailyQuests: 3