mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-06 15:56:14 +00:00
Migrate logging to SLF4J
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
@@ -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