mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Fix for Acrobatics leveling exploit - Fixes MCCORE-74
This commit is contained in:
parent
0a8d34a21f
commit
3e0cc358d0
@ -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
|
||||||
|
@ -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);
|
* Check for fall damage reduction.
|
||||||
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
*
|
||||||
|
* @param player The player whose fall damage to modify
|
||||||
if(player.isSneaking())
|
* @param event The event to check
|
||||||
acrovar = acrovar * 2;
|
*/
|
||||||
|
public static void acrobaticsCheck(Player player, EntityDamageEvent event) {
|
||||||
if(Math.random() * 1000 <= acrovar)
|
final int ROLL_XP_MODIFIER = 80;
|
||||||
{
|
final int FALL_XP_MODIFIER = 120;
|
||||||
int threshold = 7;
|
|
||||||
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
if(player.isSneaking())
|
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
||||||
threshold = 14;
|
boolean gracefulRoll = player.isSneaking();
|
||||||
|
int damage = event.getDamage();
|
||||||
int newDamage = event.getDamage() - threshold;
|
|
||||||
|
if (gracefulRoll) {
|
||||||
if(newDamage < 0)
|
acrovar = acrovar * 2;
|
||||||
newDamage = 0;
|
}
|
||||||
|
|
||||||
/*
|
if (acrovar > 1000 || Math.random() * 1000 <= acrovar) {
|
||||||
* Check for death
|
int threshold = 7;
|
||||||
*/
|
|
||||||
if(player.getHealth() - newDamage >= 1)
|
if (gracefulRoll) {
|
||||||
{
|
threshold = threshold * 2;
|
||||||
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 8)*10, player);
|
}
|
||||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
|
||||||
event.setDamage(newDamage);
|
int newDamage = damage - threshold;
|
||||||
if(event.getDamage() <= 0)
|
|
||||||
event.setCancelled(true);
|
if (newDamage < 0) {
|
||||||
if(player.isSneaking()){
|
newDamage = 0;
|
||||||
player.sendMessage(mcLocale.getString("Acrobatics.GracefulRoll"));
|
}
|
||||||
} else {
|
|
||||||
player.sendMessage(mcLocale.getString("Acrobatics.Roll"));
|
/* Check for death */
|
||||||
}
|
if (player.getHealth() - damage >= 1) {
|
||||||
}
|
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER, player);
|
||||||
}
|
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||||
else if(player.getHealth() - event.getDamage() >= 1)
|
|
||||||
{
|
event.setDamage(newDamage);
|
||||||
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, player);
|
|
||||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
if (event.getDamage() <= 0) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gracefulRoll) {
|
||||||
|
player.sendMessage(mcLocale.getString("Acrobatics.GracefulRoll"));
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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){
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user