@@ -12,36 +12,40 @@ private AbilityAPI() {
1212 }
1313
1414 public static boolean berserkEnabled (Player player ) {
15- return UserManager . getPlayer (player ). getAbilityMode ( SuperAbilityType .BERSERK );
15+ return hasAbilityEnabled (player , SuperAbilityType .BERSERK );
1616 }
1717
1818 public static boolean gigaDrillBreakerEnabled (Player player ) {
19- return UserManager . getPlayer (player ). getAbilityMode ( SuperAbilityType .GIGA_DRILL_BREAKER );
19+ return hasAbilityEnabled (player , SuperAbilityType .GIGA_DRILL_BREAKER );
2020 }
2121
2222 public static boolean greenTerraEnabled (Player player ) {
23- return UserManager . getPlayer (player ). getAbilityMode ( SuperAbilityType .GREEN_TERRA );
23+ return hasAbilityEnabled (player , SuperAbilityType .GREEN_TERRA );
2424 }
2525
2626 public static boolean serratedStrikesEnabled (Player player ) {
27- return UserManager . getPlayer (player ). getAbilityMode ( SuperAbilityType .SERRATED_STRIKES );
27+ return hasAbilityEnabled (player , SuperAbilityType .SERRATED_STRIKES );
2828 }
2929
3030 public static boolean skullSplitterEnabled (Player player ) {
31- return UserManager . getPlayer (player ). getAbilityMode ( SuperAbilityType .SKULL_SPLITTER );
31+ return hasAbilityEnabled (player , SuperAbilityType .SKULL_SPLITTER );
3232 }
3333
3434 public static boolean superBreakerEnabled (Player player ) {
35- return UserManager . getPlayer (player ). getAbilityMode ( SuperAbilityType .SUPER_BREAKER );
35+ return hasAbilityEnabled (player , SuperAbilityType .SUPER_BREAKER );
3636 }
3737
3838 public static boolean treeFellerEnabled (Player player ) {
39- return UserManager . getPlayer (player ). getAbilityMode ( SuperAbilityType .TREE_FELLER );
39+ return hasAbilityEnabled (player , SuperAbilityType .TREE_FELLER );
4040 }
4141
4242 public static boolean isAnyAbilityEnabled (Player player ) {
4343 final McMMOPlayer mmoPlayer = UserManager .getPlayer (player );
4444
45+ if (mmoPlayer == null ) {
46+ return false ;
47+ }
48+
4549 for (SuperAbilityType ability : SuperAbilityType .values ()) {
4650 if (mmoPlayer .getAbilityMode (ability )) {
4751 return true ;
@@ -51,36 +55,57 @@ public static boolean isAnyAbilityEnabled(Player player) {
5155 return false ;
5256 }
5357
58+ private static boolean hasAbilityEnabled (Player player , SuperAbilityType ability ) {
59+ McMMOPlayer mmoPlayer = UserManager .getPlayer (player );
60+ return mmoPlayer != null && mmoPlayer .getAbilityMode (ability );
61+ }
62+
5463 public static void resetCooldowns (Player player ) {
55- UserManager .getPlayer (player ).resetCooldowns ();
64+ McMMOPlayer mmoPlayer = UserManager .getPlayer (player );
65+
66+ if (mmoPlayer == null ) {
67+ return ;
68+ }
69+
70+ mmoPlayer .resetCooldowns ();
5671 }
5772
5873 public static void setBerserkCooldown (Player player , long cooldown ) {
59- UserManager . getPlayer (player ). setAbilityDATS ( SuperAbilityType .BERSERK , cooldown );
74+ setAbilityCooldown (player , SuperAbilityType .BERSERK , cooldown );
6075 }
6176
6277 public static void setGigaDrillBreakerCooldown (Player player , long cooldown ) {
63- UserManager . getPlayer (player ). setAbilityDATS ( SuperAbilityType .GIGA_DRILL_BREAKER , cooldown );
78+ setAbilityCooldown (player , SuperAbilityType .GIGA_DRILL_BREAKER , cooldown );
6479 }
6580
6681 public static void setGreenTerraCooldown (Player player , long cooldown ) {
67- UserManager . getPlayer (player ). setAbilityDATS ( SuperAbilityType .GREEN_TERRA , cooldown );
82+ setAbilityCooldown (player , SuperAbilityType .GREEN_TERRA , cooldown );
6883 }
6984
7085 public static void setSerratedStrikesCooldown (Player player , long cooldown ) {
71- UserManager . getPlayer (player ). setAbilityDATS ( SuperAbilityType .SERRATED_STRIKES , cooldown );
86+ setAbilityCooldown (player , SuperAbilityType .SERRATED_STRIKES , cooldown );
7287 }
7388
7489 public static void setSkullSplitterCooldown (Player player , long cooldown ) {
75- UserManager . getPlayer (player ). setAbilityDATS ( SuperAbilityType .SKULL_SPLITTER , cooldown );
90+ setAbilityCooldown (player , SuperAbilityType .SKULL_SPLITTER , cooldown );
7691 }
7792
7893 public static void setSuperBreakerCooldown (Player player , long cooldown ) {
79- UserManager . getPlayer (player ). setAbilityDATS ( SuperAbilityType .SUPER_BREAKER , cooldown );
94+ setAbilityCooldown (player , SuperAbilityType .SUPER_BREAKER , cooldown );
8095 }
8196
8297 public static void setTreeFellerCooldown (Player player , long cooldown ) {
83- UserManager .getPlayer (player ).setAbilityDATS (SuperAbilityType .TREE_FELLER , cooldown );
98+ setAbilityCooldown (player , SuperAbilityType .TREE_FELLER , cooldown );
99+ }
100+
101+ private static void setAbilityCooldown (Player player , SuperAbilityType ability , long cooldown ) {
102+ McMMOPlayer mmoPlayer = UserManager .getPlayer (player );
103+
104+ if (mmoPlayer == null ) {
105+ return ;
106+ }
107+
108+ mmoPlayer .setAbilityDATS (ability , cooldown );
84109 }
85110
86111 public static boolean isBleeding (LivingEntity entity ) {
0 commit comments