mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 03:02:11 +01:00
SF + set-back: Still use set-back location, don't reset data.
On teleports initiated by NCP set-back location is kept, as well as some parts of the fly data should not be cleared but reset according to the set-back location. Bed checks take into account that there could be a set-back location if ground is not set.
This commit is contained in:
parent
7a70f0e4a2
commit
d59eaaec2f
@ -153,6 +153,25 @@ public class MovingData extends ACheckData {
|
|||||||
clearNoFallData();
|
clearNoFallData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mildly reset the flying data without losing any important information.
|
||||||
|
*
|
||||||
|
* @param setBack
|
||||||
|
*/
|
||||||
|
public void onSetBack(final Location setBack) {
|
||||||
|
// Reset positions
|
||||||
|
resetPositions(teleported);
|
||||||
|
this.setBack = teleported;
|
||||||
|
clearAccounting(); // Might be more safe to do this.
|
||||||
|
// Keep no-fall data.
|
||||||
|
// Fly data: problem is we don't remember the settings for the set back location.
|
||||||
|
// Assume the player to start falling from there rather, or be on ground.
|
||||||
|
survivalFlyLastYDist = Double.MAX_VALUE;
|
||||||
|
// Keep jump amplifier
|
||||||
|
// Keep bunny-hop delay (?)
|
||||||
|
// keep jump phase.
|
||||||
|
}
|
||||||
|
|
||||||
public void clearAccounting() {
|
public void clearAccounting() {
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
hDistSum.clear(now);
|
hDistSum.clear(now);
|
||||||
|
@ -209,9 +209,18 @@ public class MovingListener implements Listener {
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final MovingData data = MovingData.getData(player);
|
final MovingData data = MovingData.getData(player);
|
||||||
|
|
||||||
if (!creativeFly.isEnabled(player) && survivalFly.isEnabled(player) && survivalFly.check(player) && data.ground != null)
|
if (!creativeFly.isEnabled(player) && survivalFly.isEnabled(player) && survivalFly.check(player)) {
|
||||||
// To cancel the event, we simply teleport the player to his last safe location.
|
// To cancel the event, we simply teleport the player to his last
|
||||||
player.teleport(data.ground);
|
// safe location.
|
||||||
|
Location target = null;
|
||||||
|
if (data.ground != null) target = data.ground;
|
||||||
|
else if (data.setBack != null) target = data.setBack;
|
||||||
|
// else target = player.getLocation(); // TODO
|
||||||
|
|
||||||
|
|
||||||
|
if (target != null) player.teleport(target);// TODO: schedule / other measures ?
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -530,13 +539,13 @@ public class MovingListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a player respawns, all information related to the moving checks becomes invalid.
|
* When a player respawns, all information related to the moving checks
|
||||||
|
* becomes invalid.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
* the event
|
* the event
|
||||||
*/
|
*/
|
||||||
@EventHandler(
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerRespawn(final PlayerRespawnEvent event) {
|
public void onPlayerRespawn(final PlayerRespawnEvent event) {
|
||||||
/*
|
/*
|
||||||
* ____ _ ____
|
* ____ _ ____
|
||||||
@ -546,9 +555,14 @@ public class MovingListener implements Listener {
|
|||||||
* |_| |_|\__,_|\__, |\___|_| |_| \_\___||___/ .__/ \__,_| \_/\_/ |_| |_|
|
* |_| |_|\__,_|\__, |\___|_| |_| \_\___||___/ .__/ \__,_| \_/\_/ |_| |_|
|
||||||
* |___/ |_|
|
* |___/ |_|
|
||||||
*/
|
*/
|
||||||
final MovingData data = MovingData.getData(event.getPlayer());
|
final Player player = event.getPlayer();
|
||||||
|
final MovingData data = MovingData.getData(player);
|
||||||
data.clearFlyData();
|
data.clearFlyData();
|
||||||
data.clearMorePacketsData();
|
data.clearMorePacketsData();
|
||||||
|
if (survivalFly.isEnabled(player)) {
|
||||||
|
data.setBack = event.getRespawnLocation();
|
||||||
|
data.ground = event.getRespawnLocation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -560,8 +574,7 @@ public class MovingListener implements Listener {
|
|||||||
* @param event
|
* @param event
|
||||||
* the event
|
* the event
|
||||||
*/
|
*/
|
||||||
@EventHandler(
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
|
||||||
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
||||||
/*
|
/*
|
||||||
* ____ _ _____ _ _
|
* ____ _ _____ _ _
|
||||||
@ -578,17 +591,22 @@ public class MovingListener implements Listener {
|
|||||||
|
|
||||||
// If it was a teleport initialized by NoCheatPlus, do it anyway even if another plugin said "no".
|
// If it was a teleport initialized by NoCheatPlus, do it anyway even if another plugin said "no".
|
||||||
final Location to = event.getTo();
|
final Location to = event.getTo();
|
||||||
if (event.isCancelled() && teleported != null && data.teleported.equals(to)){
|
if (teleported != null && teleported.equals(to)) {
|
||||||
|
// Teleport by NCP.
|
||||||
|
// Prevent cheaters getting rid of flying data (morepackets, other).
|
||||||
// TODO: even more strict enforcing ?
|
// TODO: even more strict enforcing ?
|
||||||
|
if (event.isCancelled()) {
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
event.setTo(teleported);
|
event.setTo(teleported);
|
||||||
event.setFrom(teleported);
|
event.setFrom(teleported);
|
||||||
data.clearFlyData();
|
|
||||||
data.resetPositions(teleported);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Only if it wasn't NoCheatPlus, drop data from more packets check. If it was NoCheatPlus, we don't
|
// Not cancelled but NCP teleport.
|
||||||
// want players to exploit the fly check teleporting to get rid of the "morepackets" data.
|
}
|
||||||
|
// TODO: This could be done on MONITOR.
|
||||||
|
data.onSetBack(teleported);
|
||||||
|
} else {
|
||||||
|
// Only if it wasn't NoCheatPlus, drop data from more packets check.
|
||||||
// TODO: check if to do with cancelled teleports !
|
// TODO: check if to do with cancelled teleports !
|
||||||
data.clearMorePacketsData();
|
data.clearMorePacketsData();
|
||||||
data.clearFlyData();
|
data.clearFlyData();
|
||||||
|
Loading…
Reference in New Issue
Block a user