|
@@ -12,36 +12,40 @@ public final class AbilityAPI {
|
|
|
}
|
|
|
|
|
|
public static boolean berserkEnabled(Player player) {
|
|
|
- return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);
|
|
|
+ return hasAbilityEnabled(player, SuperAbilityType.BERSERK);
|
|
|
}
|
|
|
|
|
|
public static boolean gigaDrillBreakerEnabled(Player player) {
|
|
|
- return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
|
|
|
+ return hasAbilityEnabled(player, SuperAbilityType.GIGA_DRILL_BREAKER);
|
|
|
}
|
|
|
|
|
|
public static boolean greenTerraEnabled(Player player) {
|
|
|
- return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA);
|
|
|
+ return hasAbilityEnabled(player, SuperAbilityType.GREEN_TERRA);
|
|
|
}
|
|
|
|
|
|
public static boolean serratedStrikesEnabled(Player player) {
|
|
|
- return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
|
|
|
+ return hasAbilityEnabled(player, SuperAbilityType.SERRATED_STRIKES);
|
|
|
}
|
|
|
|
|
|
public static boolean skullSplitterEnabled(Player player) {
|
|
|
- return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
|
|
|
+ return hasAbilityEnabled(player, SuperAbilityType.SKULL_SPLITTER);
|
|
|
}
|
|
|
|
|
|
public static boolean superBreakerEnabled(Player player) {
|
|
|
- return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER);
|
|
|
+ return hasAbilityEnabled(player, SuperAbilityType.SUPER_BREAKER);
|
|
|
}
|
|
|
|
|
|
public static boolean treeFellerEnabled(Player player) {
|
|
|
- return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER);
|
|
|
+ return hasAbilityEnabled(player, SuperAbilityType.TREE_FELLER);
|
|
|
}
|
|
|
|
|
|
public static boolean isAnyAbilityEnabled(Player player) {
|
|
|
final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
|
|
|
|
|
+ if(mmoPlayer == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
for (SuperAbilityType ability : SuperAbilityType.values()) {
|
|
|
if (mmoPlayer.getAbilityMode(ability)) {
|
|
|
return true;
|
|
@@ -51,36 +55,57 @@ public final class AbilityAPI {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private static boolean hasAbilityEnabled(Player player, SuperAbilityType ability) {
|
|
|
+ McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
|
|
+ return mmoPlayer != null && mmoPlayer.getAbilityMode(ability);
|
|
|
+ }
|
|
|
+
|
|
|
public static void resetCooldowns(Player player) {
|
|
|
- UserManager.getPlayer(player).resetCooldowns();
|
|
|
+ McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
|
|
+
|
|
|
+ if(mmoPlayer == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mmoPlayer.resetCooldowns();
|
|
|
}
|
|
|
|
|
|
public static void setBerserkCooldown(Player player, long cooldown) {
|
|
|
- UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
|
|
|
+ setAbilityCooldown(player, SuperAbilityType.BERSERK, cooldown);
|
|
|
}
|
|
|
|
|
|
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
|
|
|
- UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
|
|
|
+ setAbilityCooldown(player, SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
|
|
|
}
|
|
|
|
|
|
public static void setGreenTerraCooldown(Player player, long cooldown) {
|
|
|
- UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
|
|
|
+ setAbilityCooldown(player, SuperAbilityType.GREEN_TERRA, cooldown);
|
|
|
}
|
|
|
|
|
|
public static void setSerratedStrikesCooldown(Player player, long cooldown) {
|
|
|
- UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
|
|
|
+ setAbilityCooldown(player, SuperAbilityType.SERRATED_STRIKES, cooldown);
|
|
|
}
|
|
|
|
|
|
public static void setSkullSplitterCooldown(Player player, long cooldown) {
|
|
|
- UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
|
|
|
+ setAbilityCooldown(player, SuperAbilityType.SKULL_SPLITTER, cooldown);
|
|
|
}
|
|
|
|
|
|
public static void setSuperBreakerCooldown(Player player, long cooldown) {
|
|
|
- UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
|
|
|
+ setAbilityCooldown(player, SuperAbilityType.SUPER_BREAKER, cooldown);
|
|
|
}
|
|
|
|
|
|
public static void setTreeFellerCooldown(Player player, long cooldown) {
|
|
|
- UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
|
|
|
+ setAbilityCooldown(player, SuperAbilityType.TREE_FELLER, cooldown);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void setAbilityCooldown(Player player, SuperAbilityType ability, long cooldown) {
|
|
|
+ McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
|
|
+
|
|
|
+ if(mmoPlayer == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mmoPlayer.setAbilityDATS(ability, cooldown);
|
|
|
}
|
|
|
|
|
|
public static boolean isBleeding(LivingEntity entity) {
|