From a4b2b4e6b57d0e999dedf198e05d252c45d31040 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Wed, 14 Aug 2019 16:06:44 +0200 Subject: [PATCH] Same changes for giving items --- .../gamingmesh/jobs/McMMO/McMMO2_X_listener.java | 5 ----- .../com/gamingmesh/jobs/config/ShopManager.java | 3 ++- .../java/com/gamingmesh/jobs/dao/JobsManager.java | 2 ++ .../java/com/gamingmesh/jobs/stuff/GiveItem.java | 14 ++++++++------ .../java/com/gamingmesh/jobs/stuff/blockLoc.java | 12 ++++++++++++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/McMMO/McMMO2_X_listener.java b/src/main/java/com/gamingmesh/jobs/McMMO/McMMO2_X_listener.java index 1a3f67ba..970d10ac 100644 --- a/src/main/java/com/gamingmesh/jobs/McMMO/McMMO2_X_listener.java +++ b/src/main/java/com/gamingmesh/jobs/McMMO/McMMO2_X_listener.java @@ -15,7 +15,6 @@ import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.JobsPlayer; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent; -import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityEvent; import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; public class McMMO2_X_listener implements Listener { @@ -56,10 +55,6 @@ public class McMMO2_X_listener implements Listener { Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR)); } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void OnAbility(McMMOPlayerAbilityEvent event) { - } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) { HashMap InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId()); diff --git a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java index 102e91f2..d32593ab 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java @@ -30,6 +30,7 @@ import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.container.ShopItem; +import com.gamingmesh.jobs.stuff.GiveItem; public class ShopManager { private List list = new ArrayList<>(); @@ -123,7 +124,7 @@ public class ShopManager { for (JobItems one : item.getitems()) { ItemStack itemStack = one.getItemStack(player); - player.getInventory().addItem(itemStack); + GiveItem.GiveItemForPlayer(player, itemStack); } pointsInfo.takePoints(item.getPrice()); diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java b/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java index 6babe85f..f562fb1f 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java @@ -42,6 +42,8 @@ public class JobsManager { dao = startMysql(); dao.setDbType(DbType); break; + default: + break; } File f = new File(Jobs.getFolder(), "generalConfig.yml"); diff --git a/src/main/java/com/gamingmesh/jobs/stuff/GiveItem.java b/src/main/java/com/gamingmesh/jobs/stuff/GiveItem.java index 27209447..3990604a 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/GiveItem.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/GiveItem.java @@ -14,7 +14,8 @@ import org.bukkit.inventory.meta.ItemMeta; import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; public class GiveItem { - public static boolean GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List lore, HashMap hashMap) { + public static void GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List lore, + HashMap hashMap) { ItemStack itemStack = CMIMaterial.get(id, meta).newItemStack(); itemStack.setAmount(qty); ItemMeta ItemMeta = itemStack.getItemMeta(); @@ -24,22 +25,23 @@ public class GiveItem { for (String oneLore : lore) { TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName()))); } + ItemMeta.setLore(TranslatedLore); } + for (Entry OneEnchant : hashMap.entrySet()) { ItemMeta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true); } + if (name != null) ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); + itemStack.setItemMeta(ItemMeta); - player.getInventory().addItem(itemStack); - player.updateInventory(); - return true; + GiveItemForPlayer(player, itemStack); } - public static boolean GiveItemForPlayer(Player player, ItemStack item) { + public static void GiveItemForPlayer(Player player, ItemStack item) { player.getInventory().addItem(item); player.updateInventory(); - return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/stuff/blockLoc.java b/src/main/java/com/gamingmesh/jobs/stuff/blockLoc.java index 7aa52005..5ce58c37 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/blockLoc.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/blockLoc.java @@ -32,6 +32,18 @@ public class blockLoc { this.worldName = worldName; } + public void setX(int x) { + this.x = x; + } + + public void setY(int y) { + this.y = y; + } + + public void setZ(int z) { + this.z = z; + } + @Override public String toString() { return (w == null ? worldName : w.getName()) + ":" + x + ":" + y + ":" + z;