mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Improved AFK Acrobatics prevention mechanism
This commit is contained in:
parent
0aea165a8f
commit
7b3fb46a9a
@ -69,6 +69,7 @@ Version 1.4.07-dev
|
|||||||
! Admin and Party chat prefixes are now customizable
|
! Admin and Party chat prefixes are now customizable
|
||||||
! Changed the color of party leader names in Party chat
|
! Changed the color of party leader names in Party chat
|
||||||
! Improved "Tree Feller" algorithm (Thanks Riking!)
|
! Improved "Tree Feller" algorithm (Thanks Riking!)
|
||||||
|
! Improved AFK Acrobatics prevention mechanism
|
||||||
! Improved profile saving
|
! Improved profile saving
|
||||||
! Improved partial name matcher
|
! Improved partial name matcher
|
||||||
! Improved update checker
|
! Improved update checker
|
||||||
|
@ -430,6 +430,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* AFK Leveling */
|
/* AFK Leveling */
|
||||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||||
|
public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); }
|
||||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||||
|
|
||||||
/* Level Caps */
|
/* Level Caps */
|
||||||
|
@ -23,7 +23,6 @@ public final class Acrobatics {
|
|||||||
|
|
||||||
public static double featherFallXPModifier = ExperienceConfig.getInstance().getFeatherFallXPModifier();
|
public static double featherFallXPModifier = ExperienceConfig.getInstance().getFeatherFallXPModifier();
|
||||||
|
|
||||||
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
|
|
||||||
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
||||||
|
|
||||||
private Acrobatics() {};
|
private Acrobatics() {};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.skills.acrobatics;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -7,6 +8,7 @@ import org.bukkit.entity.LightningStrike;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@ -18,6 +20,9 @@ import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class AcrobaticsManager extends SkillManager {
|
public class AcrobaticsManager extends SkillManager {
|
||||||
|
private int fallTries = 0;
|
||||||
|
Location lastFallLocation;
|
||||||
|
|
||||||
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
|
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
|
||||||
super(mcMMOPlayer, SkillType.ACROBATICS);
|
super(mcMMOPlayer, SkillType.ACROBATICS);
|
||||||
}
|
}
|
||||||
@ -25,7 +30,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
public boolean canRoll() {
|
public boolean canRoll() {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player);
|
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !exploitPrevention() && Permissions.roll(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDodge(Entity damager) {
|
public boolean canDodge(Entity damager) {
|
||||||
@ -93,6 +98,8 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
applyXpGain(calculateRollXP(damage, false));
|
applyXpGain(calculateRollXP(damage, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastFallLocation = player.getLocation();
|
||||||
|
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +125,25 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean exploitPrevention() {
|
||||||
|
if (!Config.getInstance().getAcrobaticsAFKDisabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getPlayer().isInsideVehicle()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location fallLocation = getPlayer().getLocation();
|
||||||
|
|
||||||
|
boolean sameLocation = (lastFallLocation != null && Misc.isNear(lastFallLocation, fallLocation, 2));
|
||||||
|
|
||||||
|
fallTries = sameLocation ? fallTries + 1 : Math.max(fallTries - 1, 0);
|
||||||
|
lastFallLocation = fallLocation;
|
||||||
|
|
||||||
|
return fallTries > Config.getInstance().getAcrobaticsAFKMaxTries();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
|
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
|
||||||
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
|
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
|
||||||
}
|
}
|
||||||
|
@ -231,6 +231,7 @@ Skills:
|
|||||||
Enabled_For_PVP: true
|
Enabled_For_PVP: true
|
||||||
Enabled_For_PVE: true
|
Enabled_For_PVE: true
|
||||||
Prevent_AFK_Leveling: true
|
Prevent_AFK_Leveling: true
|
||||||
|
Max_Tries_At_Same_Location: 3
|
||||||
Prevent_Dodge_Lightning: false
|
Prevent_Dodge_Lightning: false
|
||||||
Prevent_XP_After_Teleport: true
|
Prevent_XP_After_Teleport: true
|
||||||
Level_Cap: 0
|
Level_Cap: 0
|
||||||
|
Loading…
Reference in New Issue
Block a user