Error Test

This commit is contained in:
Daniel Mills 2021-07-22 19:23:31 -04:00
parent 7e08f495a7
commit f0a89e99f5
2 changed files with 55 additions and 12 deletions

View File

@ -561,6 +561,25 @@ public class Iris extends VolmitPlugin implements Listener {
return IrisSettings.get().getGenerator().isMcaPregenerator(); return IrisSettings.get().getGenerator().isMcaPregenerator();
} }
public static void reportErrorChunk(int x, int z, Throwable e) {
if (IrisSettings.get().getGeneral().isDebug()) {
File f = instance.getDataFile("debug", "chunk-errors", "chunk."+ x + "." + z + ".txt");
if (!f.exists()) {
J.attempt(() -> {
PrintWriter pw = new PrintWriter(f);
pw.println("Thread: " + Thread.currentThread().getName());
pw.println("First: " + new Date(M.ms()));
e.printStackTrace(pw);
pw.close();
});
}
Iris.debug("Chunk " + x + "," + z + " Exception Logged: " + e.getClass().getSimpleName() + ": " + C.RESET + "" + C.LIGHT_PURPLE + e.getMessage());
}
}
public static synchronized void reportError(Throwable e) { public static synchronized void reportError(Throwable e) {
if (IrisSettings.get().getGeneral().isDebug()) { if (IrisSettings.get().getGeneral().isDebug()) {
String n = e.getClass().getCanonicalName() + "-" + e.getStackTrace()[0].getClassName() + "-" + e.getStackTrace()[0].getLineNumber(); String n = e.getClass().getCanonicalName() + "-" + e.getStackTrace()[0].getClassName() + "-" + e.getStackTrace()[0].getLineNumber();

View File

@ -71,6 +71,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
public class EngineCompositeGenerator extends ChunkGenerator implements IrisAccess { public class EngineCompositeGenerator extends ChunkGenerator implements IrisAccess {
private static final BlockData ERROR_BLOCK = Material.RED_GLAZED_TERRACOTTA.createBlockData();
private final AtomicReference<EngineCompound> compound = new AtomicReference<>(); private final AtomicReference<EngineCompound> compound = new AtomicReference<>();
private final AtomicBoolean initialized; private final AtomicBoolean initialized;
private final String dimensionQuery; private final String dimensionQuery;
@ -448,6 +449,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
@NotNull @NotNull
@Override @Override
public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) { public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
try
{
PrecisionStopwatch ps = PrecisionStopwatch.start(); PrecisionStopwatch ps = PrecisionStopwatch.start();
TerrainChunk tc = TerrainChunk.create(world, biome); TerrainChunk tc = TerrainChunk.create(world, biome);
IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld(); IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld();
@ -467,6 +470,27 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
return tc.getRaw(); return tc.getRaw();
} }
catch(Throwable e)
{
Iris.error("======================================");
e.printStackTrace();
Iris.reportErrorChunk(x, z, e);
Iris.error("======================================");
ChunkData d = Bukkit.createChunkData(world);
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < 16; j++)
{
d.setBlock(i, 0, j, ERROR_BLOCK);
}
}
return d;
}
}
public void assignHeadlessGenerator(HeadlessGenerator headlessGenerator) { public void assignHeadlessGenerator(HeadlessGenerator headlessGenerator) {
this.headlessGenerator = headlessGenerator; this.headlessGenerator = headlessGenerator;
} }