From e2d7f9c307887c3eaf084124d91ec0ae5e29b58e Mon Sep 17 00:00:00 2001 From: Zeshan Aslam Date: Fri, 20 Sep 2019 08:41:32 -0400 Subject: [PATCH] Fixed async and action system error --- plugin.yml | 3 ++- .../zeshanaslam/actionhealth/LookThread.java | 7 +------ .../actionhealth/action/ActionListener.java | 20 +++++++++++++++++-- .../actionhealth/config/ConfigStore.java | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/plugin.yml b/plugin.yml index 1659347..f63be21 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,7 @@ name: ActionHealth main: com.zeshanaslam.actionhealth.Main -version: 3.4.0 +version: 3.4.1 +api-version: 1.14 softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO, MythicMobs, LangUtils] commands: Actionhealth: diff --git a/src/com/zeshanaslam/actionhealth/LookThread.java b/src/com/zeshanaslam/actionhealth/LookThread.java index c665ed7..10c4745 100644 --- a/src/com/zeshanaslam/actionhealth/LookThread.java +++ b/src/com/zeshanaslam/actionhealth/LookThread.java @@ -46,12 +46,7 @@ public class LookThread extends BukkitRunnable { String name = plugin.healthUtil.getName(livingEntity, player); if (TargetHelper.canSee(player, livingEntity.getLocation(), transparentTypeIds) && !plugin.healthUtil.isBlacklisted(livingEntity, name)) { - Bukkit.getScheduler().runTask(plugin, new Runnable() { - @Override - public void run() { - plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth()); - } - }); + plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth()); break; } } diff --git a/src/com/zeshanaslam/actionhealth/action/ActionListener.java b/src/com/zeshanaslam/actionhealth/action/ActionListener.java index 0f38293..85692db 100644 --- a/src/com/zeshanaslam/actionhealth/action/ActionListener.java +++ b/src/com/zeshanaslam/actionhealth/action/ActionListener.java @@ -10,7 +10,11 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionEffect; import java.util.ArrayList; import java.util.List; @@ -91,8 +95,20 @@ public class ActionListener implements Listener { String name = itemStack.getType().name(); possibleMaterials.add(name); - if (name.contains("POTION")) { - possibleMaterials.add(Potion.fromItemStack(itemStack).getType().getEffectType().getName() + "_" + name); + if (itemStack.hasItemMeta()) { + ItemMeta itemMeta = itemStack.getItemMeta(); + if (itemMeta instanceof PotionMeta) { + PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta(); + + PotionData potionData = potionMeta.getBasePotionData(); + possibleMaterials.add(potionData.getType().getEffectType().getName() + "_" + name); + + if (potionMeta.hasCustomEffects()) { + for (PotionEffect potionEffect : potionMeta.getCustomEffects()) { + possibleMaterials.add(potionEffect.getType().getName() + "_" + name); + } + } + } } return possibleMaterials; diff --git a/src/com/zeshanaslam/actionhealth/config/ConfigStore.java b/src/com/zeshanaslam/actionhealth/config/ConfigStore.java index e0e6495..e49bc51 100644 --- a/src/com/zeshanaslam/actionhealth/config/ConfigStore.java +++ b/src/com/zeshanaslam/actionhealth/config/ConfigStore.java @@ -123,7 +123,7 @@ public class ConfigStore { lookDistance = plugin.getConfig().getDouble("Look Distance"); if (showOnLook) { - BukkitTask bukkitTask = new LookThread(plugin).runTaskTimerAsynchronously(plugin, 0, 20); + BukkitTask bukkitTask = new LookThread(plugin).runTaskTimer(plugin, 0, 20); plugin.taskID = bukkitTask.getTaskId(); } } else {