mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-12-18 14:58:45 +01:00
formatting applied to most of the source code to tidy things up, and misc refactors
This commit is contained in:
@@ -29,8 +29,8 @@ import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.ACROBATICS);
|
||||
public AcrobaticsManager(McMMOPlayer mmoPlayer) {
|
||||
super(mmoPlayer, PrimarySkillType.ACROBATICS);
|
||||
fallLocationMap = new BlockLocationHistory(50);
|
||||
}
|
||||
|
||||
@@ -48,8 +48,9 @@ public class AcrobaticsManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canGainRollXP() {
|
||||
if (!ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented())
|
||||
if (!ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() >= rollXPCooldown) {
|
||||
rollXPCooldown = System.currentTimeMillis() + rollXPInterval;
|
||||
@@ -63,11 +64,13 @@ public class AcrobaticsManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canDodge(Entity damager) {
|
||||
if (getPlayer().isBlocking())
|
||||
if (getPlayer().isBlocking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE))
|
||||
if (!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ACROBATICS_DODGE)) {
|
||||
if (damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) {
|
||||
@@ -84,36 +87,49 @@ public class AcrobaticsManager extends SkillManager {
|
||||
* Handle the damage reduction and XP gain from the Dodge ability
|
||||
*
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
* @return the modified event damage if the ability was successful, the original event damage
|
||||
* otherwise
|
||||
*/
|
||||
public double dodgeCheck(Entity attacker, double damage) {
|
||||
double modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
|
||||
double modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage,
|
||||
Acrobatics.dodgeDamageModifier);
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!isFatal(modifiedDamage)
|
||||
&& ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.ACROBATICS_DODGE, UserManager.getPlayer(player))) {
|
||||
&& ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.ACROBATICS_DODGE,
|
||||
UserManager.getPlayer(player))) {
|
||||
ParticleEffectUtils.playDodgeEffect(player);
|
||||
|
||||
if (mmoPlayer.useChatNotifications()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Combat.Proc");
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE,
|
||||
"Acrobatics.Combat.Proc");
|
||||
}
|
||||
|
||||
if (SkillUtils.cooldownExpired(mmoPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
if (SkillUtils.cooldownExpired(mmoPlayer.getRespawnATS(),
|
||||
Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
if (attacker instanceof Mob mob) {
|
||||
//Check to see how many dodge XP rewards this mob has handed out
|
||||
if (mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
if (mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER)
|
||||
&& ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
//If Dodge XP has been handed out 5 times then consider it being exploited
|
||||
MetadataValue metadataValue = mob.getMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER).get(0);
|
||||
MetadataValue metadataValue = mob.getMetadata(
|
||||
MetadataConstants.METADATA_KEY_DODGE_TRACKER).get(0);
|
||||
int count = metadataValue.asInt();
|
||||
|
||||
if (count <= 5) {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob, mcMMO.p);
|
||||
mcMMO.p.getFoliaLib().getScheduler().runAtEntityTimer(mob, metaCleanupTask, 20, 20*60); //one minute
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
|
||||
XPGainReason.PVE);
|
||||
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER,
|
||||
new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob,
|
||||
mcMMO.p);
|
||||
mcMMO.p.getFoliaLib().getScheduler()
|
||||
.runAtEntityTimer(mob, metaCleanupTask, 20,
|
||||
20 * 60); //one minute
|
||||
}
|
||||
} else {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier),
|
||||
XPGainReason.PVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user