Adjust available build parameters: TEST_LEVEL and DEBUG_LEVEL
Not yet too much in use, though.
This commit is contained in:
parent
50ebbb01fb
commit
31faf7f11e
|
@ -57,8 +57,12 @@ Version updating is done for NCPPlugin mainly, expect the other poms version to
|
|||
<value>!!! THIS FILE IS AUTO GENERATED, ANY MANUAL CHANGES TO IT WILL GET LOST !!!</value>
|
||||
</replacement>
|
||||
<replacement>
|
||||
<token>@EXTENSIVE_TESTING@</token>
|
||||
<value>${EXTENSIVE_TESTING}</value>
|
||||
<token>@TEST_LEVEL@</token>
|
||||
<value>${TEST_LEVEL}</value>
|
||||
</replacement>
|
||||
<replacement>
|
||||
<token>@DEBUG_LEVEL@</token>
|
||||
<value>${DEBUG_LEVEL}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
|
|
|
@ -43,11 +43,20 @@ public class BuildParameters {
|
|||
else return ResourceUtil.getBoolean(input, preset);
|
||||
}
|
||||
|
||||
public static Integer getInteger(String path, Integer preset){
|
||||
String input = fileContents.get(path);
|
||||
if (input == null) return preset;
|
||||
else return ResourceUtil.getInteger(input, preset);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// Public members.
|
||||
//////////////////////
|
||||
|
||||
/** Extend testing amount. */
|
||||
public static final boolean extensiveTesting = getBoolean("EXTENSIVE_TESTING", false);
|
||||
/** Test level: more testing for higher levels. */
|
||||
public static final int testLevel = getInteger("TEST_LEVEL", 0);
|
||||
|
||||
/** Debug level: more debug output for higher levels. */
|
||||
public static final int debugLevel = getInteger("DEBUG_LEVEL", 0);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,14 +10,6 @@ import java.util.Map;
|
|||
|
||||
public class ResourceUtil {
|
||||
|
||||
public static Boolean getBoolean(String input, Boolean preset){
|
||||
if (input == null) return preset;
|
||||
input = input.trim().toLowerCase();
|
||||
if (input.matches("1|true|yes")) return true;
|
||||
else if (input.matches("0|false|no")) return false;
|
||||
else return preset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Might have a newline at the end.<br>
|
||||
* TODO: Move to other utility.
|
||||
|
@ -84,4 +76,23 @@ public class ResourceUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean getBoolean(String input, Boolean preset){
|
||||
if (input == null) return preset;
|
||||
input = input.trim().toLowerCase();
|
||||
if (input.matches("1|true|yes")) return true;
|
||||
else if (input.matches("0|false|no")) return false;
|
||||
else return preset;
|
||||
}
|
||||
|
||||
|
||||
public static Integer getInteger(String input, Integer preset) {
|
||||
if (input == null) return preset;
|
||||
try{
|
||||
return Integer.parseInt(input);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
}
|
||||
return preset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# @GENERATED_NOTE@
|
||||
# These parameters are filled in during building (maven), they are not strictly needed.
|
||||
# Replacement mappings are defined in the pom.xml.
|
||||
EXTENSIVE_TESTING=@EXTENSIVE_TESTING@
|
||||
TEST_LEVEL=@TEST_LEVEL@
|
||||
DEBUG_LEVEL=@DEBUG_LEVEL@
|
|
@ -263,7 +263,7 @@ public class TestCoordMap {
|
|||
|
||||
final Random random = new Random(System.nanoTime() - (System.currentTimeMillis() % 2 == 1 ? 37 : 137));
|
||||
|
||||
final boolean e = BuildParameters.extensiveTesting;
|
||||
final boolean e = BuildParameters.testLevel > 0;
|
||||
|
||||
final int n = e ? 40000 : 6000; // Number of coordinates.
|
||||
final int max = 800; // Coordinate maximum.
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.build.BuildParameters;
|
||||
|
||||
/**
|
||||
* Some auxiliary specialized static-access methods.
|
||||
|
@ -37,19 +38,23 @@ public class DebugUtil {
|
|||
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");
|
||||
|
||||
if (BuildParameters.debugLevel > 0){
|
||||
if (from.getTypeId() != 0) addBlockInfo(builder, from, "\nfrom");
|
||||
if (from.getTypeIdBelow() != 0) addBlockBelowInfo(builder, from, "\nfrom");
|
||||
if (!from.isOnGround() && from.isOnGround(0.5)) builder.append(" (ground within 0.5)");
|
||||
if (to.getTypeId() != 0) addBlockInfo(builder, to, "\nto");
|
||||
if (to.getTypeIdBelow() != 0) addBlockBelowInfo(builder, to, "\nto");
|
||||
if (!to.isOnGround() && to.isOnGround(0.5)) builder.append(" (ground within 0.5)");
|
||||
}
|
||||
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() + "data=" + loc.getData(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()) + " shape=" + Arrays.toString(loc.getBlockCache().getBounds(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ())));
|
||||
builder.append(tag + " below id= " + loc.getTypeIdBelow() + " data=" + loc.getData(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()) + " 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() + "data=" + loc.getData() + " shape=" + Arrays.toString(loc.getBlockCache().getBounds(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
|
||||
builder.append(tag + " id= " + loc.getTypeId() + " data=" + loc.getData() + " shape=" + Arrays.toString(loc.getBlockCache().getBounds(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ public class TestRayTracing {
|
|||
checkConsistency(coords);
|
||||
}
|
||||
|
||||
final boolean e = BuildParameters.extensiveTesting;
|
||||
final boolean e = BuildParameters.testLevel > 0;
|
||||
|
||||
// Random tests.
|
||||
for (int i = 0; i < (e ? 50000000 : 100000); i++){
|
||||
|
|
Loading…
Reference in New Issue