mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 11:10:05 +01:00
[BREAKING] Rename fields from morePacketsVehicle... to vehicle...
This commit is contained in:
parent
a8954ad458
commit
b6228e417e
@ -101,8 +101,8 @@ public class MovingConfig extends ACheckConfig {
|
||||
public final double morePacketsBurstEPM;
|
||||
public final ActionList morePacketsActions;
|
||||
|
||||
public final boolean morePacketsVehicleCheck;
|
||||
public final ActionList morePacketsVehicleActions;
|
||||
public final boolean vehicleMorePacketsCheck;
|
||||
public final ActionList vehicleMorePacketsActions;
|
||||
|
||||
public final boolean noFallCheck;
|
||||
/** Deal damage instead of Minecraft, whenever a player is judged to be on ground. */
|
||||
@ -217,8 +217,8 @@ public class MovingConfig extends ACheckConfig {
|
||||
morePacketsBurstEPM = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM);
|
||||
morePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS);
|
||||
|
||||
morePacketsVehicleCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK);
|
||||
morePacketsVehicleActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETSVEHICLE_ACTIONS,
|
||||
vehicleMorePacketsCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK);
|
||||
vehicleMorePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETSVEHICLE_ACTIONS,
|
||||
Permissions.MOVING_MOREPACKETS);
|
||||
|
||||
noFallCheck = config.getBoolean(ConfPaths.MOVING_NOFALL_CHECK);
|
||||
@ -324,7 +324,7 @@ public class MovingConfig extends ACheckConfig {
|
||||
case MOVING_MOREPACKETS:
|
||||
return morePacketsCheck;
|
||||
case MOVING_VEHICLE_MOREPACKETS:
|
||||
return morePacketsVehicleCheck;
|
||||
return vehicleMorePacketsCheck;
|
||||
case MOVING_CREATIVEFLY:
|
||||
return creativeFlyCheck;
|
||||
default:
|
||||
|
@ -195,11 +195,11 @@ public class MovingData extends ACheckData {
|
||||
private Location morePacketsSetback = null;
|
||||
|
||||
// Data of the more packets vehicle check.
|
||||
public int morePacketsVehicleBuffer = 50;
|
||||
public long morePacketsVehicleLastTime;
|
||||
private Location morePacketsVehicleSetback = null;
|
||||
/** Task id of the morepackets set-back task. */
|
||||
public int morePacketsVehicleTaskId = -1;
|
||||
public int vehicleMorePacketsBuffer = 50;
|
||||
public long vehicleMorePacketsLastTime;
|
||||
private Location vehicleMorePacketsSetback = null;
|
||||
/** Task id of the vehicle set-back task. */
|
||||
public int vehicleSetBackTaskId = -1;
|
||||
|
||||
|
||||
// Data of the no fall check.
|
||||
@ -330,7 +330,7 @@ public class MovingData extends ACheckData {
|
||||
*/
|
||||
public void onSetBack(final PlayerLocation setBack) {
|
||||
// Reset positions (a teleport should follow, though).
|
||||
this.morePacketsSetback = this.morePacketsVehicleSetback = null;
|
||||
this.morePacketsSetback = this.vehicleMorePacketsSetback = null;
|
||||
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.
|
||||
@ -427,7 +427,7 @@ public class MovingData extends ACheckData {
|
||||
if (setBack != null && worldName.equalsIgnoreCase(setBack.getWorld().getName())) {
|
||||
clearFlyData();
|
||||
}
|
||||
if (morePacketsSetback != null && worldName.equalsIgnoreCase(morePacketsSetback.getWorld().getName()) || morePacketsVehicleSetback != null && worldName.equalsIgnoreCase(morePacketsVehicleSetback.getWorld().getName())) {
|
||||
if (morePacketsSetback != null && worldName.equalsIgnoreCase(morePacketsSetback.getWorld().getName()) || vehicleMorePacketsSetback != null && worldName.equalsIgnoreCase(vehicleMorePacketsSetback.getWorld().getName())) {
|
||||
clearMorePacketsData();
|
||||
clearNoFallData(); // just in case.
|
||||
}
|
||||
@ -475,7 +475,7 @@ public class MovingData extends ACheckData {
|
||||
*/
|
||||
public void clearMorePacketsData() {
|
||||
morePacketsSetback = null;
|
||||
morePacketsVehicleSetback = null;
|
||||
vehicleMorePacketsSetback = null;
|
||||
// TODO: Also reset other data ?
|
||||
}
|
||||
|
||||
@ -618,29 +618,29 @@ public class MovingData extends ACheckData {
|
||||
}
|
||||
|
||||
public boolean hasMorePacketsVehicleSetBack() {
|
||||
return morePacketsVehicleSetback != null;
|
||||
return vehicleMorePacketsSetback != null;
|
||||
}
|
||||
|
||||
public final void setMorePacketsVehicleSetBack(final PlayerLocation loc) {
|
||||
if (morePacketsVehicleSetback == null) {
|
||||
morePacketsVehicleSetback = loc.getLocation();
|
||||
if (vehicleMorePacketsSetback == null) {
|
||||
vehicleMorePacketsSetback = loc.getLocation();
|
||||
}
|
||||
else {
|
||||
LocUtil.set(morePacketsVehicleSetback, loc);
|
||||
LocUtil.set(vehicleMorePacketsSetback, loc);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setMorePacketsVehicleSetBack(final Location loc) {
|
||||
if (morePacketsVehicleSetback == null) {
|
||||
morePacketsVehicleSetback = LocUtil.clone(loc);
|
||||
if (vehicleMorePacketsSetback == null) {
|
||||
vehicleMorePacketsSetback = LocUtil.clone(loc);
|
||||
}
|
||||
else {
|
||||
LocUtil.set(morePacketsVehicleSetback, loc);
|
||||
LocUtil.set(vehicleMorePacketsSetback, loc);
|
||||
}
|
||||
}
|
||||
|
||||
public final Location getMorePacketsVehicleSetBack() {
|
||||
return LocUtil.clone(morePacketsVehicleSetback);
|
||||
return LocUtil.clone(vehicleMorePacketsSetback);
|
||||
}
|
||||
|
||||
public final void resetTeleported() {
|
||||
@ -1034,7 +1034,7 @@ public class MovingData extends ACheckData {
|
||||
public void handleTimeRanBackwards() {
|
||||
final long time = System.currentTimeMillis();
|
||||
timeSprinting = Math.min(timeSprinting, time);
|
||||
morePacketsVehicleLastTime = Math.min(morePacketsVehicleLastTime, time);
|
||||
vehicleMorePacketsLastTime = Math.min(vehicleMorePacketsLastTime, time);
|
||||
sfCobwebTime = Math.min(sfCobwebTime, time);
|
||||
sfVLTime = Math.min(sfVLTime, time);
|
||||
if (trace != null) {
|
||||
|
@ -29,7 +29,7 @@ public class VehicleSetBack implements Runnable{
|
||||
@Override
|
||||
public void run() {
|
||||
final MovingData data = MovingData.getData(player);
|
||||
data.morePacketsVehicleTaskId = -1;
|
||||
data.vehicleSetBackTaskId = -1;
|
||||
try{
|
||||
data.prepareSetBack(location);
|
||||
TeleportUtil.teleport(vehicle, player, location, debug);
|
||||
|
@ -54,64 +54,64 @@ public class MorePacketsVehicle extends Check {
|
||||
if (!data.hasMorePacketsVehicleSetBack()){
|
||||
// TODO: Check if other set-back is appropriate or if to set on other events.
|
||||
data.setMorePacketsVehicleSetBack(from);
|
||||
if (data.morePacketsVehicleTaskId != -1) {
|
||||
if (data.vehicleSetBackTaskId != -1) {
|
||||
// TODO: Set back outdated or not?
|
||||
Bukkit.getScheduler().cancelTask(data.morePacketsVehicleTaskId);
|
||||
Bukkit.getScheduler().cancelTask(data.vehicleSetBackTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
// Take a packet from the buffer.
|
||||
data.morePacketsVehicleBuffer--;
|
||||
data.vehicleMorePacketsBuffer--;
|
||||
|
||||
if (data.morePacketsVehicleTaskId != -1){
|
||||
if (data.vehicleSetBackTaskId != -1){
|
||||
// Short version !
|
||||
return data.getMorePacketsVehicleSetBack();
|
||||
}
|
||||
|
||||
// Player used up buffer, they fail the check.
|
||||
if (data.morePacketsVehicleBuffer < 0) {
|
||||
if (data.vehicleMorePacketsBuffer < 0) {
|
||||
|
||||
// Increment violation level.
|
||||
data.morePacketsVehicleVL = -data.morePacketsVehicleBuffer;
|
||||
data.morePacketsVehicleVL = -data.vehicleMorePacketsBuffer;
|
||||
|
||||
// Execute whatever actions are associated with this check and the violation level and find out if we should
|
||||
// cancel the event.
|
||||
final ViolationData vd = new ViolationData(this, player, data.morePacketsVehicleVL, -data.morePacketsVehicleBuffer, cc.morePacketsVehicleActions);
|
||||
final ViolationData vd = new ViolationData(this, player, data.morePacketsVehicleVL, -data.vehicleMorePacketsBuffer, cc.vehicleMorePacketsActions);
|
||||
if (data.debug || vd.needsParameters()) {
|
||||
vd.setParameter(ParameterName.PACKETS, Integer.toString(-data.morePacketsVehicleBuffer));
|
||||
vd.setParameter(ParameterName.PACKETS, Integer.toString(-data.vehicleMorePacketsBuffer));
|
||||
}
|
||||
if (executeActions(vd).willCancel()){
|
||||
newTo = data.getMorePacketsVehicleSetBack();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.morePacketsVehicleLastTime + 1000 < time) {
|
||||
if (data.vehicleMorePacketsLastTime + 1000 < time) {
|
||||
// More than 1 second elapsed, but how many?
|
||||
final double seconds = (time - data.morePacketsVehicleLastTime) / 1000D;
|
||||
final double seconds = (time - data.vehicleMorePacketsLastTime) / 1000D;
|
||||
|
||||
// For each second, fill the buffer.
|
||||
data.morePacketsVehicleBuffer += packetsPerTimeframe * seconds;
|
||||
data.vehicleMorePacketsBuffer += packetsPerTimeframe * seconds;
|
||||
|
||||
// If there was a long pause (maybe server lag?), allow buffer to grow up to 100.
|
||||
if (seconds > 2) {
|
||||
if (data.morePacketsVehicleBuffer > 100) {
|
||||
data.morePacketsVehicleBuffer = 100;
|
||||
if (data.vehicleMorePacketsBuffer > 100) {
|
||||
data.vehicleMorePacketsBuffer = 100;
|
||||
}
|
||||
} else if (data.morePacketsVehicleBuffer > 50) {
|
||||
} else if (data.vehicleMorePacketsBuffer > 50) {
|
||||
// Only allow growth up to 50.
|
||||
data.morePacketsVehicleBuffer = 50;
|
||||
data.vehicleMorePacketsBuffer = 50;
|
||||
}
|
||||
|
||||
// Set the new "last" time.
|
||||
data.morePacketsVehicleLastTime = time;
|
||||
data.vehicleMorePacketsLastTime = time;
|
||||
|
||||
// Set the new "setback" location.
|
||||
if (newTo == null) {
|
||||
data.setMorePacketsVehicleSetBack(from);
|
||||
}
|
||||
} else if (data.morePacketsVehicleLastTime > time) {
|
||||
} else if (data.vehicleMorePacketsLastTime > time) {
|
||||
// Security check, maybe system time changed.
|
||||
data.morePacketsVehicleLastTime = time;
|
||||
data.vehicleMorePacketsLastTime = time;
|
||||
}
|
||||
|
||||
if (newTo == null) {
|
||||
|
@ -196,13 +196,14 @@ public class VehicleChecks extends CheckListener {
|
||||
}
|
||||
|
||||
// Schedule a set-back?
|
||||
if (newTo != null && data.morePacketsVehicleTaskId == -1) {
|
||||
if (newTo != null && data.vehicleSetBackTaskId == -1) {
|
||||
// Schedule a delayed task to teleport back the vehicle with the player.
|
||||
// (Only schedule if not already scheduled.)
|
||||
// TODO: Might log debug if skipping.
|
||||
// TODO: Problem: scheduling allows a lot of things to happen until the task is run. Thus control about some things might be necessary.
|
||||
// TODO: Reset on world changes or not?
|
||||
data.morePacketsVehicleTaskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new VehicleSetBack(vehicle, player, newTo, data.debug));
|
||||
data.vehicleSetBackTaskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new VehicleSetBack(vehicle, player, newTo, data.debug));
|
||||
// TODO: Handle scheduling failure.
|
||||
}
|
||||
useLoc.setWorld(null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user