|
@@ -6,10 +6,13 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|
import com.gmail.nossr50.config.Config;
|
|
import com.gmail.nossr50.config.Config;
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
|
|
+import com.gmail.nossr50.util.Misc;
|
|
import com.gmail.nossr50.util.Permissions;
|
|
import com.gmail.nossr50.util.Permissions;
|
|
import com.gmail.nossr50.util.Users;
|
|
import com.gmail.nossr50.util.Users;
|
|
|
|
|
|
public class AcrobaticsManager {
|
|
public class AcrobaticsManager {
|
|
|
|
+ private static Config config = Config.getInstance();
|
|
|
|
+
|
|
private Player player;
|
|
private Player player;
|
|
private PlayerProfile profile;
|
|
private PlayerProfile profile;
|
|
private int skillLevel;
|
|
private int skillLevel;
|
|
@@ -26,29 +29,28 @@ public class AcrobaticsManager {
|
|
* @param event The event to check
|
|
* @param event The event to check
|
|
*/
|
|
*/
|
|
public void rollCheck(EntityDamageEvent event) {
|
|
public void rollCheck(EntityDamageEvent event) {
|
|
- if(player == null)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- if (!Permissions.roll(player)) {
|
|
|
|
|
|
+ if (Misc.isCitizensNPC(player) || !Permissions.roll(player)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if(Config.getInstance().getAcrobaticsAFKDisabled() && player.isInsideVehicle())
|
|
|
|
|
|
+ if (config.getAcrobaticsAFKDisabled() && player.isInsideVehicle()) {
|
|
return;
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
RollEventHandler eventHandler = new RollEventHandler(this, event);
|
|
RollEventHandler eventHandler = new RollEventHandler(this, event);
|
|
|
|
|
|
int randomChance = 100;
|
|
int randomChance = 100;
|
|
-
|
|
|
|
if (Permissions.luckyAcrobatics(player)) {
|
|
if (Permissions.luckyAcrobatics(player)) {
|
|
randomChance = (int) (randomChance * 0.75);
|
|
randomChance = (int) (randomChance * 0.75);
|
|
}
|
|
}
|
|
|
|
|
|
- float chance = (float) (((double) Acrobatics.ROLL_MAX_CHANCE / (double) Acrobatics.ROLL_MAX_BONUS_LEVEL) * skillLevel);
|
|
|
|
- if (chance > Acrobatics.ROLL_MAX_CHANCE) chance = Acrobatics.ROLL_MAX_CHANCE;
|
|
|
|
|
|
+ float chance;
|
|
|
|
+
|
|
if (eventHandler.isGraceful) {
|
|
if (eventHandler.isGraceful) {
|
|
- chance = (float) (((double) Acrobatics.GRACEFUL_MAX_CHANCE / (double) Acrobatics.GRACEFUL_MAX_BONUS_LEVEL) * skillLevel);
|
|
|
|
- if (chance > Acrobatics.GRACEFUL_MAX_CHANCE) chance = Acrobatics.GRACEFUL_MAX_CHANCE;
|
|
|
|
|
|
+ chance = ((float) Acrobatics.GRACEFUL_MAX_CHANCE / Acrobatics.GRACEFUL_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ chance = ((float) Acrobatics.ROLL_MAX_CHANCE / Acrobatics.ROLL_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
|
}
|
|
}
|
|
|
|
|
|
if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
|
if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
|
@@ -67,23 +69,18 @@ public class AcrobaticsManager {
|
|
* @param event The event to check
|
|
* @param event The event to check
|
|
*/
|
|
*/
|
|
public void dodgeCheck(EntityDamageEvent event) {
|
|
public void dodgeCheck(EntityDamageEvent event) {
|
|
- if(player == null)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- if (!Permissions.dodge(player)) {
|
|
|
|
|
|
+ if (Misc.isCitizensNPC(player) || !Permissions.dodge(player)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
|
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
|
|
|
|
|
int randomChance = 100;
|
|
int randomChance = 100;
|
|
-
|
|
|
|
if (Permissions.luckyAcrobatics(player)) {
|
|
if (Permissions.luckyAcrobatics(player)) {
|
|
randomChance = (int) (randomChance * 0.75);
|
|
randomChance = (int) (randomChance * 0.75);
|
|
}
|
|
}
|
|
|
|
|
|
- float chance = (float) (((double) Acrobatics.DODGE_MAX_CHANCE / (double) Acrobatics.DODGE_MAX_BONUS_LEVEL) * skillLevel);
|
|
|
|
- if (chance > Acrobatics.DODGE_MAX_CHANCE) chance = Acrobatics.DODGE_MAX_CHANCE;
|
|
|
|
|
|
+ float chance = ((float) Acrobatics.DODGE_MAX_CHANCE / Acrobatics.DODGE_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
|
|
|
|
|
if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
|
if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
|
eventHandler.modifyEventDamage();
|
|
eventHandler.modifyEventDamage();
|