Fixed async and action system error

This commit is contained in:
Zeshan Aslam 2019-09-20 08:41:32 -04:00
parent 945c73981c
commit e2d7f9c307
4 changed files with 22 additions and 10 deletions

View File

@ -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:

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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 {