Fix for Acrobatics leveling exploit - Fixes MCCORE-74

This commit is contained in:
GJ 2012-03-12 01:45:08 -04:00
parent 0a8d34a21f
commit 3e0cc358d0
2 changed files with 103 additions and 74 deletions

View File

@ -24,6 +24,7 @@ Version 2.0.00-dev
= Fixed bug where Green Terra didn't work on Stone Brick = Fixed bug where Green Terra didn't work on Stone Brick
= Fixed bug where Tree Feller could be used without permissions = Fixed bug where Tree Feller could be used without permissions
= Fixed exploit where falling sand & gravel weren't tracked = Fixed exploit where falling sand & gravel weren't tracked
= Fixed exploit where Acrobatics could be leveled via Dodge on party members.
! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable) ! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable)
! Changed Chimera Wing failure check to use the maxWorldHeight. ! Changed Chimera Wing failure check to use the maxWorldHeight.
! Changed inspect failed message to say inspect rather than whois ! Changed inspect failed message to say inspect rather than whois

View File

@ -9,81 +9,109 @@ import com.gmail.nossr50.mcPermissions;
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.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
public class Acrobatics { public class Acrobatics {
public static void acrobaticsCheck(Player player, EntityDamageEvent event)
{
PlayerProfile PP = Users.getProfile(player);
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
if(player.isSneaking()) /**
acrovar = acrovar * 2; * Check for fall damage reduction.
*
* @param player The player whose fall damage to modify
* @param event The event to check
*/
public static void acrobaticsCheck(Player player, EntityDamageEvent event) {
final int ROLL_XP_MODIFIER = 80;
final int FALL_XP_MODIFIER = 120;
if(Math.random() * 1000 <= acrovar) PlayerProfile PP = Users.getProfile(player);
{ int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
int threshold = 7; boolean gracefulRoll = player.isSneaking();
int damage = event.getDamage();
if(player.isSneaking()) if (gracefulRoll) {
threshold = 14; acrovar = acrovar * 2;
}
int newDamage = event.getDamage() - threshold; if (acrovar > 1000 || Math.random() * 1000 <= acrovar) {
int threshold = 7;
if(newDamage < 0) if (gracefulRoll) {
newDamage = 0; threshold = threshold * 2;
}
/* int newDamage = damage - threshold;
* Check for death
*/ if (newDamage < 0) {
if(player.getHealth() - newDamage >= 1) newDamage = 0;
{ }
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 8)*10, player);
Skills.XpCheckSkill(SkillType.ACROBATICS, player); /* Check for death */
event.setDamage(newDamage); if (player.getHealth() - damage >= 1) {
if(event.getDamage() <= 0) PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER, player);
event.setCancelled(true); Skills.XpCheckSkill(SkillType.ACROBATICS, player);
if(player.isSneaking()){
player.sendMessage(mcLocale.getString("Acrobatics.GracefulRoll")); event.setDamage(newDamage);
} else {
player.sendMessage(mcLocale.getString("Acrobatics.Roll")); if (event.getDamage() <= 0) {
} event.setCancelled(true);
} }
}
else if(player.getHealth() - event.getDamage() >= 1) if (gracefulRoll) {
{ player.sendMessage(mcLocale.getString("Acrobatics.GracefulRoll"));
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, player); }
Skills.XpCheckSkill(SkillType.ACROBATICS, player); else {
} player.sendMessage(mcLocale.getString("Acrobatics.Roll"));
}
}
}
else if (player.getHealth() - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER, player);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
}
} }
public static void dodgeChecks(EntityDamageByEntityEvent event){
Player defender = (Player) event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
if(mcPermissions.getInstance().acrobatics(defender)){ /**
if(PPd.getSkillLevel(SkillType.ACROBATICS) <= 800){ * Check for dodge damage reduction.
if(Math.random() * 4000 <= PPd.getSkillLevel(SkillType.ACROBATICS)){ *
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge")); * @param event The event to check
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){ */
PPd.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*1, defender); public static void dodgeChecks(EntityDamageByEntityEvent event) {
Skills.XpCheckSkill(SkillType.ACROBATICS, defender); final int DODGE_MODIFIER = 120;
}
event.setDamage(event.getDamage() / 2);
//Needs to do minimal damage
if(event.getDamage() <= 0)
event.setDamage(1);
}
} else if(Math.random() * 4000 <= 800) {
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
PPd.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, defender);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}
event.setDamage(event.getDamage() / 2);
//Needs to deal minimal damage
if(event.getDamage() <= 0)
event.setDamage(1);
}
}
}
Player attacker = (Player) event.getDamager();
Player defender = (Player) event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
/* PARTY CHECK */
if (Party.getInstance().inSameParty(defender, attacker)) {
return;
}
if (mcPermissions.getInstance().acrobatics(defender)) {
int skillCheck = 0;
if (PPd.getSkillLevel(SkillType.ACROBATICS) <= 800) {
skillCheck = PPd.getSkillLevel(SkillType.ACROBATICS);
}
else {
skillCheck = 800;
}
if (Math.random() * 4000 <= skillCheck) {
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
if (System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1) {
PPd.addXP(SkillType.ACROBATICS, event.getDamage() * DODGE_MODIFIER, defender);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}
event.setDamage(event.getDamage() / 2);
//Needs to do minimal damage
if (event.getDamage() <= 0) {
event.setDamage(1);
}
}
}
}
} }