瀏覽代碼

Added API to check if an entity is bleeding

TfT_02 11 年之前
父節點
當前提交
af64bdf742

+ 1 - 0
Changelog.txt

@@ -13,6 +13,7 @@ Version 1.5.01-dev
  + Added option to config.yml for Alchemy. Skills.Alchemy.Prevent_Hopper_Transfer_Bottles
  + Added support for `MATERIAL|data` format in treasures.yml
  + Added API to experience events to get XP gain reason
+ + Added API to check if an entity is bleeding
  = Fixed bug where the Updater was running on the main thread.
  = Fixed bug when players would use /ptp without being in a party
  = Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent

+ 6 - 0
src/main/java/com/gmail/nossr50/api/AbilityAPI.java

@@ -1,9 +1,11 @@
 package com.gmail.nossr50.api;
 
+import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.Player;
 
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.AbilityType;
+import com.gmail.nossr50.runnables.skills.BleedTimerTask;
 import com.gmail.nossr50.util.player.UserManager;
 
 public final class AbilityAPI {
@@ -80,4 +82,8 @@ public final class AbilityAPI {
     public static void setTreeFellerCooldown(Player player, long cooldown) {
         UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
     }
+
+    public static boolean isBleeding(LivingEntity entity) {
+        return BleedTimerTask.isBleeding(entity);
+    }
 }

+ 4 - 0
src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java

@@ -107,4 +107,8 @@ public class BleedTimerTask extends BukkitRunnable {
             bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
         }
     }
+
+    public static boolean isBleeding(LivingEntity entity) {
+        return bleedList.containsKey(entity);
+    }
 }