Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some debugging code to a utility.
- Loading branch information
Showing
2 changed files
with
58 additions
and
18 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
NCPCompat/src/main/java/fr/neatmonster/nocheatplus/logging/DebugUtil.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,55 @@ | ||
package fr.neatmonster.nocheatplus.logging; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
|
||
import fr.neatmonster.nocheatplus.compat.MCAccess; | ||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation; | ||
import fr.neatmonster.nocheatplus.utilities.StringUtil; | ||
|
||
/** | ||
* Some auxiliary specialized static-access methods. | ||
* @author mc_dev | ||
* | ||
*/ | ||
public class DebugUtil { | ||
|
||
/** | ||
* | ||
* @param player | ||
* @param from | ||
* @param to | ||
* @param mcAccess | ||
*/ | ||
public static void outputMoveDebug(final Player player, final PlayerLocation from, final PlayerLocation to, final MCAccess mcAccess) { | ||
final StringBuilder builder = new StringBuilder(250); | ||
final Location loc = player.getLocation(); | ||
builder.append(player.getName()); | ||
builder.append(" " + from.getWorld().getName() + " " + StringUtil.fdec3.format(from.getX()) + (from.getX() == loc.getX() ? "" : ("(" + StringUtil.fdec3.format(loc.getX()) + ")"))); | ||
builder.append(", " + StringUtil.fdec3.format(from.getY()) + (from.getY() == loc.getY() ? "" : ("(" + StringUtil.fdec3.format(loc.getY()) + ")"))); | ||
builder.append(", " + StringUtil.fdec3.format(from.getZ()) + (from.getZ() == loc.getZ() ? "" : ("(" + StringUtil.fdec3.format(loc.getZ()) + ")"))); | ||
builder.append(" -> " + StringUtil.fdec3.format(to.getX()) + ", " + StringUtil.fdec3.format(to.getY()) + ", " + StringUtil.fdec3.format(to.getZ())); | ||
final double jump = mcAccess.getJumpAmplifier(player); | ||
final double speed = mcAccess.getFasterMovementAmplifier(player); | ||
if (speed != Double.NEGATIVE_INFINITY || jump != Double.NEGATIVE_INFINITY){ | ||
builder.append(" (" + (speed != Double.NEGATIVE_INFINITY ? ("speed=" + speed) : "") + (jump != Double.NEGATIVE_INFINITY ? ("jump=" + jump) : "") + ")"); | ||
} | ||
|
||
// // TEMP: Dump block shapes: | ||
// addBlockBelowInfo(builder, from, "\nfrom"); | ||
// addBlockBelowInfo(builder, to, "\nto"); | ||
|
||
System.out.print(builder.toString()); | ||
} | ||
|
||
public static void addBlockBelowInfo(final StringBuilder builder, final PlayerLocation loc, final String tag) { | ||
builder.append(tag + " below id= " + loc.getTypeIdBelow() + " shape=" + Arrays.toString(loc.getBlockCache().getBounds(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()))); | ||
} | ||
|
||
public static void addBlockInfo(final StringBuilder builder, final PlayerLocation loc, final String tag) { | ||
builder.append(tag + " id= " + loc.getTypeId() + " shape=" + Arrays.toString(loc.getBlockCache().getBounds(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); | ||
} | ||
|
||
} |
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