mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +01:00
Fix potion consume event in 1.8 versions, #418
The potion drink action will be removed soon. It seems some potions has 3-4 types and needs to be known what types of, but not described.
This commit is contained in:
parent
1b818f5d05
commit
4e47bf2f4f
2
pom.xml
2
pom.xml
@ -124,7 +124,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.10.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -28,6 +28,7 @@ import org.bukkit.potion.PotionData;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.potion.PotionType;
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
||||||
|
|
||||||
public class ItemManager {
|
public class ItemManager {
|
||||||
@ -36,7 +37,7 @@ public class ItemManager {
|
|||||||
static HashMap<String, CMIItemStack> byBukkitName = new HashMap<>();
|
static HashMap<String, CMIItemStack> byBukkitName = new HashMap<>();
|
||||||
static HashMap<String, CMIItemStack> byMojangName = new HashMap<>();
|
static HashMap<String, CMIItemStack> byMojangName = new HashMap<>();
|
||||||
static HashMap<CMIMaterial, CMIItemStack> byMaterial = new HashMap<>();
|
static HashMap<CMIMaterial, CMIItemStack> byMaterial = new HashMap<>();
|
||||||
static HashMap<Material, CMIMaterial> byRealMaterial = new HashMap<Material, CMIMaterial>();
|
static HashMap<Material, CMIMaterial> byRealMaterial = new HashMap<>();
|
||||||
|
|
||||||
public HashMap<Integer, CMIItemStack> idMap() {
|
public HashMap<Integer, CMIItemStack> idMap() {
|
||||||
return byId;
|
return byId;
|
||||||
@ -396,7 +397,7 @@ public class ItemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Recipe> getAllRecipes() {
|
public List<Recipe> getAllRecipes() {
|
||||||
List<Recipe> results = new ArrayList<Recipe>();
|
List<Recipe> results = new ArrayList<>();
|
||||||
Iterator<Recipe> iter = Bukkit.recipeIterator();
|
Iterator<Recipe> iter = Bukkit.recipeIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Recipe recipe = iter.next();
|
Recipe recipe = iter.next();
|
||||||
@ -557,59 +558,57 @@ public class ItemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum CMIPotionType {
|
public enum CMIPotionType {
|
||||||
Awkward(373, 16, "Awkard Potion"),
|
Awkward(16, "Awkward"),
|
||||||
Fire_Resistance_1(373, 8195, "Fire Resistance Potion"),
|
Fire_Resistance(8195, "Fire Resistance"),
|
||||||
Fire_Resistance_2(373, 8259, "Fire Resistance Potion 2"),
|
Extended_Fire_Resistance(8259, "Extended Fire Resistance"),
|
||||||
Harming_1(373, 8204, "Harming Potion"),
|
Harming(8204, "Harming"),
|
||||||
Harming_2(373, 8236, "Harming Potion 2"),
|
Extended_Harming(8236, "Extended Harming"),
|
||||||
Healing_1(373, 8197, "Healing Potion"),
|
Healing(8197, "Healing"),
|
||||||
Healing_2(373, 8229, "Healing Potion 2"),
|
Extended_Healing(8229, "Extended Healing"),
|
||||||
Invisibility_1(373, 8206, "Invisibility Potion"),
|
Invisibility(8206, "Invisibility"),
|
||||||
Invisibility_2(373, 8270, "Invisibility Potion 2"),
|
Extended_Invisibility(8270, "Extended Invisibility"),
|
||||||
Leaping_1(373, 8267, "Leaping Potion"),
|
Leaping(8267, "Leaping"),
|
||||||
Leaping_2(373, 8235, "Leaping Potion 2"),
|
Extended_Leaping(8235, "Extended Leaping"),
|
||||||
Luck(-1, -1, "Luck Potion"),
|
Luck(-1, "Luck"),
|
||||||
Mundane(373, 64, "Mundane Potion"),
|
Mundane(64, "Mundane"),
|
||||||
Night_Vision_1(373, 8198, "Night Vision Potion"),
|
Night_Vision(8198, "Night Vision"),
|
||||||
Night_Vision_2(373, 8262, "Night Vision Potion 2"),
|
Extended_Night_Vision(8262, "Extended Night Vision"),
|
||||||
Poison_1(373, 8196, "Poison Potion"),
|
Poison(8196, "Poison"),
|
||||||
Poison_2(373, 8228, "Poison Potion 2"),
|
Extended_Poison(8228, "Extended Poison"),
|
||||||
Poison_3(373, 8260, "Poison Potion 3"),
|
//Poison_3(8260, "Poison 3"),
|
||||||
Poison_4(373, 8292, "Poison Potion 4"),
|
//Poison_4(8292, "Poison 4"),
|
||||||
Regeneration_1(373, 8193, "Regeneration Potion"),
|
Regeneration(8193, "Regeneration"),
|
||||||
Regeneration_2(373, 8225, "Regeneration Potion 2"),
|
Extended_Regeneration(8225, "Extended Regeneration"),
|
||||||
Regeneration_3(373, 8257, "Regeneration Potion 3"),
|
//Regeneration_3(8257, "Regeneration Potion 3"),
|
||||||
Regeneration_4(373, 8289, "Regeneration Potion 4"),
|
//Regeneration_4(8289, "Regeneration Potion 4"),
|
||||||
Slow_Falling_1(-1, -1, "Slow Falling Potion"),
|
Slow_Falling(-1, "Slow Falling"),
|
||||||
Slow_Falling_2(-1, -1, "Slow Falling Potion 2"),
|
Extended_Slow_Falling(-1, "Extended Slow Falling"),
|
||||||
Slowness_1(373, 8202, "Slowness Potion"),
|
Slowness(8202, "Slowness"),
|
||||||
Slowness_2(373, 8266, "Slowness Potion 2"),
|
Extended_Slowness(8266, "Extended Slowness"),
|
||||||
Strength_1(373, 8201, "Strength Potion"),
|
Strength(8201, "Strength Potion"),
|
||||||
Strength_2(373, 8233, "Strength Potion 2"),
|
Extended_Strength(8233, "Extended Strength"),
|
||||||
Strength_3(373, 8265, "Strength Potion 3"),
|
//Strength_3(8265, "Strength Potion 3"),
|
||||||
Strength_4(373, 8297, "Strength Potion 4"),
|
//Strength_4(8297, "Strength Potion 4"),
|
||||||
Swiftness_1(373, 8194, "Swiftness Potion"),
|
Swiftness(8194, "Swiftness"),
|
||||||
Swiftness_2(373, 8226, "Swiftness Potion 2"),
|
Extended_Swiftness(8226, "Extended Swiftness"),
|
||||||
Swiftness_3(373, 8258, "Swiftness Potion 3"),
|
//Swiftness_3(8258, "Swiftness Potion 3"),
|
||||||
Swiftness_4(373, 8290, "Swiftness Potion 4"),
|
//Swiftness_4(8290, "Swiftness Potion 4"),
|
||||||
Thick(373, 32, "Thick Potion"),
|
Thick(32, "Thick"),
|
||||||
Turtle_Master_1(-1, -1, "Turtle Master Potion"),
|
Turtle_Master(-1, "Turtle Master"),
|
||||||
Turtle_Master_2(-1, -1, "Turtle Master Potion 2"),
|
Extended_Turtle_Master(-1, "Extended Turtle Master"),
|
||||||
Turtle_Master_3(-1, -1, "Turtle Master Potion 3"),
|
//Turtle_Master_3(-1, "Turtle Master Potion 3"),
|
||||||
Water_Breathing_1(373, 8205, "Water Breathing Potion"),
|
Water_Breathing(8205, "Water Breathing"),
|
||||||
Water_Breathing_2(373, 8269, "Water Breathing Potion 2"),
|
Extended_Water_Breathing(8269, "Extended Water Breathing"),
|
||||||
Weakness_1(373, 8200, "Weakness Potion"),
|
Weakness(8200, "Weakness"),
|
||||||
Weakness_2(373, 8264, "Weakness Potion 2"),
|
Extended_Weakness(8264, "Extended Weakness"),
|
||||||
Water(373, 0, "Water Potion");
|
Water(0, "Water");
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
PotionType type = null;
|
PotionType type = null;
|
||||||
private int data;
|
|
||||||
|
|
||||||
CMIPotionType(int id, int data, String name) {
|
CMIPotionType(int id, String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.data = data;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,10 +738,6 @@ public class ItemManager {
|
|||||||
name = name.substring(0, 1).toUpperCase() + name.substring(1);
|
name = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSubId() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CMIEntityType {
|
public enum CMIEntityType {
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
package com.gamingmesh.jobs.actions;
|
package com.gamingmesh.jobs.actions;
|
||||||
|
|
||||||
import org.bukkit.potion.PotionType;
|
|
||||||
|
|
||||||
import com.gamingmesh.jobs.container.ActionInfo;
|
import com.gamingmesh.jobs.container.ActionInfo;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.BaseActionInfo;
|
import com.gamingmesh.jobs.container.BaseActionInfo;
|
||||||
|
|
||||||
public class PotionDrinkInfo extends BaseActionInfo implements ActionInfo {
|
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);
|
super(type);
|
||||||
this.potion = potion;
|
this.potion = potion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return potion.name();
|
return potion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,6 +81,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
import org.bukkit.potion.Potion;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
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) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (!plugin.isEnabled())
|
if (!plugin.isEnabled())
|
||||||
return;
|
return;
|
||||||
@ -1571,11 +1572,8 @@ public class JobsPaymentListener implements Listener {
|
|||||||
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
|
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
|
||||||
if (!plugin.isEnabled())
|
if (!plugin.isEnabled())
|
||||||
return;
|
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;
|
return;
|
||||||
|
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
@ -1583,7 +1581,6 @@ public class JobsPaymentListener implements Listener {
|
|||||||
if (!p.isOnline())
|
if (!p.isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// check if in creative
|
|
||||||
if (!payIfCreative(p))
|
if (!payIfCreative(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1594,15 +1591,20 @@ public class JobsPaymentListener implements Listener {
|
|||||||
if (jPlayer == null)
|
if (jPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getItem().getType() != Material.POTION)
|
if (event.getItem().getType() != CMIMaterial.POTION.getMaterial())
|
||||||
return;
|
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();
|
PotionMeta meta = (PotionMeta) event.getItem().getItemMeta();
|
||||||
if (meta == null)
|
if (meta == null)
|
||||||
return;
|
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
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user