Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BLEEDING/INSTABLE] Not that much desperate: Random code changes.
- Loading branch information
Showing
8 changed files
with
191 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MoveConsistency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package fr.neatmonster.nocheatplus.checks.moving; | ||
|
||
import org.bukkit.Location; | ||
|
||
import fr.neatmonster.nocheatplus.utilities.TrigUtil; | ||
|
||
/** | ||
* Consistency of a Location/thing concerning a move with a from and a to location. | ||
* @author mc_dev | ||
* | ||
*/ | ||
public enum MoveConsistency { | ||
/** | ||
* Consistent with the to-location. Highest priority. | ||
*/ | ||
TO, | ||
/** | ||
* Consistent with the from-location. | ||
*/ | ||
FROM, | ||
/** | ||
* Not consistent. Lowest priority. | ||
*/ | ||
INCONSISTENT; | ||
|
||
|
||
|
||
public static final double maxDistance = 1.25; | ||
public static final double maxDistanceSq = maxDistance * maxDistance; | ||
|
||
public static MoveConsistency getConsistency(final Location from, final Location to, final Location loc) { | ||
if (to != null && TrigUtil.distanceSquared(to, loc) < maxDistanceSq) { | ||
return TO; | ||
} else if (from != null && TrigUtil.distanceSquared(from, loc) < maxDistanceSq) { | ||
return FROM; | ||
} else { | ||
return INCONSISTENT; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.