Handle exceptions using logger

This commit is contained in:
dordsor21 2022-06-20 12:25:34 +01:00
parent 6187569086
commit 802edcba9f
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -34,6 +34,8 @@ import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.HeightMap; import org.bukkit.HeightMap;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@ -52,6 +54,8 @@ import java.util.Set;
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> { public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + BukkitPlotGenerator.class.getSimpleName());
@SuppressWarnings("unused") @SuppressWarnings("unused")
public final boolean PAPER_ASYNC_SAFE = true; public final boolean PAPER_ASYNC_SAFE = true;
@ -130,7 +134,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
try { try {
checkLoaded(world); checkLoaded(world);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOGGER.error("Error attempting to load world into PlotSquared.", e);
} }
ArrayList<BlockPopulator> toAdd = new ArrayList<>(); ArrayList<BlockPopulator> toAdd = new ArrayList<>();
List<BlockPopulator> existing = world.getPopulators(); List<BlockPopulator> existing = world.getPopulators();
@ -206,7 +210,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
try { try {
generate(BlockVector2.at(chunkX, chunkZ), worldInfo.getName(), result, false); generate(BlockVector2.at(chunkX, chunkZ), worldInfo.getName(), result, false);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); LOGGER.error("Error attempting to generate chunk.", e);
} }
} }
@ -319,7 +323,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
generate(BlockVector2.at(x, z), world.getName(), result, true); generate(BlockVector2.at(x, z), world.getName(), result, true);
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); LOGGER.error("Error attempting to load world into PlotSquared.", e);
} }
// Return the result data // Return the result data
return result.getChunkData(); return result.getChunkData();
@ -341,7 +345,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
this.plotGenerator.generateChunk(result, area, biomes); this.plotGenerator.generateChunk(result, area, biomes);
} catch (Throwable e) { } catch (Throwable e) {
// Recover from generator error // Recover from generator error
e.printStackTrace(); LOGGER.error("Error attempting to generate chunk.", e);
} }
ChunkManager.postProcessChunk(loc, result); ChunkManager.postProcessChunk(loc, result);
} }