mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-23 15:11:25 +01:00
Rather use prepareSetBack than setTeleported before set-back.
This commit is contained in:
parent
8eebda863f
commit
1cb9a18174
@ -60,8 +60,12 @@ public class MorePackets extends Check {
|
||||
|
||||
if (!data.hasMorePacketsSetBack()){
|
||||
// TODO: Check if other set-back is appropriate or if to set on other events.
|
||||
if (data.hasSetBack()) data.setMorePacketsSetBack(data.getSetBack(to));
|
||||
else data.setMorePacketsSetBack(from);
|
||||
if (data.hasSetBack()) {
|
||||
data.setMorePacketsSetBack(data.getSetBack(to));
|
||||
}
|
||||
else {
|
||||
data.setMorePacketsSetBack(from);
|
||||
}
|
||||
}
|
||||
|
||||
// Take a packet from the buffer.
|
||||
@ -76,10 +80,8 @@ public class MorePackets extends Check {
|
||||
|
||||
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
||||
// cancel the event.
|
||||
if (executeActions(player, data.morePacketsVL, -data.morePacketsBuffer,
|
||||
MovingConfig.getConfig(player).morePacketsActions)){
|
||||
if (executeActions(player, data.morePacketsVL, -data.morePacketsBuffer, MovingConfig.getConfig(player).morePacketsActions)){
|
||||
newTo = data.getMorePacketsSetBack();
|
||||
data.setTeleported(newTo);
|
||||
}
|
||||
|
||||
}
|
||||
@ -93,23 +95,28 @@ public class MorePackets extends Check {
|
||||
|
||||
// If there was a long pause (maybe server lag?), allow buffer to grow up to 100.
|
||||
if (seconds > 2) {
|
||||
if (data.morePacketsBuffer > 100)
|
||||
data.morePacketsBuffer = 100;
|
||||
} else if (data.morePacketsBuffer > 50)
|
||||
if (data.morePacketsBuffer > 100) {
|
||||
data.morePacketsBuffer = 100;
|
||||
}
|
||||
} else if (data.morePacketsBuffer > 50) {
|
||||
// Only allow growth up to 50.
|
||||
data.morePacketsBuffer = 50;
|
||||
|
||||
}
|
||||
// Set the new "last" time.
|
||||
data.morePacketsLastTime = time;
|
||||
|
||||
// Set the new "setback" location.
|
||||
if (newTo == null) data.setMorePacketsSetBack(from);
|
||||
} else if (data.morePacketsLastTime > time)
|
||||
if (newTo == null) {
|
||||
data.setMorePacketsSetBack(from);
|
||||
}
|
||||
} else if (data.morePacketsLastTime > time) {
|
||||
// Security check, maybe system time changed.
|
||||
data.morePacketsLastTime = time;
|
||||
data.morePacketsLastTime = time;
|
||||
}
|
||||
|
||||
if (newTo == null)
|
||||
return null;
|
||||
if (newTo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Compose a new location based on coordinates of "newTo" and viewing direction of "event.getTo()" to allow the
|
||||
// player to look somewhere else despite getting pulled back by NoCheatPlus.
|
||||
|
@ -282,18 +282,15 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
target = LocUtil.clone(loc);
|
||||
}
|
||||
useLoc.setWorld(null);
|
||||
if (target != null) {
|
||||
// Actually this should not possibly be null, this is a block for "future" purpose, feel free to criticize it.
|
||||
if (sfCheck && cc.sfFallDamage && noFall.isEnabled(player)) {
|
||||
// Check if to deal damage.
|
||||
double y = loc.getY();
|
||||
if (data.hasSetBack()) y = Math.min(y, data.getSetBackY());
|
||||
noFall.checkDamage(player, data, y);
|
||||
}
|
||||
// Teleport.
|
||||
data.setTeleported(target); // Should be enough. | new Location(target.getWorld(), target.getX(), target.getY(), target.getZ(), target.getYaw(), target.getPitch());
|
||||
player.teleport(target, TeleportCause.PLUGIN);// TODO: schedule / other measures ?
|
||||
if (sfCheck && cc.sfFallDamage && noFall.isEnabled(player)) {
|
||||
// Check if to deal damage.
|
||||
double y = loc.getY();
|
||||
if (data.hasSetBack()) y = Math.min(y, data.getSetBackY());
|
||||
noFall.checkDamage(player, data, y);
|
||||
}
|
||||
// Teleport.
|
||||
data.prepareSetBack(target); // Should be enough. | new Location(target.getWorld(), target.getX(), target.getY(), target.getZ(), target.getYaw(), target.getPitch());
|
||||
player.teleport(target, TeleportCause.PLUGIN);// TODO: schedule / other measures ?
|
||||
}
|
||||
else{
|
||||
// Reset bed ...
|
||||
@ -1389,7 +1386,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
final MovingData data = MovingData.getData(player);
|
||||
final Location newTo = enforceLocation(player, player.getLocation(useLoc), data);
|
||||
if (newTo != null) {
|
||||
data.setTeleported(newTo);
|
||||
data.prepareSetBack(newTo);
|
||||
player.teleport(newTo, TeleportCause.PLUGIN);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class VehicleSetBack implements Runnable{
|
||||
final MovingData data = MovingData.getData(player);
|
||||
data.morePacketsVehicleTaskId = -1;
|
||||
try{
|
||||
data.setTeleported(location);
|
||||
data.prepareSetBack(location);
|
||||
TeleportUtil.teleport(vehicle, player, location, debug);
|
||||
}
|
||||
catch(Throwable t){
|
||||
|
@ -23,6 +23,7 @@ public class TeleportUtil {
|
||||
final boolean vehicleTeleported;
|
||||
final boolean playerIsPassenger = player.equals(passenger);
|
||||
if (playerIsPassenger && !vehicle.isDead()){ // && vehicle.equals(player.getVehicle).
|
||||
// TODO: Does VehicleExit fire here !? Consequences?
|
||||
vehicle.eject();
|
||||
vehicleTeleported = vehicle.teleport(location, TeleportCause.PLUGIN);
|
||||
|
||||
@ -34,6 +35,7 @@ public class TeleportUtil {
|
||||
final boolean playerTeleported = player.teleport(location);
|
||||
if (playerIsPassenger && playerTeleported && vehicleTeleported && player.getLocation().distance(vehicle.getLocation(useLoc)) < 1.0){
|
||||
// Somewhat check against tp showing something wrong (< 1.0).
|
||||
// TODO: Does VehicleEnter fire here !? Consequences?
|
||||
vehicle.setPassenger(player);
|
||||
}
|
||||
if (debug){
|
||||
|
Loading…
Reference in New Issue
Block a user