diff --git a/pom.xml b/pom.xml index c3e84807..833c9f4d 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ me.clip placeholderapi - 2.10.1 + 2.10.2 provided diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index baa4f8cc..90015074 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -28,6 +28,7 @@ import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.CMILib.VersionChecker.Version; public class ItemManager { @@ -36,7 +37,7 @@ public class ItemManager { static HashMap byBukkitName = new HashMap<>(); static HashMap byMojangName = new HashMap<>(); static HashMap byMaterial = new HashMap<>(); - static HashMap byRealMaterial = new HashMap(); + static HashMap byRealMaterial = new HashMap<>(); public HashMap idMap() { return byId; @@ -396,7 +397,7 @@ public class ItemManager { } public List getAllRecipes() { - List results = new ArrayList(); + List results = new ArrayList<>(); Iterator iter = Bukkit.recipeIterator(); while (iter.hasNext()) { Recipe recipe = iter.next(); @@ -557,59 +558,57 @@ public class ItemManager { } public enum CMIPotionType { - Awkward(373, 16, "Awkard Potion"), - Fire_Resistance_1(373, 8195, "Fire Resistance Potion"), - Fire_Resistance_2(373, 8259, "Fire Resistance Potion 2"), - Harming_1(373, 8204, "Harming Potion"), - Harming_2(373, 8236, "Harming Potion 2"), - Healing_1(373, 8197, "Healing Potion"), - Healing_2(373, 8229, "Healing Potion 2"), - Invisibility_1(373, 8206, "Invisibility Potion"), - Invisibility_2(373, 8270, "Invisibility Potion 2"), - Leaping_1(373, 8267, "Leaping Potion"), - Leaping_2(373, 8235, "Leaping Potion 2"), - Luck(-1, -1, "Luck Potion"), - Mundane(373, 64, "Mundane Potion"), - Night_Vision_1(373, 8198, "Night Vision Potion"), - Night_Vision_2(373, 8262, "Night Vision Potion 2"), - Poison_1(373, 8196, "Poison Potion"), - Poison_2(373, 8228, "Poison Potion 2"), - Poison_3(373, 8260, "Poison Potion 3"), - Poison_4(373, 8292, "Poison Potion 4"), - Regeneration_1(373, 8193, "Regeneration Potion"), - Regeneration_2(373, 8225, "Regeneration Potion 2"), - Regeneration_3(373, 8257, "Regeneration Potion 3"), - Regeneration_4(373, 8289, "Regeneration Potion 4"), - Slow_Falling_1(-1, -1, "Slow Falling Potion"), - Slow_Falling_2(-1, -1, "Slow Falling Potion 2"), - Slowness_1(373, 8202, "Slowness Potion"), - Slowness_2(373, 8266, "Slowness Potion 2"), - Strength_1(373, 8201, "Strength Potion"), - Strength_2(373, 8233, "Strength Potion 2"), - Strength_3(373, 8265, "Strength Potion 3"), - Strength_4(373, 8297, "Strength Potion 4"), - Swiftness_1(373, 8194, "Swiftness Potion"), - Swiftness_2(373, 8226, "Swiftness Potion 2"), - Swiftness_3(373, 8258, "Swiftness Potion 3"), - Swiftness_4(373, 8290, "Swiftness Potion 4"), - Thick(373, 32, "Thick Potion"), - Turtle_Master_1(-1, -1, "Turtle Master Potion"), - Turtle_Master_2(-1, -1, "Turtle Master Potion 2"), - Turtle_Master_3(-1, -1, "Turtle Master Potion 3"), - Water_Breathing_1(373, 8205, "Water Breathing Potion"), - Water_Breathing_2(373, 8269, "Water Breathing Potion 2"), - Weakness_1(373, 8200, "Weakness Potion"), - Weakness_2(373, 8264, "Weakness Potion 2"), - Water(373, 0, "Water Potion"); + Awkward(16, "Awkward"), + Fire_Resistance(8195, "Fire Resistance"), + Extended_Fire_Resistance(8259, "Extended Fire Resistance"), + Harming(8204, "Harming"), + Extended_Harming(8236, "Extended Harming"), + Healing(8197, "Healing"), + Extended_Healing(8229, "Extended Healing"), + Invisibility(8206, "Invisibility"), + Extended_Invisibility(8270, "Extended Invisibility"), + Leaping(8267, "Leaping"), + Extended_Leaping(8235, "Extended Leaping"), + Luck(-1, "Luck"), + Mundane(64, "Mundane"), + Night_Vision(8198, "Night Vision"), + Extended_Night_Vision(8262, "Extended Night Vision"), + Poison(8196, "Poison"), + Extended_Poison(8228, "Extended Poison"), + //Poison_3(8260, "Poison 3"), + //Poison_4(8292, "Poison 4"), + Regeneration(8193, "Regeneration"), + Extended_Regeneration(8225, "Extended Regeneration"), + //Regeneration_3(8257, "Regeneration Potion 3"), + //Regeneration_4(8289, "Regeneration Potion 4"), + Slow_Falling(-1, "Slow Falling"), + Extended_Slow_Falling(-1, "Extended Slow Falling"), + Slowness(8202, "Slowness"), + Extended_Slowness(8266, "Extended Slowness"), + Strength(8201, "Strength Potion"), + Extended_Strength(8233, "Extended Strength"), + //Strength_3(8265, "Strength Potion 3"), + //Strength_4(8297, "Strength Potion 4"), + Swiftness(8194, "Swiftness"), + Extended_Swiftness(8226, "Extended Swiftness"), + //Swiftness_3(8258, "Swiftness Potion 3"), + //Swiftness_4(8290, "Swiftness Potion 4"), + Thick(32, "Thick"), + Turtle_Master(-1, "Turtle Master"), + Extended_Turtle_Master(-1, "Extended Turtle Master"), + //Turtle_Master_3(-1, "Turtle Master Potion 3"), + Water_Breathing(8205, "Water Breathing"), + Extended_Water_Breathing(8269, "Extended Water Breathing"), + Weakness(8200, "Weakness"), + Extended_Weakness(8264, "Extended Weakness"), + Water(0, "Water"); private int id; private String name; PotionType type = null; - private int data; - CMIPotionType(int id, int data, String name) { + CMIPotionType(int id, String name) { this.id = id; - this.data = data; this.name = name; } @@ -739,10 +738,6 @@ public class ItemManager { name = name.substring(0, 1).toUpperCase() + name.substring(1); return name; } - - public int getSubId() { - return data; - } } public enum CMIEntityType { diff --git a/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java b/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java index 36313c45..c2487f26 100644 --- a/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java +++ b/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java @@ -1,22 +1,20 @@ package com.gamingmesh.jobs.actions; -import org.bukkit.potion.PotionType; - import com.gamingmesh.jobs.container.ActionInfo; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.BaseActionInfo; public class PotionDrinkInfo extends BaseActionInfo implements ActionInfo { - private PotionType potion; + private String potion; - public PotionDrinkInfo(PotionType potion, ActionType type) { + public PotionDrinkInfo(String potion, ActionType type) { super(type); this.potion = potion; } @Override public String getName() { - return potion.name(); + return potion; } @Override diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index f3ab38f5..bd56cb0c 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -81,6 +81,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; +import org.bukkit.potion.Potion; import org.bukkit.projectiles.ProjectileSource; import com.gamingmesh.jobs.Jobs; @@ -1473,7 +1474,7 @@ public class JobsPaymentListener implements Listener { } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerInteract(PlayerInteractEvent event) { if (!plugin.isEnabled()) return; @@ -1571,11 +1572,8 @@ public class JobsPaymentListener implements Listener { public void onPlayerItemConsume(PlayerItemConsumeEvent event) { if (!plugin.isEnabled()) return; - //disabling plugin in world - if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) - return; - if (event.isCancelled()) + if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) return; Player p = event.getPlayer(); @@ -1583,7 +1581,6 @@ public class JobsPaymentListener implements Listener { if (!p.isOnline()) return; - // check if in creative if (!payIfCreative(p)) return; @@ -1594,15 +1591,20 @@ public class JobsPaymentListener implements Listener { if (jPlayer == null) return; - if (event.getItem().getType() != Material.POTION) + if (event.getItem().getType() != CMIMaterial.POTION.getMaterial()) return; - // Player drinking a potion + if (Version.isCurrentEqualOrLower(Version.v1_8_R3)) { + Potion potion = Potion.fromItemStack(event.getItem()); + Jobs.action(jPlayer, new PotionDrinkInfo(potion.getType().name(), ActionType.DRINK)); + return; + } PotionMeta meta = (PotionMeta) event.getItem().getItemMeta(); if (meta == null) return; - Jobs.action(jPlayer, new PotionDrinkInfo(meta.getBasePotionData().getType(), ActionType.DRINK)); + String name = meta.getBasePotionData().getType().name(); + Jobs.action(jPlayer, new PotionDrinkInfo(meta.getBasePotionData().isExtended() ? "EXTENDED_" + name : name, ActionType.DRINK)); } @EventHandler