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 Tree Feller could be used without permissions
= 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 Chimera Wing failure check to use the maxWorldHeight.
! 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.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
public class Acrobatics {
public static void acrobaticsCheck(Player player, EntityDamageEvent event)
{
/**
* 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;
PlayerProfile PP = Users.getProfile(player);
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
boolean gracefulRoll = player.isSneaking();
int damage = event.getDamage();
if(player.isSneaking())
if (gracefulRoll) {
acrovar = acrovar * 2;
}
if(Math.random() * 1000 <= acrovar)
{
if (acrovar > 1000 || Math.random() * 1000 <= acrovar) {
int threshold = 7;
if(player.isSneaking())
threshold = 14;
if (gracefulRoll) {
threshold = threshold * 2;
}
int newDamage = event.getDamage() - threshold;
int newDamage = damage - threshold;
if(newDamage < 0)
if (newDamage < 0) {
newDamage = 0;
}
/*
* Check for death
*/
if(player.getHealth() - newDamage >= 1)
{
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 8)*10, player);
/* Check for death */
if (player.getHealth() - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER, player);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
event.setDamage(newDamage);
if(event.getDamage() <= 0)
if (event.getDamage() <= 0) {
event.setCancelled(true);
if(player.isSneaking()){
}
if (gracefulRoll) {
player.sendMessage(mcLocale.getString("Acrobatics.GracefulRoll"));
} else {
}
else {
player.sendMessage(mcLocale.getString("Acrobatics.Roll"));
}
}
}
else if(player.getHealth() - event.getDamage() >= 1)
{
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, player);
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){
/**
* Check for dodge damage reduction.
*
* @param event The event to check
*/
public static void dodgeChecks(EntityDamageByEntityEvent event) {
final int DODGE_MODIFIER = 120;
Player attacker = (Player) event.getDamager();
Player defender = (Player) event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
if(mcPermissions.getInstance().acrobatics(defender)){
if(PPd.getSkillLevel(SkillType.ACROBATICS) <= 800){
if(Math.random() * 4000 <= PPd.getSkillLevel(SkillType.ACROBATICS)){
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
PPd.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*1, defender);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}
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);
}
}
/* 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);
}
}
}
}
}