mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-04 23:07:44 +01:00
Try to support MonsterEffect.JUMP
This commit is contained in:
parent
fa4ca4a75f
commit
03688f6e86
@ -25,7 +25,10 @@ public interface NoCheatPlayer {
|
|||||||
|
|
||||||
public float getSpeedAmplifier();
|
public float getSpeedAmplifier();
|
||||||
|
|
||||||
|
public float getJumpAmplifier();
|
||||||
|
|
||||||
public boolean isCreative();
|
public boolean isCreative();
|
||||||
|
|
||||||
public ExecutionHistory getExecutionHistory();
|
public ExecutionHistory getExecutionHistory();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
|||||||
public class BlockBreakCheckListener implements Listener, EventManager {
|
public class BlockBreakCheckListener implements Listener, EventManager {
|
||||||
|
|
||||||
private final List<BlockBreakCheck> checks;
|
private final List<BlockBreakCheck> checks;
|
||||||
private final NoCheat plugin;
|
private final NoCheat plugin;
|
||||||
|
|
||||||
public BlockBreakCheckListener(NoCheat plugin) {
|
public BlockBreakCheckListener(NoCheat plugin) {
|
||||||
|
|
||||||
@ -33,14 +33,15 @@ public class BlockBreakCheckListener implements Listener, EventManager {
|
|||||||
this.checks.add(new NoswingCheck(plugin));
|
this.checks.add(new NoswingCheck(plugin));
|
||||||
this.checks.add(new ReachCheck(plugin));
|
this.checks.add(new ReachCheck(plugin));
|
||||||
this.checks.add(new DirectionCheck(plugin));
|
this.checks.add(new DirectionCheck(plugin));
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void blockBreak(final BlockBreakEvent event) {
|
public void blockBreak(final BlockBreakEvent event) {
|
||||||
|
|
||||||
if(event.isCancelled()) return;
|
if(event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
|
|
||||||
@ -78,8 +79,9 @@ public class BlockBreakCheckListener implements Listener, EventManager {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void blockHit(final BlockDamageEvent event) {
|
public void blockHit(final BlockDamageEvent event) {
|
||||||
|
|
||||||
if(event.isCancelled()) return;
|
if(event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
NoCheatPlayer player = plugin.getPlayer(event.getPlayer());
|
NoCheatPlayer player = plugin.getPlayer(event.getPlayer());
|
||||||
BlockBreakData data = BlockBreakCheck.getData(player.getDataStore());
|
BlockBreakData data = BlockBreakCheck.getData(player.getDataStore());
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
|
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
|
||||||
@ -78,8 +77,19 @@ public class FlyingCheck extends MovingCheck {
|
|||||||
|
|
||||||
resultHoriz *= 100;
|
resultHoriz *= 100;
|
||||||
|
|
||||||
|
double jumpAmplifier = player.getJumpAmplifier();
|
||||||
|
if(jumpAmplifier > data.lastJumpAmplifier) {
|
||||||
|
data.lastJumpAmplifier = jumpAmplifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
double speedLimitVertical = ccmoving.flyingSpeedLimitVertical * data.lastJumpAmplifier;
|
||||||
|
|
||||||
|
if(data.from.y >= data.to.y && data.lastJumpAmplifier > 0) {
|
||||||
|
data.lastJumpAmplifier--;
|
||||||
|
}
|
||||||
|
|
||||||
// super simple, just check distance compared to max distance
|
// super simple, just check distance compared to max distance
|
||||||
resultVert = Math.max(0.0D, yDistance - data.vertFreedom - ccmoving.flyingSpeedLimitVertical) * 100;
|
resultVert = Math.max(0.0D, yDistance - data.vertFreedom - speedLimitVertical) * 100;
|
||||||
|
|
||||||
result = resultHoriz + resultVert;
|
result = resultHoriz + resultVert;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ public class MovingData implements DataItem {
|
|||||||
public int morePacketsFailed;
|
public int morePacketsFailed;
|
||||||
|
|
||||||
public int jumpPhase;
|
public int jumpPhase;
|
||||||
|
public double lastJumpAmplifier;
|
||||||
|
|
||||||
public final PreciseLocation runflySetBackPoint = new PreciseLocation();
|
public final PreciseLocation runflySetBackPoint = new PreciseLocation();
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class RunningCheck extends MovingCheck {
|
|||||||
PreciseLocation newToLocation = null;
|
PreciseLocation newToLocation = null;
|
||||||
|
|
||||||
final double resultHoriz = Math.max(0.0D, checkHorizontal(player, data, CheckUtil.isLiquid(fromType) && CheckUtil.isLiquid(toType), horizontalDistance, cc));
|
final double resultHoriz = Math.max(0.0D, checkHorizontal(player, data, CheckUtil.isLiquid(fromType) && CheckUtil.isLiquid(toType), horizontalDistance, cc));
|
||||||
final double resultVert = Math.max(0.0D, checkVertical(data, fromOnGround, toOnGround, cc));
|
final double resultVert = Math.max(0.0D, checkVertical(player, data, fromOnGround, toOnGround, cc));
|
||||||
|
|
||||||
final double result = (resultHoriz + resultVert) * 100;
|
final double result = (resultHoriz + resultVert) * 100;
|
||||||
|
|
||||||
@ -214,21 +214,34 @@ public class RunningCheck extends MovingCheck {
|
|||||||
* Calculate if and how much the player "failed" this check.
|
* Calculate if and how much the player "failed" this check.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private double checkVertical(final MovingData data, final boolean fromOnGround, final boolean toOnGround, final MovingConfig cc) {
|
private double checkVertical(final NoCheatPlayer player, final MovingData data, final boolean fromOnGround, final boolean toOnGround, final MovingConfig cc) {
|
||||||
|
|
||||||
// How much higher did the player move than expected??
|
// How much higher did the player move than expected??
|
||||||
double distanceAboveLimit = 0.0D;
|
double distanceAboveLimit = 0.0D;
|
||||||
|
|
||||||
double limit = data.vertFreedom + cc.jumpheight;
|
double jumpAmplifier = player.getJumpAmplifier();
|
||||||
|
if(jumpAmplifier > data.lastJumpAmplifier) {
|
||||||
|
data.lastJumpAmplifier = jumpAmplifier;
|
||||||
|
}
|
||||||
|
|
||||||
if(data.jumpPhase > jumpingLimit) {
|
double limit = data.vertFreedom + cc.jumpheight;
|
||||||
|
|
||||||
|
limit *= data.lastJumpAmplifier;
|
||||||
|
|
||||||
|
if(data.jumpPhase > jumpingLimit + data.lastJumpAmplifier) {
|
||||||
limit -= (data.jumpPhase - jumpingLimit) * 0.15D;
|
limit -= (data.jumpPhase - jumpingLimit) * 0.15D;
|
||||||
}
|
}
|
||||||
|
|
||||||
distanceAboveLimit = data.to.y - data.runflySetBackPoint.y - limit;
|
distanceAboveLimit = data.to.y - data.runflySetBackPoint.y - limit;
|
||||||
|
|
||||||
if(distanceAboveLimit > 0) {
|
if(distanceAboveLimit > 0) {
|
||||||
data.checknamesuffix = "vertical";
|
data.checknamesuffix = "vertical";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(toOnGround || fromOnGround) {
|
||||||
|
data.lastJumpAmplifier = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return distanceAboveLimit;
|
return distanceAboveLimit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,22 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getJumpAmplifier() {
|
||||||
|
EntityPlayer ep = ((CraftPlayer) player).getHandle();
|
||||||
|
if(ep.hasEffect(MobEffectList.JUMP)) {
|
||||||
|
int amp = ep.getEffect(MobEffectList.JUMP).getAmplifier();
|
||||||
|
// Very rough estimates only
|
||||||
|
if(amp > 20) {
|
||||||
|
return 1.5F * (float) (ep.getEffect(MobEffectList.JUMP).getAmplifier() + 1);
|
||||||
|
} else {
|
||||||
|
return 1.2F * (float) (ep.getEffect(MobEffectList.JUMP).getAmplifier() + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 1.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSprinting() {
|
public boolean isSprinting() {
|
||||||
return player.isSprinting();
|
return player.isSprinting();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user