use of fr.neatmonster.nocheatplus.players.IPlayerData in project NoCheatPlus by NoCheatPlus.
the class MovingListener method onPlayerPortalLowest.
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerPortalLowest(final PlayerPortalEvent event) {
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(event.getPlayer());
if (MovingUtil.hasScheduledPlayerSetBack(player)) {
if (pData.isDebugActive(checkType)) {
debug(player, "[PORTAL] Prevent use, due to a scheduled set back.");
}
event.setCancelled(true);
}
}
use of fr.neatmonster.nocheatplus.players.IPlayerData in project NoCheatPlus by NoCheatPlus.
the class MovingListener method playerJoins.
@Override
public void playerJoins(final Player player) {
final IPlayerData pData = DataManager.getPlayerData(player);
dataOnJoin(player, player.getLocation(useLoc), false, pData.getGenericInstance(MovingData.class), pData.getGenericInstance(MovingConfig.class), pData.isDebugActive(checkType));
// Cleanup.
useLoc.setWorld(null);
}
use of fr.neatmonster.nocheatplus.players.IPlayerData in project NoCheatPlus by NoCheatPlus.
the class MovingListener method onPlayerRespawn.
/**
* When a player respawns, all information related to the moving checks
* becomes invalid.
*
* @param event
* the event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerRespawn(final PlayerRespawnEvent event) {
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
final MovingData data = pData.getGenericInstance(MovingData.class);
// TODO: Prevent/cancel scheduled teleport (use PlayerData/task for teleport, or a sequence count).
data.clearMostMovingCheckData();
// To force dataOnJoin to set it to loc.
data.resetSetBack();
// Handle respawn like join.
dataOnJoin(player, event.getRespawnLocation(), true, data, pData.getGenericInstance(MovingConfig.class), pData.isDebugActive(checkType));
// Patch up issues.
if (Bridge1_9.hasGetItemInOffHand() && player.isBlocking()) {
// Attempt to fix server-side-only blocking after respawn.
redoShield(player);
}
}
use of fr.neatmonster.nocheatplus.players.IPlayerData in project NoCheatPlus by NoCheatPlus.
the class MovingListener method handleEntityToggleGlideEvent.
/**
* @param entity
* @param isGliding
* @return True, if the event is to be cancelled.
*/
private boolean handleEntityToggleGlideEvent(final Entity entity, final boolean isGliding) {
// Ignore non players.
if (!(entity instanceof Player)) {
return false;
}
final Player player = (Player) entity;
if (isGliding && !Bridge1_9.isGlidingWithElytra(player)) {
// Includes check for elytra item.
final PlayerMoveInfo info = aux.usePlayerMoveInfo();
// Only restrict very near ground.
info.set(player, player.getLocation(info.useLoc), null, 0.001);
final IPlayerData pData = DataManager.getPlayerData(player);
final MovingData data = pData.getGenericInstance(MovingData.class);
final boolean res = !MovingUtil.canLiftOffWithElytra(player, info.from, data);
info.cleanup();
aux.returnPlayerMoveInfo(info);
if (res && pData.isDebugActive(checkType)) {
debug(player, "Prevent toggle glide on.");
}
return res;
}
return false;
}
use of fr.neatmonster.nocheatplus.players.IPlayerData in project NoCheatPlus by NoCheatPlus.
the class MovingListener method onPlayerTeleportMonitor.
/**
* MONITOR: Adjust data to what happened.
*
* @param event
*/
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onPlayerTeleportMonitor(final PlayerTeleportEvent event) {
// Evaluate result and adjust data.
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
final MovingData data = pData.getGenericInstance(MovingData.class);
// Invalidate first-move thing.
// TODO: Might conflict with 'moved wrongly' on join.
data.joinOrRespawn = false;
// Special cases.
final Location to = event.getTo();
if (event.isCancelled()) {
onPlayerTeleportMonitorCancelled(player, event, to, data, pData);
return;
} else if (to == null) {
// Weird event.
onPlayerTeleportMonitorNullTarget(player, event, to, data, pData);
return;
}
final MovingConfig cc = pData.getGenericInstance(MovingConfig.class);
// Detect our own player set backs.
if (data.hasTeleported() && onPlayerTeleportMonitorHasTeleported(player, event, to, data, cc, pData)) {
return;
}
// Skip extra data adjustments during special teleport, e.g. vehicle set back.
boolean skipExtras = false;
// Detect our own vehicle set backs (...).
if (data.isVehicleSetBack) {
// Uncertain if this is vehicle leave or vehicle enter.
if (event.getCause() != BridgeMisc.TELEPORT_CAUSE_CORRECTION_OF_POSITION) {
// TODO: Unexpected, what now?
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().warning(Streams.STATUS, CheckUtils.getLogMessagePrefix(player, CheckType.MOVING_VEHICLE) + "Unexpected teleport cause on vehicle set back: " + event.getCause());
}
// TODO: Consider to verify, if this is somewhere near the vehicle as expected (might need storing more data for a set back).
skipExtras = true;
}
// Normal teleport
final double fallDistance = data.noFallFallDistance;
// final LiftOffEnvelope oldEnv = data.liftOffEnvelope; // Remember for workarounds.
data.clearFlyData();
data.clearPlayerMorePacketsData();
data.setSetBack(to);
// Important against concurrent modification exception.
data.sfHoverTicks = -1;
if (cc.loadChunksOnTeleport) {
MovingUtil.ensureChunksLoaded(player, to, "teleport", data, cc, pData);
}
aux.resetPositionsAndMediumProperties(player, to, data, cc);
// TODO: Decide to remove the LiftOffEnvelope thing completely.
// if (TrigUtil.maxDistance(from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ()) <= 12.0) {
// // TODO: Might happen with bigger distances (mainly ender pearl thrown at others).
// // Keep old lift-off envelope.
// data.liftOffEnvelope = oldEnv;
// }
// Reset stuff.
// TODO: Not sure.
Combined.resetYawRate(player, to.getYaw(), System.currentTimeMillis(), true, pData);
data.resetTeleported();
if (!skipExtras) {
// TODO: Detect transition from valid flying that needs resetting the fall distance.
if (event.getCause() == TeleportCause.UNKNOWN) {
// Always keep fall damage.
player.setFallDistance((float) fallDistance);
data.noFallFallDistance = (float) fallDistance;
} else if (fallDistance > 1.0 && fallDistance - player.getFallDistance() > 0.0) {
// Reset fall distance if set so in the config.
if (!cc.noFallTpReset) {
// (Set fall distance if set to not reset.)
player.setFallDistance((float) fallDistance);
data.noFallFallDistance = (float) fallDistance;
} else if (fallDistance >= Magic.FALL_DAMAGE_DIST) {
data.noFallSkipAirCheck = true;
}
}
if (event.getCause() == TeleportCause.ENDER_PEARL) {
// Prevent NoFall violations for ender-pearls.
data.noFallSkipAirCheck = true;
}
}
// Cross world teleportation issues with the end.
final Location from = event.getFrom();
if (from != null && // Currently only related to this.
event.getCause() == TeleportCause.END_PORTAL && !from.getWorld().getName().equals(to.getWorld().getName())) {
// Less java, though.
// Remember the position teleported from.
data.crossWorldFrom = new SimplePositionWithLook(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
} else {
// Reset last cross world position.
data.crossWorldFrom = null;
}
// Log.
if (pData.isDebugActive(checkType)) {
debugTeleportMessage(player, event, "(normal)", to);
}
}
Aggregations