NoCheatPlus/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/NoFall.java

400 lines
16 KiB
Java
Raw Normal View History

/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.checks.moving.player;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.magic.Magic;
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
import fr.neatmonster.nocheatplus.checks.moving.model.LocationData;
import fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.location.PlayerLocation;
/**
* A check to see if people cheat by tricking the server to not deal them fall damage.
*/
public class NoFall extends Check {
2014-11-25 23:53:03 +01:00
/** For temporary use: LocUtil.clone before passing deeply, call setWorld(null) after use. */
private final Location useLoc = new Location(null, 0, 0, 0);
/**
* Instantiates a new no fall check.
*/
public NoFall() {
super(CheckType.MOVING_NOFALL);
}
2014-11-25 23:53:03 +01:00
/**
* Calculate the damage in hearts from the given fall distance.
* @param fallDistance
* @return
*/
public static final double getDamage(final float fallDistance) {
return fallDistance - Magic.FALL_DAMAGE_DIST;
}
2014-11-25 23:53:03 +01:00
/**
* Deal damage if appropriate. To be used for if the player is on ground
* somehow. Contains checking for skipping conditions (getAllowFlight set +
* configured to skip).
*
* @param mcPlayer
* @param data
* @param y
* @param previousSetBackY
* The set back y from lift-off. If not present:
* Double.NEGATIVE_INFINITY.
*/
private void handleOnGround(final Player player, final double y, final double previousSetBackY,
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
final boolean reallyOnGround, final MovingData data, final MovingConfig cc,
final IPlayerData pData) {
// Damage to be dealt.
final float fallDist = (float) getApplicableFallHeight(player, y, previousSetBackY, data);
final double maxD = getDamage(fallDist);
if (maxD >= Magic.FALL_DAMAGE_MINIMUM) {
// Check skipping conditions.
if (cc.noFallSkipAllowFlight && player.getAllowFlight()) {
data.clearNoFallData();
data.noFallSkipAirCheck = true;
// Not resetting the fall distance here, let Minecraft or the issue tracker deal with that.
}
else {
// TODO: more effects like sounds, maybe use custom event with violation added.
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
if (pData.isDebugActive(type)) {
debug(player, "NoFall deal damage" + (reallyOnGround ? "" : "violation") + ": " + maxD);
}
// TODO: might not be necessary: if (mcPlayer.invulnerableTicks <= 0) [no damage event for resetting]
// TODO: Detect fake fall distance accumulation here as well.
data.noFallSkipAirCheck = true;
dealFallDamage(player, maxD);
}
}
else {
data.clearNoFallData();
player.setFallDistance(0);
}
}
2014-11-25 23:53:03 +01:00
/**
* Estimate the applicable fall height for the given data.
*
* @param player
* @param y
* @param previousSetBackY
* The set back y from lift-off. If not present:
* Double.NEGATIVE_INFINITY.
* @param data
* @return
*/
private static double getApplicableFallHeight(final Player player, final double y,
final double previousSetBackY, final MovingData data) {
//return getDamage(Math.max((float) (data.noFallMaxY - y), Math.max(data.noFallFallDistance, player.getFallDistance())));
final double yDistance = Math.max(data.noFallMaxY - y, data.noFallFallDistance);
if (yDistance > 0.0 && data.jumpAmplifier > 0.0
&& previousSetBackY != Double.NEGATIVE_INFINITY) {
// Fall height counts below previous set-back-y.
// TODO: Likely updating the amplifier after lift-off doesn't make sense.
// TODO: In case of velocity... skip too / calculate max exempt height?
final double correction = data.noFallMaxY - previousSetBackY;
if (correction > 0.0) {
final float effectiveDistance = (float) Math.max(0.0, yDistance - correction);
return effectiveDistance;
}
}
return yDistance;
}
public static double getApplicableFallHeight(final Player player, final double y, final MovingData data) {
return getApplicableFallHeight(player, y,
data.hasSetBack() ? data.getSetBackY() : Double.NEGATIVE_INFINITY, data);
}
/**
* Test if fall damage would be dealt accounting for the given data.
*
* @param player
* @param y
* @param previousSetBackY
* The set back y from lift-off. If not present:
* Double.NEGATIVE_INFINITY.
* @param data
* @return
*/
public boolean willDealFallDamage(final Player player, final double y,
final double previousSetBackY, final MovingData data) {
return getDamage((float) getApplicableFallHeight(player, y,
previousSetBackY, data)) - Magic.FALL_DAMAGE_DIST >= Magic.FALL_DAMAGE_MINIMUM;
}
/**
*
* @param player
* @param minY
* @param reallyOnGround
* @param data
* @param cc
*/
private void adjustFallDistance(final Player player, final double minY, final boolean reallyOnGround, final MovingData data, final MovingConfig cc) {
2014-11-25 23:53:03 +01:00
final float noFallFallDistance = Math.max(data.noFallFallDistance, (float) (data.noFallMaxY - minY));
if (noFallFallDistance >= Magic.FALL_DAMAGE_DIST) {
2014-11-25 23:53:03 +01:00
final float fallDistance = player.getFallDistance();
if (noFallFallDistance - fallDistance >= 0.5f // TODO: Why not always adjust, if greater?
|| noFallFallDistance >= Magic.FALL_DAMAGE_DIST && fallDistance < Magic.FALL_DAMAGE_DIST // Ensure damage.
) {
2014-11-25 23:53:03 +01:00
player.setFallDistance(noFallFallDistance);
}
}
data.clearNoFallData();
2014-11-25 23:53:03 +01:00
}
private void dealFallDamage(final Player player, final double damage) {
if (mcAccess.getHandle().dealFallDamageFiresAnEvent().decide()) {
// TODO: Better decideOptimistically?
mcAccess.getHandle().dealFallDamage(player, damage);
}
else {
final EntityDamageEvent event = BridgeHealth.getEntityDamageEvent(player, DamageCause.FALL, damage);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
// TODO: account for no damage ticks etc.
player.setLastDamageCause(event);
mcAccess.getHandle().dealFallDamage(player, BridgeHealth.getDamage(event));
}
}
// Currently resetting is done from within the damage event handler.
// TODO: MUST detect if event fired at all (...) and override, if necessary. Best probe once per class (with YES).
// data.clearNoFallData();
player.setFallDistance(0);
2014-11-25 23:53:03 +01:00
}
2014-11-25 23:53:03 +01:00
/**
* Checks a player. Expects from and to using cc.yOnGround.
*
* @param player
* the player
* @param from
* the from
* @param to
* the to
* @param previousSetBackY
* The set back y from lift-off. If not present:
* Double.NEGATIVE_INFINITY.
*/
public void check(final Player player, final PlayerLocation pFrom, final PlayerLocation pTo,
final double previousSetBackY,
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
final MovingData data, final MovingConfig cc, final IPlayerData pData) {
2014-11-25 23:53:03 +01:00
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
final boolean debug = pData.isDebugActive(type);
final PlayerMoveData thisMove = data.playerMoves.getCurrentMove();
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
final LocationData from = thisMove.from;
final LocationData to = thisMove.to;
final double fromY = from.getY();
final double toY = to.getY();
2014-11-25 23:53:03 +01:00
final double yDiff = toY - fromY;
final double oldNFDist = data.noFallFallDistance;
// Reset-cond is not touched by yOnGround.
// TODO: Distinguish water depth vs. fall distance ?
/*
* TODO: Account for flags instead (F_FALLDIST_ZERO and
* F_FALLDIST_HALF). Resetcond as trigger: if (resetFrom) { ...
*/
// TODO: Also handle from and to independently (rather fire twice than wait for next time).
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
final boolean fromReset = from.resetCond;
final boolean toReset = to.resetCond;
2014-11-25 23:53:03 +01:00
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
final boolean fromOnGround, toOnGround;
2014-11-25 23:53:03 +01:00
// Adapt yOnGround if necessary (sf uses another setting).
if (yDiff < 0 && cc.yOnGround < cc.noFallyOnGround) {
// In fact this is somewhat heuristic, but it seems to work well.
// Missing on-ground seems to happen with running down pyramids rather.
// TODO: Should be obsolete.
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
adjustYonGround(pFrom, pTo , cc.noFallyOnGround);
fromOnGround = pFrom.isOnGround();
toOnGround = pTo.isOnGround();
} else {
fromOnGround = from.onGround;
toOnGround = to.onGround;
2014-11-25 23:53:03 +01:00
}
// TODO: early returns (...)
2014-11-25 23:53:03 +01:00
final double minY = Math.min(fromY, toY);
2014-11-25 23:53:03 +01:00
if (fromReset) {
// Just reset.
data.clearNoFallData();
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
// Ensure very big/strange moves don't yield violations.
if (toY - fromY <= -Magic.FALL_DAMAGE_DIST) {
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
data.noFallSkipAirCheck = true;
}
}
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
else if (fromOnGround || !toOnGround && thisMove.touchedGround) {
// Check if to deal damage (fall back damage check).
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
touchDown(player, minY, previousSetBackY, data, cc, pData); // Includes the current y-distance on descend!
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
// Ensure very big/strange moves don't yield violations.
if (toY - fromY <= -Magic.FALL_DAMAGE_DIST) {
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
data.noFallSkipAirCheck = true;
}
}
else if (toReset) {
// Just reset.
data.clearNoFallData();
}
else if (toOnGround) {
// Check if to deal damage.
if (yDiff < 0) {
2014-11-25 23:53:03 +01:00
// In this case the player has traveled further: add the difference.
data.noFallFallDistance -= yDiff;
2012-11-15 00:13:58 +01:00
}
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
touchDown(player, minY, previousSetBackY, data, cc, pData);
}
else {
2012-11-15 00:13:58 +01:00
// Ensure fall distance is correct, or "anyway"?
}
2014-11-25 23:53:03 +01:00
// Set reference y for nofall (always).
/*
* TODO: Consider setting this before handleOnGround (at least for
* resetTo). This is after dealing damage, needs to be done differently.
*/
data.noFallMaxY = Math.max(Math.max(fromY, toY), data.noFallMaxY);
2014-11-25 23:53:03 +01:00
// TODO: fall distance might be behind (!)
// TODO: should be the data.noFallMaxY be counted in ?
final float mcFallDistance = player.getFallDistance(); // Note: it has to be fetched here.
// SKIP: data.noFallFallDistance = Math.max(mcFallDistance, data.noFallFallDistance);
2014-11-25 23:53:03 +01:00
// Add y distance.
if (!toReset && !toOnGround && yDiff < 0) {
data.noFallFallDistance -= yDiff;
}
[BLEEDING] Add/move typical flags to past move tracking. Move location-dependent properties from MovingData and MoveData to LocationData. Rough list of related Changes: * Represent from and to positions as LocationData inside of MoveData. * Have flags for onGround, inLiquid and the like in LocationData. * Change noFallAssumeGround to touchedGroundWorkaround within MoveData. * Add touchedGround to MoveData (to|from|workaround). * (Remove involved properties from MovingData and use MoveData.from/to instead.) * Use MoveData and LocationData flags instead of PlayerLocation methods in more places. * Adjust various special case pre-conditions, based on past move data. Other changes made on the fly: * Allow maximum of jump gain and step height for ground -> ground. * Add envelopes for vDistAir after teleport/join/respawn. * Add cases for vdistrel. * Extend logging on teleport (add cause, log set-back too). * Reorder/fix vdistsb workaround checking. * Reorder teleport handling. * Remove small-range workaround for teleport [uncertain effect]. Immediate future follow ups: * Attempt to only accept PlayerLocation for various setPositions methods in MovingData (ensure to set MoveData with extra properties + simplify/cleanup (public) methods with MoveData/LocationData). * Relate to past move tracking for more workarounds, either to confine pre-conditions more (inLiquid instead of toWasReset~somehow), or just to be able to track a false positive at all (thisMove + 2 past moves needed). * (Fixes, etc.) Distant future follow-up: * Somehow merge with PlayerLocation, e.g. using LocationData inside PlayerLocation internally, which means changing raw types to Object versions, just like it's done inside of PlayerLocation right now. * Possibly PlayerLocation is transformed to static methods with BlockCache and LocationData as input. Expected trouble: * New/old false positives, due to replacing the fromWasReset and toWasReset by more distinct flags from past move tracking. * A workaround may have prevented other false positives unintentionally, e.g. had been intended for liquid, but the to/fromWasReset flags previously did include ground/noFallAssumeGround, thus the workaround will not cover that case anymore, after the change. * Forgetting something like checking touchedGround and to/from.onGround or similar as a replacement for xyWasReset. * Mixing up thisMove and lastMove for touchedGround. * Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-26 21:57:39 +01:00
else if (cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || thisMove.touchedGround) && yDiff >= 0)) {
2014-11-25 23:53:03 +01:00
final double max = Math.max(data.noFallFallDistance, mcFallDistance);
if (max > 0.0 && max < 0.75) { // (Ensure this does not conflict with deal-damage set to false.)
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
if (debug) {
debug(player, "NoFall: Reset fall distance (anticriticals): mc=" + mcFallDistance +" / nf=" + data.noFallFallDistance);
2014-11-25 23:53:03 +01:00
}
if (data.noFallFallDistance > 0) {
2014-11-25 23:53:03 +01:00
data.noFallFallDistance = 0;
}
if (mcFallDistance > 0f) {
player.setFallDistance(0f);
2014-11-25 23:53:03 +01:00
}
}
}
2014-11-25 23:53:03 +01:00
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
if (debug) {
debug(player, "NoFall: mc=" + mcFallDistance +" / nf=" + data.noFallFallDistance + (oldNFDist < data.noFallFallDistance ? " (+" + (data.noFallFallDistance - oldNFDist) + ")" : "") + " | ymax=" + data.noFallMaxY);
}
2014-11-25 23:53:03 +01:00
}
2014-11-25 23:53:03 +01:00
/**
* Called during check.
*
* @param player
* @param minY
* @param previousSetBackY
* The set back y from lift-off. If not present:
* Double.NEGATIVE_INFINITY.
* @param data
* @param cc
*/
private void touchDown(final Player player, final double minY, final double previousSetBackY,
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
final MovingData data, final MovingConfig cc, IPlayerData pData) {
if (cc.noFallDealDamage) {
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
handleOnGround(player, minY, previousSetBackY, true, data, cc, pData);
}
else {
adjustFallDistance(player, minY, true, data, cc);
}
}
2014-11-25 23:53:03 +01:00
/**
* Set yOnGround for from and to, if needed, should be obsolete.
* @param from
* @param to
* @param cc
*/
private void adjustYonGround(final PlayerLocation from, final PlayerLocation to, final double yOnGround) {
if (!from.isOnGround()) {
2014-11-25 23:53:03 +01:00
from.setyOnGround(yOnGround);
}
if (!to.isOnGround()) {
2014-11-25 23:53:03 +01:00
to.setyOnGround(yOnGround);
}
}
/**
* Quit or kick: adjust fall distance if necessary.
* @param player
*/
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
public void onLeave(final Player player, final MovingData data,
final IPlayerData pData) {
final float fallDistance = player.getFallDistance();
// TODO: Might also detect too high mc fall dist.
if (data.noFallFallDistance > fallDistance) {
2014-11-25 23:53:03 +01:00
final double playerY = player.getLocation(useLoc).getY();
useLoc.setWorld(null);
if (player.isFlying() || player.getGameMode() == GameMode.CREATIVE
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
|| player.getAllowFlight()
&& pData.getGenericInstance(MovingConfig.class).noFallSkipAllowFlight) {
2014-11-25 23:53:03 +01:00
// Forestall potential issues with flying plugins.
player.setFallDistance(0f);
data.noFallFallDistance = 0f;
data.noFallMaxY = playerY;
} else {
// Might use tolerance, might log, might use method (compare: MovingListener.onEntityDamage).
// Might consider triggering violations here as well.
final float yDiff = (float) (data.noFallMaxY - playerY);
final float maxDist = Math.max(yDiff, data.noFallFallDistance);
player.setFallDistance(maxDist);
2014-11-25 23:53:03 +01:00
}
}
}
/**
* This is called if a player fails a check and gets set back, to avoid using that to avoid fall damage the player might be dealt damage here.
* @param player
* @param data
*/
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
public void checkDamage(final Player player, final double y,
final MovingData data, final IPlayerData pData) {
final MovingConfig cc = pData.getGenericInstance(MovingConfig.class);
2014-11-25 23:53:03 +01:00
// Deal damage.
handleOnGround(player, y, data.hasSetBack() ? data.getSetBackY() : Double.NEGATIVE_INFINITY,
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
false, data, cc, pData);
2014-12-11 00:22:08 +01:00
}
2014-11-25 23:53:03 +01:00
}