mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-10 09:46:24 +00:00
Migrate logging to SLF4J
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
@@ -14,7 +14,7 @@ import com.dfsek.terra.api.world.generator.Palette;
|
||||
public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
@Value("slant")
|
||||
@Default
|
||||
private final @Meta SlantHolder slant;
|
||||
private @Meta SlantHolder slant;
|
||||
@Value("palette")
|
||||
private @Meta PaletteHolder palette;
|
||||
@Value("ocean.level")
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.dfsek.terra.addons.chunkgenerator.generation.generators;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -30,6 +32,8 @@ import com.dfsek.terra.api.world.generator.Sampler;
|
||||
|
||||
|
||||
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private static final Logger logger = LoggerFactory.getLogger(NoiseChunkGenerator3D.class);
|
||||
|
||||
private final ConfigPack configPack;
|
||||
private final TerraPlugin main;
|
||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||
@@ -87,7 +91,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
|
||||
if(paletteInfo == null) {
|
||||
main.logger().info("null palette: " + biome.getID());
|
||||
logger.info("null palette: {}", biome.getID());
|
||||
}
|
||||
|
||||
GenerationSettings generationSettings = biome.getGenerator();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.dfsek.terra.addons.structure.command.structure;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
@@ -28,6 +31,8 @@ import com.dfsek.terra.api.vector.Vector3;
|
||||
@DebugCommand
|
||||
@Command(arguments = @Argument("id"), usage = "/terra structure export <ID>")
|
||||
public class StructureExportCommand implements CommandTemplate {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StructureExportCommand.class);
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@@ -38,10 +43,10 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
public void execute(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
Pair<Vector3, Vector3> l = main.getWorldHandle().getSelectedLocation(player);
|
||||
Pair<Vector3, Vector3> area = main.getWorldHandle().getSelectedLocation(player);
|
||||
|
||||
Vector3 l1 = l.getLeft();
|
||||
Vector3 l2 = l.getRight();
|
||||
Vector3 firstCorner = area.getLeft();
|
||||
Vector3 secondCorner = area.getRight();
|
||||
|
||||
StringBuilder scriptBuilder = new StringBuilder("id \"" + id + "\";\nnum y = 0;\n");
|
||||
|
||||
@@ -49,38 +54,36 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
int centerY = 0;
|
||||
int centerZ = 0;
|
||||
|
||||
for(int x = l1.getBlockX(); x <= l2.getBlockX(); x++) {
|
||||
for(int y = l1.getBlockY(); y <= l2.getBlockY(); y++) {
|
||||
for(int z = l1.getBlockZ(); z <= l2.getBlockZ(); z++) {
|
||||
for(int x = firstCorner.getBlockX(); x <= secondCorner.getBlockX(); x++) {
|
||||
for(int y = firstCorner.getBlockY(); y <= secondCorner.getBlockY(); y++) {
|
||||
for(int z = firstCorner.getBlockZ(); z <= secondCorner.getBlockZ(); z++) {
|
||||
BlockEntity state = player.world().getBlockState(x, y, z);
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
if(sign.getLine(0).equals("[TERRA]") && sign.getLine(1).equals("[CENTER]")) {
|
||||
centerX = x - l1.getBlockX();
|
||||
centerY = y - l1.getBlockY();
|
||||
centerZ = z - l1.getBlockZ();
|
||||
if(state instanceof Sign sign) {
|
||||
if("[TERRA]".equals(sign.getLine(0)) && "[CENTER]".equals(sign.getLine(1))) {
|
||||
centerX = x - firstCorner.getBlockX();
|
||||
centerY = y - firstCorner.getBlockY();
|
||||
centerZ = z - firstCorner.getBlockZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = l1.getBlockX(); x <= l2.getBlockX(); x++) {
|
||||
for(int y = l1.getBlockY(); y <= l2.getBlockY(); y++) {
|
||||
for(int z = l1.getBlockZ(); z <= l2.getBlockZ(); z++) {
|
||||
for(int x = firstCorner.getBlockX(); x <= secondCorner.getBlockX(); x++) {
|
||||
for(int y = firstCorner.getBlockY(); y <= secondCorner.getBlockY(); y++) {
|
||||
for(int z = firstCorner.getBlockZ(); z <= secondCorner.getBlockZ(); z++) {
|
||||
|
||||
BlockState data = player.world().getBlockData(x, y, z);
|
||||
if(data.isStructureVoid()) continue;
|
||||
BlockEntity state = player.world().getBlockState(x, y, z);
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
if(sign.getLine(0).equals("[TERRA]")) {
|
||||
if(state instanceof Sign sign) {
|
||||
if("[TERRA]".equals(sign.getLine(0))) {
|
||||
data = main.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||
}
|
||||
}
|
||||
if(!data.isStructureVoid()) {
|
||||
scriptBuilder.append("block(").append(x - l1.getBlockX() - centerX).append(", y + ").append(
|
||||
y - l1.getBlockY() - centerY).append(", ").append(z - l1.getBlockZ() - centerZ).append(", ")
|
||||
scriptBuilder.append("block(").append(x - firstCorner.getBlockX() - centerX).append(", y + ").append(
|
||||
y - firstCorner.getBlockY() - centerY).append(", ").append(z - firstCorner.getBlockZ() - centerZ).append(", ")
|
||||
.append("\"");
|
||||
scriptBuilder.append(data.getAsString()).append("\");\n");
|
||||
}
|
||||
@@ -93,12 +96,12 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error creating file to export", e);
|
||||
}
|
||||
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
||||
writer.write(scriptBuilder.toString());
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error writing script file", e);
|
||||
}
|
||||
|
||||
sender.sendMessage("Exported structure to " + file.getAbsolutePath());
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.dfsek.terra.addons.structure.structures.loot.functions;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -15,6 +17,8 @@ import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
|
||||
|
||||
public class EnchantFunction implements LootFunction {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EnchantFunction.class);
|
||||
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final JSONArray disabled;
|
||||
@@ -60,9 +64,8 @@ public class EnchantFunction implements LootFunction {
|
||||
try {
|
||||
meta.addEnchantment(chosen, FastMath.max(lvl, 1));
|
||||
} catch(IllegalArgumentException e) {
|
||||
main.logger().warning(
|
||||
"Attempted to enchant " + original.getType() + " with " + chosen + " at level " + FastMath.max(lvl, 1) +
|
||||
", but an unexpected exception occurred! Usually this is caused by a misbehaving enchantment plugin.");
|
||||
logger.warn("Attempted to enchant {} with {} at level {}, but an unexpected exception occurred! Usually this is caused " +
|
||||
"by a misbehaving enchantment plugin.", original.getType(), chosen, FastMath.max(lvl, 1));
|
||||
}
|
||||
}
|
||||
original.setItemMeta(meta);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.addons.yaml;
|
||||
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
@@ -16,6 +18,8 @@ import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
@Version("1.0.0")
|
||||
@Author("Terra")
|
||||
public class YamlAddon extends TerraAddon {
|
||||
private static final Logger logger = LoggerFactory.getLogger(YamlAddon.class);
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@@ -25,7 +29,7 @@ public class YamlAddon extends TerraAddon {
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationDiscoveryEvent.class)
|
||||
.then(event -> event.getLoader().open("", ".yml").thenEntries(entries -> entries.forEach(entry -> {
|
||||
main.getDebugLogger().info("Discovered config " + entry.getKey());
|
||||
logger.info("Discovered config {}", entry.getKey());
|
||||
event.register(entry.getKey(), new YamlConfiguration(entry.getValue(), entry.getKey()));
|
||||
})))
|
||||
.failThrough();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
@@ -9,6 +12,8 @@ import com.dfsek.terra.api.world.World;
|
||||
|
||||
|
||||
public class BufferedBlock implements BufferedItem {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BufferedBlock.class);
|
||||
|
||||
private final BlockState data;
|
||||
private final boolean overwrite;
|
||||
private final TerraPlugin main;
|
||||
@@ -32,8 +37,7 @@ public class BufferedBlock implements BufferedItem {
|
||||
world.setBlockData(origin, data);
|
||||
}
|
||||
} catch(RuntimeException e) {
|
||||
main.logger().severe("Failed to place block at location " + origin + ": " + e.getMessage());
|
||||
main.getDebugLogger().stack(e);
|
||||
logger.error("Failed to place block at location {}", origin, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||
@@ -14,6 +17,8 @@ import com.dfsek.terra.api.world.World;
|
||||
|
||||
|
||||
public class BufferedLootApplication implements BufferedItem {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BufferedLootApplication.class);
|
||||
|
||||
private final LootTable table;
|
||||
private final TerraPlugin main;
|
||||
private final StructureScript structure;
|
||||
@@ -28,12 +33,11 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
public void paste(Vector3 origin, World world) {
|
||||
try {
|
||||
BlockEntity data = world.getBlockState(origin);
|
||||
if(!(data instanceof Container)) {
|
||||
main.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
||||
if(!(data instanceof Container container)) {
|
||||
logger.error("Failed to place loot at {}; block {} is not container.", origin, data);
|
||||
return;
|
||||
}
|
||||
Container container = (Container) data;
|
||||
|
||||
|
||||
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getConfig().getPack(), structure);
|
||||
main.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
@@ -41,8 +45,7 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
event.getTable().fillInventory(container.getInventory(), new Random(origin.hashCode()));
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
main.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
logger.warn("Could not apply loot at {}", origin, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
@@ -8,6 +11,8 @@ import com.dfsek.terra.api.world.World;
|
||||
|
||||
|
||||
public class BufferedStateManipulator implements BufferedItem {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BufferedStateManipulator.class);
|
||||
|
||||
private final TerraPlugin main;
|
||||
private final String data;
|
||||
|
||||
@@ -23,8 +28,7 @@ public class BufferedStateManipulator implements BufferedItem {
|
||||
state.applyState(data);
|
||||
state.update(false);
|
||||
} catch(Exception e) {
|
||||
main.logger().warning("Could not apply BlockState at " + origin + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
logger.warn("Could not apply BlockState at {}", origin, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import net.jafama.FastMath;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -49,6 +51,8 @@ import com.dfsek.terra.api.world.World;
|
||||
|
||||
|
||||
public class StructureScript implements Structure {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StructureScript.class);
|
||||
|
||||
private final Block block;
|
||||
private final String id;
|
||||
private final Cache<Vector3, StructureBuffer> cache;
|
||||
@@ -93,7 +97,7 @@ public class StructureScript implements Structure {
|
||||
.registerFunction("rotationDegrees", new ZeroArgFunctionBuilder<>(arguments -> arguments.getRotation().getDegrees(),
|
||||
Returnable.ReturnType.NUMBER))
|
||||
.registerFunction("print",
|
||||
new UnaryStringFunctionBuilder(string -> main.getDebugLogger().info("[" + tempID + "] " + string)))
|
||||
new UnaryStringFunctionBuilder(string -> logger.info("[{}] {}", tempID, string)))
|
||||
.registerFunction("abs", new UnaryNumberFunctionBuilder(number -> FastMath.abs(number.doubleValue())))
|
||||
.registerFunction("pow", new BinaryNumberFunctionBuilder(
|
||||
(number, number2) -> FastMath.pow(number.doubleValue(), number2.doubleValue())))
|
||||
@@ -175,8 +179,7 @@ public class StructureScript implements Structure {
|
||||
try {
|
||||
return block.apply(arguments).getLevel() != Block.ReturnLevel.FAIL;
|
||||
} catch(RuntimeException e) {
|
||||
main.logger().severe("Failed to generate structure at " + arguments.getBuffer().getOrigin() + ": " + e.getMessage());
|
||||
main.getDebugLogger().stack(e);
|
||||
logger.error("Failed to generate structure at {}: {}", arguments.getBuffer().getOrigin(), e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -21,6 +23,8 @@ import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
|
||||
public class LootFunction implements Function<Void> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LootFunction.class);
|
||||
|
||||
private final Registry<LootTable> registry;
|
||||
private final Returnable<String> data;
|
||||
private final Returnable<Number> x, y, z;
|
||||
@@ -52,7 +56,7 @@ public class LootFunction implements Function<Void> {
|
||||
LootTable table = registry.get(id);
|
||||
|
||||
if(table == null) {
|
||||
main.logger().severe("No such loot table " + id);
|
||||
logger.error("No such loot table {}", id);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.dfsek.terra.addons.terrascript.tokenizer;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
@@ -11,6 +14,8 @@ import java.util.List;
|
||||
* Stream-like data structure that allows viewing future elements without consuming current.
|
||||
*/
|
||||
public class Lookahead {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Lookahead.class);
|
||||
|
||||
private final List<Char> buffer = new ArrayList<>();
|
||||
private final Reader input;
|
||||
private int index = 0;
|
||||
@@ -108,7 +113,7 @@ public class Lookahead {
|
||||
index++;
|
||||
return new Char((char) c, line, index);
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error while fetching next token", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user