mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-19 23:00:19 +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> {
|
public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||||
@Value("slant")
|
@Value("slant")
|
||||||
@Default
|
@Default
|
||||||
private final @Meta SlantHolder slant;
|
private @Meta SlantHolder slant;
|
||||||
@Value("palette")
|
@Value("palette")
|
||||||
private @Meta PaletteHolder palette;
|
private @Meta PaletteHolder palette;
|
||||||
@Value("ocean.level")
|
@Value("ocean.level")
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.dfsek.terra.addons.chunkgenerator.generation.generators;
|
|||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,6 +32,8 @@ import com.dfsek.terra.api.world.generator.Sampler;
|
|||||||
|
|
||||||
|
|
||||||
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(NoiseChunkGenerator3D.class);
|
||||||
|
|
||||||
private final ConfigPack configPack;
|
private final ConfigPack configPack;
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||||
@@ -87,7 +91,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||||
|
|
||||||
if(paletteInfo == null) {
|
if(paletteInfo == null) {
|
||||||
main.logger().info("null palette: " + biome.getID());
|
logger.info("null palette: {}", biome.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerationSettings generationSettings = biome.getGenerator();
|
GenerationSettings generationSettings = biome.getGenerator();
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.addons.structure.command.structure;
|
package com.dfsek.terra.addons.structure.command.structure;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@@ -28,6 +31,8 @@ import com.dfsek.terra.api.vector.Vector3;
|
|||||||
@DebugCommand
|
@DebugCommand
|
||||||
@Command(arguments = @Argument("id"), usage = "/terra structure export <ID>")
|
@Command(arguments = @Argument("id"), usage = "/terra structure export <ID>")
|
||||||
public class StructureExportCommand implements CommandTemplate {
|
public class StructureExportCommand implements CommandTemplate {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(StructureExportCommand.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private TerraPlugin main;
|
private TerraPlugin main;
|
||||||
|
|
||||||
@@ -38,10 +43,10 @@ public class StructureExportCommand implements CommandTemplate {
|
|||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
Player player = (Player) 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 firstCorner = area.getLeft();
|
||||||
Vector3 l2 = l.getRight();
|
Vector3 secondCorner = area.getRight();
|
||||||
|
|
||||||
StringBuilder scriptBuilder = new StringBuilder("id \"" + id + "\";\nnum y = 0;\n");
|
StringBuilder scriptBuilder = new StringBuilder("id \"" + id + "\";\nnum y = 0;\n");
|
||||||
|
|
||||||
@@ -49,38 +54,36 @@ public class StructureExportCommand implements CommandTemplate {
|
|||||||
int centerY = 0;
|
int centerY = 0;
|
||||||
int centerZ = 0;
|
int centerZ = 0;
|
||||||
|
|
||||||
for(int x = l1.getBlockX(); x <= l2.getBlockX(); x++) {
|
for(int x = firstCorner.getBlockX(); x <= secondCorner.getBlockX(); x++) {
|
||||||
for(int y = l1.getBlockY(); y <= l2.getBlockY(); y++) {
|
for(int y = firstCorner.getBlockY(); y <= secondCorner.getBlockY(); y++) {
|
||||||
for(int z = l1.getBlockZ(); z <= l2.getBlockZ(); z++) {
|
for(int z = firstCorner.getBlockZ(); z <= secondCorner.getBlockZ(); z++) {
|
||||||
BlockEntity state = player.world().getBlockState(x, y, z);
|
BlockEntity state = player.world().getBlockState(x, y, z);
|
||||||
if(state instanceof Sign) {
|
if(state instanceof Sign sign) {
|
||||||
Sign sign = (Sign) state;
|
if("[TERRA]".equals(sign.getLine(0)) && "[CENTER]".equals(sign.getLine(1))) {
|
||||||
if(sign.getLine(0).equals("[TERRA]") && sign.getLine(1).equals("[CENTER]")) {
|
centerX = x - firstCorner.getBlockX();
|
||||||
centerX = x - l1.getBlockX();
|
centerY = y - firstCorner.getBlockY();
|
||||||
centerY = y - l1.getBlockY();
|
centerZ = z - firstCorner.getBlockZ();
|
||||||
centerZ = z - l1.getBlockZ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = l1.getBlockX(); x <= l2.getBlockX(); x++) {
|
for(int x = firstCorner.getBlockX(); x <= secondCorner.getBlockX(); x++) {
|
||||||
for(int y = l1.getBlockY(); y <= l2.getBlockY(); y++) {
|
for(int y = firstCorner.getBlockY(); y <= secondCorner.getBlockY(); y++) {
|
||||||
for(int z = l1.getBlockZ(); z <= l2.getBlockZ(); z++) {
|
for(int z = firstCorner.getBlockZ(); z <= secondCorner.getBlockZ(); z++) {
|
||||||
|
|
||||||
BlockState data = player.world().getBlockData(x, y, z);
|
BlockState data = player.world().getBlockData(x, y, z);
|
||||||
if(data.isStructureVoid()) continue;
|
if(data.isStructureVoid()) continue;
|
||||||
BlockEntity state = player.world().getBlockState(x, y, z);
|
BlockEntity state = player.world().getBlockState(x, y, z);
|
||||||
if(state instanceof Sign) {
|
if(state instanceof Sign sign) {
|
||||||
Sign sign = (Sign) state;
|
if("[TERRA]".equals(sign.getLine(0))) {
|
||||||
if(sign.getLine(0).equals("[TERRA]")) {
|
|
||||||
data = main.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
data = main.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!data.isStructureVoid()) {
|
if(!data.isStructureVoid()) {
|
||||||
scriptBuilder.append("block(").append(x - l1.getBlockX() - centerX).append(", y + ").append(
|
scriptBuilder.append("block(").append(x - firstCorner.getBlockX() - centerX).append(", y + ").append(
|
||||||
y - l1.getBlockY() - centerY).append(", ").append(z - l1.getBlockZ() - centerZ).append(", ")
|
y - firstCorner.getBlockY() - centerY).append(", ").append(z - firstCorner.getBlockZ() - centerZ).append(", ")
|
||||||
.append("\"");
|
.append("\"");
|
||||||
scriptBuilder.append(data.getAsString()).append("\");\n");
|
scriptBuilder.append(data.getAsString()).append("\");\n");
|
||||||
}
|
}
|
||||||
@@ -93,12 +96,12 @@ public class StructureExportCommand implements CommandTemplate {
|
|||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error creating file to export", e);
|
||||||
}
|
}
|
||||||
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
||||||
writer.write(scriptBuilder.toString());
|
writer.write(scriptBuilder.toString());
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error writing script file", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("Exported structure to " + file.getAbsolutePath());
|
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 net.jafama.FastMath;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -15,6 +17,8 @@ import com.dfsek.terra.api.inventory.item.ItemMeta;
|
|||||||
|
|
||||||
|
|
||||||
public class EnchantFunction implements LootFunction {
|
public class EnchantFunction implements LootFunction {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(EnchantFunction.class);
|
||||||
|
|
||||||
private final int min;
|
private final int min;
|
||||||
private final int max;
|
private final int max;
|
||||||
private final JSONArray disabled;
|
private final JSONArray disabled;
|
||||||
@@ -60,9 +64,8 @@ public class EnchantFunction implements LootFunction {
|
|||||||
try {
|
try {
|
||||||
meta.addEnchantment(chosen, FastMath.max(lvl, 1));
|
meta.addEnchantment(chosen, FastMath.max(lvl, 1));
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
main.logger().warning(
|
logger.warn("Attempted to enchant {} with {} at level {}, but an unexpected exception occurred! Usually this is caused " +
|
||||||
"Attempted to enchant " + original.getType() + " with " + chosen + " at level " + FastMath.max(lvl, 1) +
|
"by a misbehaving enchantment plugin.", original.getType(), chosen, FastMath.max(lvl, 1));
|
||||||
", but an unexpected exception occurred! Usually this is caused by a misbehaving enchantment plugin.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
original.setItemMeta(meta);
|
original.setItemMeta(meta);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.dfsek.terra.addons.yaml;
|
package com.dfsek.terra.addons.yaml;
|
||||||
|
|
||||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
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.TerraPlugin;
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
@@ -16,6 +18,8 @@ import com.dfsek.terra.api.injection.annotations.Inject;
|
|||||||
@Version("1.0.0")
|
@Version("1.0.0")
|
||||||
@Author("Terra")
|
@Author("Terra")
|
||||||
public class YamlAddon extends TerraAddon {
|
public class YamlAddon extends TerraAddon {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(YamlAddon.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private TerraPlugin main;
|
private TerraPlugin main;
|
||||||
|
|
||||||
@@ -25,7 +29,7 @@ public class YamlAddon extends TerraAddon {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(this, ConfigurationDiscoveryEvent.class)
|
.register(this, ConfigurationDiscoveryEvent.class)
|
||||||
.then(event -> event.getLoader().open("", ".yml").thenEntries(entries -> entries.forEach(entry -> {
|
.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()));
|
event.register(entry.getKey(), new YamlConfiguration(entry.getValue(), entry.getKey()));
|
||||||
})))
|
})))
|
||||||
.failThrough();
|
.failThrough();
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
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.TerraPlugin;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
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 {
|
public class BufferedBlock implements BufferedItem {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(BufferedBlock.class);
|
||||||
|
|
||||||
private final BlockState data;
|
private final BlockState data;
|
||||||
private final boolean overwrite;
|
private final boolean overwrite;
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
@@ -32,8 +37,7 @@ public class BufferedBlock implements BufferedItem {
|
|||||||
world.setBlockData(origin, data);
|
world.setBlockData(origin, data);
|
||||||
}
|
}
|
||||||
} catch(RuntimeException e) {
|
} catch(RuntimeException e) {
|
||||||
main.logger().severe("Failed to place block at location " + origin + ": " + e.getMessage());
|
logger.error("Failed to place block at location {}", origin, e);
|
||||||
main.getDebugLogger().stack(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
package com.dfsek.terra.addons.terrascript.buffer.items;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||||
@@ -14,6 +17,8 @@ import com.dfsek.terra.api.world.World;
|
|||||||
|
|
||||||
|
|
||||||
public class BufferedLootApplication implements BufferedItem {
|
public class BufferedLootApplication implements BufferedItem {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(BufferedLootApplication.class);
|
||||||
|
|
||||||
private final LootTable table;
|
private final LootTable table;
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
private final StructureScript structure;
|
private final StructureScript structure;
|
||||||
@@ -28,12 +33,11 @@ public class BufferedLootApplication implements BufferedItem {
|
|||||||
public void paste(Vector3 origin, World world) {
|
public void paste(Vector3 origin, World world) {
|
||||||
try {
|
try {
|
||||||
BlockEntity data = world.getBlockState(origin);
|
BlockEntity data = world.getBlockState(origin);
|
||||||
if(!(data instanceof Container)) {
|
if(!(data instanceof Container container)) {
|
||||||
main.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
logger.error("Failed to place loot at {}; block {} is not container.", origin, data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Container container = (Container) data;
|
|
||||||
|
|
||||||
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getConfig().getPack(), structure);
|
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getConfig().getPack(), structure);
|
||||||
main.getEventManager().callEvent(event);
|
main.getEventManager().callEvent(event);
|
||||||
if(event.isCancelled()) return;
|
if(event.isCancelled()) return;
|
||||||
@@ -41,8 +45,7 @@ public class BufferedLootApplication implements BufferedItem {
|
|||||||
event.getTable().fillInventory(container.getInventory(), new Random(origin.hashCode()));
|
event.getTable().fillInventory(container.getInventory(), new Random(origin.hashCode()));
|
||||||
data.update(false);
|
data.update(false);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
main.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage());
|
logger.warn("Could not apply loot at {}", origin, e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.buffer.items;
|
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.TerraPlugin;
|
||||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
@@ -8,6 +11,8 @@ import com.dfsek.terra.api.world.World;
|
|||||||
|
|
||||||
|
|
||||||
public class BufferedStateManipulator implements BufferedItem {
|
public class BufferedStateManipulator implements BufferedItem {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(BufferedStateManipulator.class);
|
||||||
|
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
private final String data;
|
private final String data;
|
||||||
|
|
||||||
@@ -23,8 +28,7 @@ public class BufferedStateManipulator implements BufferedItem {
|
|||||||
state.applyState(data);
|
state.applyState(data);
|
||||||
state.update(false);
|
state.update(false);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
main.logger().warning("Could not apply BlockState at " + origin + ": " + e.getMessage());
|
logger.warn("Could not apply BlockState at {}", origin, e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.google.common.cache.Cache;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -49,6 +51,8 @@ import com.dfsek.terra.api.world.World;
|
|||||||
|
|
||||||
|
|
||||||
public class StructureScript implements Structure {
|
public class StructureScript implements Structure {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(StructureScript.class);
|
||||||
|
|
||||||
private final Block block;
|
private final Block block;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Cache<Vector3, StructureBuffer> cache;
|
private final Cache<Vector3, StructureBuffer> cache;
|
||||||
@@ -93,7 +97,7 @@ public class StructureScript implements Structure {
|
|||||||
.registerFunction("rotationDegrees", new ZeroArgFunctionBuilder<>(arguments -> arguments.getRotation().getDegrees(),
|
.registerFunction("rotationDegrees", new ZeroArgFunctionBuilder<>(arguments -> arguments.getRotation().getDegrees(),
|
||||||
Returnable.ReturnType.NUMBER))
|
Returnable.ReturnType.NUMBER))
|
||||||
.registerFunction("print",
|
.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("abs", new UnaryNumberFunctionBuilder(number -> FastMath.abs(number.doubleValue())))
|
||||||
.registerFunction("pow", new BinaryNumberFunctionBuilder(
|
.registerFunction("pow", new BinaryNumberFunctionBuilder(
|
||||||
(number, number2) -> FastMath.pow(number.doubleValue(), number2.doubleValue())))
|
(number, number2) -> FastMath.pow(number.doubleValue(), number2.doubleValue())))
|
||||||
@@ -175,8 +179,7 @@ public class StructureScript implements Structure {
|
|||||||
try {
|
try {
|
||||||
return block.apply(arguments).getLevel() != Block.ReturnLevel.FAIL;
|
return block.apply(arguments).getLevel() != Block.ReturnLevel.FAIL;
|
||||||
} catch(RuntimeException e) {
|
} catch(RuntimeException e) {
|
||||||
main.logger().severe("Failed to generate structure at " + arguments.getBuffer().getOrigin() + ": " + e.getMessage());
|
logger.error("Failed to generate structure at {}: {}", arguments.getBuffer().getOrigin(), e.getMessage(), e);
|
||||||
main.getDebugLogger().stack(e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -21,6 +23,8 @@ import com.dfsek.terra.api.vector.Vector3;
|
|||||||
|
|
||||||
|
|
||||||
public class LootFunction implements Function<Void> {
|
public class LootFunction implements Function<Void> {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(LootFunction.class);
|
||||||
|
|
||||||
private final Registry<LootTable> registry;
|
private final Registry<LootTable> registry;
|
||||||
private final Returnable<String> data;
|
private final Returnable<String> data;
|
||||||
private final Returnable<Number> x, y, z;
|
private final Returnable<Number> x, y, z;
|
||||||
@@ -52,7 +56,7 @@ public class LootFunction implements Function<Void> {
|
|||||||
LootTable table = registry.get(id);
|
LootTable table = registry.get(id);
|
||||||
|
|
||||||
if(table == null) {
|
if(table == null) {
|
||||||
main.logger().severe("No such loot table " + id);
|
logger.error("No such loot table {}", id);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.dfsek.terra.addons.terrascript.tokenizer;
|
package com.dfsek.terra.addons.terrascript.tokenizer;
|
||||||
|
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -11,6 +14,8 @@ import java.util.List;
|
|||||||
* Stream-like data structure that allows viewing future elements without consuming current.
|
* Stream-like data structure that allows viewing future elements without consuming current.
|
||||||
*/
|
*/
|
||||||
public class Lookahead {
|
public class Lookahead {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(Lookahead.class);
|
||||||
|
|
||||||
private final List<Char> buffer = new ArrayList<>();
|
private final List<Char> buffer = new ArrayList<>();
|
||||||
private final Reader input;
|
private final Reader input;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
@@ -108,7 +113,7 @@ public class Lookahead {
|
|||||||
index++;
|
index++;
|
||||||
return new Char((char) c, line, index);
|
return new Char((char) c, line, index);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error while fetching next token", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,7 @@ dependencies {
|
|||||||
"shadedApi"("com.dfsek.tectonic:common:2.1.2")
|
"shadedApi"("com.dfsek.tectonic:common:2.1.2")
|
||||||
|
|
||||||
"shadedApi"("net.jafama:jafama:2.3.2")
|
"shadedApi"("net.jafama:jafama:2.3.2")
|
||||||
|
|
||||||
|
"shadedApi"("org.slf4j:slf4j-api:1.7.32")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.dfsek.terra.api;
|
|
||||||
|
|
||||||
public interface Logger {
|
|
||||||
void info(String message);
|
|
||||||
|
|
||||||
void warning(String message);
|
|
||||||
|
|
||||||
void severe(String message);
|
|
||||||
|
|
||||||
default void stack(Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,8 +19,6 @@ import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
|||||||
* Represents a Terra mod/plugin instance.
|
* Represents a Terra mod/plugin instance.
|
||||||
*/
|
*/
|
||||||
public interface TerraPlugin extends LoaderRegistrar {
|
public interface TerraPlugin extends LoaderRegistrar {
|
||||||
Logger logger();
|
|
||||||
|
|
||||||
boolean reload();
|
boolean reload();
|
||||||
|
|
||||||
String platformName();
|
String platformName();
|
||||||
@@ -50,8 +48,6 @@ public interface TerraPlugin extends LoaderRegistrar {
|
|||||||
|
|
||||||
ItemHandle getItemHandle();
|
ItemHandle getItemHandle();
|
||||||
|
|
||||||
Logger getDebugLogger();
|
|
||||||
|
|
||||||
EventManager getEventManager();
|
EventManager getEventManager();
|
||||||
|
|
||||||
default String getVersion() {
|
default String getVersion() {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.dfsek.terra;
|
|||||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -16,7 +18,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
import com.dfsek.terra.api.command.CommandManager;
|
import com.dfsek.terra.api.command.CommandManager;
|
||||||
@@ -28,7 +29,6 @@ import com.dfsek.terra.api.lang.Language;
|
|||||||
import com.dfsek.terra.api.profiler.Profiler;
|
import com.dfsek.terra.api.profiler.Profiler;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
import com.dfsek.terra.api.util.generic.Lazy;
|
|
||||||
import com.dfsek.terra.api.util.mutable.MutableBoolean;
|
import com.dfsek.terra.api.util.mutable.MutableBoolean;
|
||||||
import com.dfsek.terra.commands.CommandUtil;
|
import com.dfsek.terra.commands.CommandUtil;
|
||||||
import com.dfsek.terra.commands.TerraCommandManager;
|
import com.dfsek.terra.commands.TerraCommandManager;
|
||||||
@@ -40,7 +40,6 @@ import com.dfsek.terra.profiler.ProfilerImpl;
|
|||||||
import com.dfsek.terra.registry.CheckedRegistryImpl;
|
import com.dfsek.terra.registry.CheckedRegistryImpl;
|
||||||
import com.dfsek.terra.registry.master.AddonRegistry;
|
import com.dfsek.terra.registry.master.AddonRegistry;
|
||||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||||
import com.dfsek.terra.util.logging.DebugLogger;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,9 +48,10 @@ import com.dfsek.terra.util.logging.DebugLogger;
|
|||||||
* Implementations must invoke {@link #load()} in their constructors.
|
* Implementations must invoke {@link #load()} in their constructors.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractTerraPlugin implements TerraPlugin {
|
public abstract class AbstractTerraPlugin implements TerraPlugin {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AbstractTerraPlugin.class);
|
||||||
|
|
||||||
private static final MutableBoolean LOADED = new MutableBoolean(false);
|
private static final MutableBoolean LOADED = new MutableBoolean(false);
|
||||||
private final EventManager eventManager = new EventManagerImpl(this);
|
private final EventManager eventManager = new EventManagerImpl(this);
|
||||||
|
|
||||||
private final ConfigRegistry configRegistry = new ConfigRegistry();
|
private final ConfigRegistry configRegistry = new ConfigRegistry();
|
||||||
|
|
||||||
private final CheckedRegistry<ConfigPack> checkedConfigRegistry = new CheckedRegistryImpl<>(configRegistry);
|
private final CheckedRegistry<ConfigPack> checkedConfigRegistry = new CheckedRegistryImpl<>(configRegistry);
|
||||||
@@ -66,19 +66,11 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
|
|
||||||
private final AddonRegistry addonRegistry = new AddonRegistry(this);
|
private final AddonRegistry addonRegistry = new AddonRegistry(this);
|
||||||
|
|
||||||
private final Lazy<Logger> logger = Lazy.lazy(() -> createLogger());
|
|
||||||
private final Lazy<DebugLogger> debugLogger = Lazy.lazy(() -> new DebugLogger(logger()));
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(TypeRegistry registry) {
|
public void register(TypeRegistry registry) {
|
||||||
loaders.register(registry);
|
loaders.register(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger logger() {
|
|
||||||
return logger.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginConfig getTerraConfig() {
|
public PluginConfig getTerraConfig() {
|
||||||
return config;
|
return config;
|
||||||
@@ -99,11 +91,6 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
return addonRegistry;
|
return addonRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getDebugLogger() {
|
|
||||||
return debugLogger.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EventManager getEventManager() {
|
public EventManager getEventManager() {
|
||||||
return eventManager;
|
return eventManager;
|
||||||
@@ -122,7 +109,7 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
}
|
}
|
||||||
LOADED.set(true);
|
LOADED.set(true);
|
||||||
|
|
||||||
logger().info("Initializing Terra...");
|
logger.info("Initializing Terra...");
|
||||||
|
|
||||||
getPlatformAddon().ifPresent(addonRegistry::register);
|
getPlatformAddon().ifPresent(addonRegistry::register);
|
||||||
|
|
||||||
@@ -132,7 +119,7 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
FileUtils.copyInputStreamToFile(stream, configFile);
|
FileUtils.copyInputStreamToFile(stream, configFile);
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error loading config.yml resource from jar", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,16 +130,17 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
if(config.dumpDefaultConfig()) {
|
if(config.dumpDefaultConfig()) {
|
||||||
try(InputStream resourcesConfig = getClass().getResourceAsStream("/resources.yml")) {
|
try(InputStream resourcesConfig = getClass().getResourceAsStream("/resources.yml")) {
|
||||||
if(resourcesConfig == null) {
|
if(resourcesConfig == null) {
|
||||||
logger().info("No resources config found. Skipping resource dumping.");
|
logger.info("No resources config found. Skipping resource dumping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String resourceYaml = IOUtils.toString(resourcesConfig, StandardCharsets.UTF_8);
|
String resourceYaml = IOUtils.toString(resourcesConfig, StandardCharsets.UTF_8);
|
||||||
Map<String, List<String>> resources = new Yaml().load(resourceYaml);
|
Map<String, List<String>> resources = new Yaml().load(resourceYaml);
|
||||||
resources.forEach((dir, entries) -> entries.forEach(entry -> {
|
resources.forEach((dir, entries) -> entries.forEach(entry -> {
|
||||||
String resourcePath = dir + "/" + entry;
|
String resourcePath = String.format("%s/%s", dir, entry);
|
||||||
File resource = new File(getDataFolder(), resourcePath);
|
File resource = new File(getDataFolder(), resourcePath);
|
||||||
if(resource.exists()) return; // dont overwrite
|
if(resource.exists())
|
||||||
logger().info("Dumping resource " + resource.getAbsolutePath());
|
return; // dont overwrite
|
||||||
|
logger.info("Dumping resource {}...", resource.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
resource.getParentFile().mkdirs();
|
resource.getParentFile().mkdirs();
|
||||||
resource.createNewFile();
|
resource.createNewFile();
|
||||||
@@ -167,14 +155,12 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error while dumping resources...", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getDebugLogger().info("Skipping resource dumping.");
|
logger.info("Skipping resource dumping.");
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLogger.value().setDebug(config.isDebugLogging()); // enable debug logger if applicable
|
|
||||||
|
|
||||||
if(config.isDebugProfiler()) { // if debug.profiler is enabled, start profiling
|
if(config.isDebugProfiler()) { // if debug.profiler is enabled, start profiling
|
||||||
profiler.start();
|
profiler.start();
|
||||||
}
|
}
|
||||||
@@ -184,20 +170,18 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
if(!addonRegistry.loadAll(getClass().getClassLoader())) { // load all addons
|
if(!addonRegistry.loadAll(getClass().getClassLoader())) { // load all addons
|
||||||
throw new IllegalStateException("Failed to load addons. Please correct addon installations to continue.");
|
throw new IllegalStateException("Failed to load addons. Please correct addon installations to continue.");
|
||||||
}
|
}
|
||||||
logger().info("Loaded addons.");
|
logger.info("Loaded addons.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommandUtil.registerAll(manager);
|
CommandUtil.registerAll(manager);
|
||||||
} catch(MalformedCommandException e) {
|
} catch(MalformedCommandException e) {
|
||||||
e.printStackTrace(); // TODO do something here even though this should literally never happen
|
logger.error("Error registering commands", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logger().info("Finished initialization.");
|
logger.info("Finished initialization.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Logger createLogger();
|
|
||||||
|
|
||||||
protected Optional<TerraAddon> getPlatformAddon() {
|
protected Optional<TerraAddon> getPlatformAddon() {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra;
|
package com.dfsek.terra;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
@@ -12,6 +15,8 @@ import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
|||||||
@Author("Terra")
|
@Author("Terra")
|
||||||
@Version("1.0.0")
|
@Version("1.0.0")
|
||||||
public class InternalAddon extends TerraAddon {
|
public class InternalAddon extends TerraAddon {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(InternalAddon.class);
|
||||||
|
|
||||||
private final AbstractTerraPlugin main;
|
private final AbstractTerraPlugin main;
|
||||||
|
|
||||||
public InternalAddon(AbstractTerraPlugin main) {
|
public InternalAddon(AbstractTerraPlugin main) {
|
||||||
@@ -24,9 +29,9 @@ public class InternalAddon extends TerraAddon {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(this, PlatformInitializationEvent.class)
|
.register(this, PlatformInitializationEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
main.logger().info("Loading config packs...");
|
logger.info("Loading config packs...");
|
||||||
main.getRawConfigRegistry().loadAll(main);
|
main.getRawConfigRegistry().loadAll(main);
|
||||||
main.logger().info("Loaded packs.");
|
logger.info("Loaded packs.");
|
||||||
})
|
})
|
||||||
.global();
|
.global();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.commands.profiler;
|
package com.dfsek.terra.commands.profiler;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
import com.dfsek.terra.api.command.CommandTemplate;
|
import com.dfsek.terra.api.command.CommandTemplate;
|
||||||
import com.dfsek.terra.api.command.annotation.Command;
|
import com.dfsek.terra.api.command.annotation.Command;
|
||||||
@@ -11,6 +14,8 @@ import com.dfsek.terra.api.injection.annotations.Inject;
|
|||||||
@Command
|
@Command
|
||||||
@DebugCommand
|
@DebugCommand
|
||||||
public class ProfileQueryCommand implements CommandTemplate {
|
public class ProfileQueryCommand implements CommandTemplate {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ProfileQueryCommand.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private TerraPlugin main;
|
private TerraPlugin main;
|
||||||
|
|
||||||
@@ -18,7 +23,7 @@ public class ProfileQueryCommand implements CommandTemplate {
|
|||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
StringBuilder data = new StringBuilder("Terra Profiler data dump: \n");
|
StringBuilder data = new StringBuilder("Terra Profiler data dump: \n");
|
||||||
main.getProfiler().getTimings().forEach((id, timings) -> data.append(id).append(": ").append(timings.toString()).append('\n'));
|
main.getProfiler().getTimings().forEach((id, timings) -> data.append(id).append(": ").append(timings.toString()).append('\n'));
|
||||||
main.logger().info(data.toString());
|
logger.info(data.toString());
|
||||||
sender.sendMessage("Profiler data dumped to console.");
|
sender.sendMessage("Profiler data dumped to console.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.dfsek.tectonic.config.ConfigTemplate;
|
|||||||
import com.dfsek.tectonic.exception.ConfigException;
|
import com.dfsek.tectonic.exception.ConfigException;
|
||||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -13,19 +15,20 @@ import java.io.IOException;
|
|||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("FieldMayBeFinal")
|
@SuppressWarnings("FieldMayBeFinal")
|
||||||
public class PluginConfigImpl implements ConfigTemplate, com.dfsek.terra.api.config.PluginConfig {
|
public class PluginConfigImpl implements ConfigTemplate, com.dfsek.terra.api.config.PluginConfig {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PluginConfigImpl.class);
|
||||||
|
|
||||||
@Value("debug.commands")
|
@Value("debug.commands")
|
||||||
@Default
|
@Default
|
||||||
private boolean debugCommands = false;
|
private boolean debugCommands = false;
|
||||||
|
|
||||||
@Value("debug.log")
|
@Value("debug.log")
|
||||||
@Default
|
@Default
|
||||||
private boolean debugLog = false;
|
private boolean debugLog = false; // TODO: 2021-08-30 remove me
|
||||||
|
|
||||||
@Value("debug.profiler")
|
@Value("debug.profiler")
|
||||||
@Default
|
@Default
|
||||||
@@ -77,20 +80,20 @@ public class PluginConfigImpl implements ConfigTemplate, com.dfsek.terra.api.con
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(TerraPlugin main) {
|
public void load(TerraPlugin main) {
|
||||||
Logger logger = main.logger();
|
|
||||||
logger.info("Loading config values");
|
logger.info("Loading config values");
|
||||||
try(FileInputStream file = new FileInputStream(new File(main.getDataFolder(), "config.yml"))) {
|
try(FileInputStream file = new FileInputStream(new File(main.getDataFolder(), "config.yml"))) {
|
||||||
ConfigLoader loader = new ConfigLoader();
|
ConfigLoader loader = new ConfigLoader();
|
||||||
loader.load(this, new YamlConfiguration(file, "config.yml"));
|
loader.load(this, new YamlConfiguration(file, "config.yml"));
|
||||||
} catch(ConfigException | IOException | UncheckedIOException e) {
|
} catch(ConfigException | IOException | UncheckedIOException e) {
|
||||||
logger.severe("Failed to load config");
|
logger.error("Failed to load config", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isDebugCommands()) logger.info("Debug commands enabled.");
|
if(isDebugCommands())
|
||||||
if(isDebugLogging()) logger.info("Debug logging enabled.");
|
logger.info("Debug commands enabled.");
|
||||||
if(isDebugProfiler()) logger.info("Debug profiler enabled.");
|
if(isDebugProfiler())
|
||||||
if(isDebugScript()) logger.info("Script debug blocks enabled.");
|
logger.info("Debug profiler enabled.");
|
||||||
|
if(isDebugScript())
|
||||||
|
logger.info("Script debug blocks enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.config.fileloaders;
|
package com.dfsek.terra.config.fileloaders;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -14,6 +17,8 @@ import java.util.stream.Stream;
|
|||||||
* Load all {@code *.yml} files from a {@link java.nio.file.Path}.
|
* Load all {@code *.yml} files from a {@link java.nio.file.Path}.
|
||||||
*/
|
*/
|
||||||
public class FolderLoader extends LoaderImpl {
|
public class FolderLoader extends LoaderImpl {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FolderLoader.class);
|
||||||
|
|
||||||
private final Path path;
|
private final Path path;
|
||||||
|
|
||||||
public FolderLoader(Path path) {
|
public FolderLoader(Path path) {
|
||||||
@@ -34,11 +39,11 @@ public class FolderLoader extends LoaderImpl {
|
|||||||
String rel = newPath.toPath().relativize(file).toString();
|
String rel = newPath.toPath().relativize(file).toString();
|
||||||
streams.put(rel, new FileInputStream(file.toFile()));
|
streams.put(rel, new FileInputStream(file.toFile()));
|
||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
logger.error("Could not find file to load", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error while loading files", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.dfsek.terra.config.fileloaders;
|
package com.dfsek.terra.config.fileloaders;
|
||||||
|
|
||||||
import com.dfsek.tectonic.exception.ConfigException;
|
import com.dfsek.tectonic.exception.ConfigException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -15,6 +17,8 @@ import com.dfsek.terra.api.config.Loader;
|
|||||||
|
|
||||||
|
|
||||||
public abstract class LoaderImpl implements Loader {
|
public abstract class LoaderImpl implements Loader {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(LoaderImpl.class);
|
||||||
|
|
||||||
protected final Map<String, InputStream> streams = new HashMap<>();
|
protected final Map<String, InputStream> streams = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,7 +55,7 @@ public abstract class LoaderImpl implements Loader {
|
|||||||
try {
|
try {
|
||||||
input.close();
|
input.close();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.warn("Error occurred while loading", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
streams.clear();
|
streams.clear();
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.config.fileloaders;
|
package com.dfsek.terra.config.fileloaders;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -8,6 +11,8 @@ import java.util.zip.ZipFile;
|
|||||||
|
|
||||||
|
|
||||||
public class ZIPLoader extends LoaderImpl {
|
public class ZIPLoader extends LoaderImpl {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ZIPLoader.class);
|
||||||
|
|
||||||
private final ZipFile file;
|
private final ZipFile file;
|
||||||
|
|
||||||
public ZIPLoader(ZipFile file) {
|
public ZIPLoader(ZipFile file) {
|
||||||
@@ -33,7 +38,7 @@ public class ZIPLoader extends LoaderImpl {
|
|||||||
String rel = entry.getName().substring(directory.length());
|
String rel = entry.getName().substring(directory.length());
|
||||||
streams.put(rel, file.getInputStream(entry));
|
streams.put(rel, file.getInputStream(entry));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error while loading file from zip", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,30 @@
|
|||||||
package com.dfsek.terra.config.lang;
|
package com.dfsek.terra.config.lang;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
import com.dfsek.terra.api.entity.CommandSender;
|
import com.dfsek.terra.api.entity.CommandSender;
|
||||||
import com.dfsek.terra.api.lang.Language;
|
import com.dfsek.terra.api.lang.Language;
|
||||||
|
|
||||||
|
|
||||||
public final class LangUtil {
|
public final class LangUtil {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(LangUtil.class);
|
||||||
|
|
||||||
private static Language language;
|
private static Language language;
|
||||||
|
|
||||||
public static void load(String langID, TerraPlugin main) {
|
public static void load(String langID, TerraPlugin main) {
|
||||||
Logger logger = main.logger();
|
|
||||||
File file = new File(main.getDataFolder(), "lang");
|
File file = new File(main.getDataFolder(), "lang");
|
||||||
try {
|
try {
|
||||||
File file1 = new File(file, langID + ".yml");
|
File file1 = new File(file, langID + ".yml");
|
||||||
logger.info(file1.getAbsolutePath());
|
logger.info(file1.getAbsolutePath());
|
||||||
language = new LanguageImpl(file1);
|
language = new LanguageImpl(file1);
|
||||||
logger.info("Loaded language " + langID);
|
logger.info("Loaded language {}", langID);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
logger.severe("Unable to load language: " + langID);
|
logger.error("Unable to load language: {}.\nDouble-check your configuration before reporting this to Terra!", langID, e);
|
||||||
e.printStackTrace();
|
|
||||||
logger.severe("Double-check your configuration before reporting this to Terra!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
|||||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -78,6 +80,8 @@ import com.dfsek.terra.registry.config.ConfigTypeRegistry;
|
|||||||
* Represents a Terra configuration pack.
|
* Represents a Terra configuration pack.
|
||||||
*/
|
*/
|
||||||
public class ConfigPackImpl implements ConfigPack {
|
public class ConfigPackImpl implements ConfigPack {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ConfigPackImpl.class);
|
||||||
|
|
||||||
private final ConfigPackTemplate template = new ConfigPackTemplate();
|
private final ConfigPackTemplate template = new ConfigPackTemplate();
|
||||||
|
|
||||||
private final RegistryFactory registryFactory = new RegistryFactoryImpl();
|
private final RegistryFactory registryFactory = new RegistryFactoryImpl();
|
||||||
@@ -127,7 +131,7 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
|
|
||||||
selfLoader.load(template, configuration);
|
selfLoader.load(template, configuration);
|
||||||
|
|
||||||
main.logger().info("Loading config pack \"" + template.getID() + "\"");
|
logger.info("Loading config pack \"{}\"", template.getID());
|
||||||
load(l, main);
|
load(l, main);
|
||||||
|
|
||||||
ConfigPackPostTemplate packPostTemplate = new ConfigPackPostTemplate();
|
ConfigPackPostTemplate packPostTemplate = new ConfigPackPostTemplate();
|
||||||
@@ -138,7 +142,7 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
throw new LoadException("No pack.yml file found in " + folder.getAbsolutePath(), e);
|
throw new LoadException("No pack.yml file found in " + folder.getAbsolutePath(), e);
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
main.logger().severe("Failed to load config pack from folder \"" + folder.getAbsolutePath() + "\"");
|
logger.error("Failed to load config pack from folder \"{}\"", folder.getAbsolutePath(), e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
toWorldConfig(new DummyWorld()); // Build now to catch any errors immediately.
|
toWorldConfig(new DummyWorld()); // Build now to catch any errors immediately.
|
||||||
@@ -177,7 +181,7 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
|
|
||||||
|
|
||||||
selfLoader.load(template, configuration);
|
selfLoader.load(template, configuration);
|
||||||
main.logger().info("Loading config pack \"" + template.getID() + "\"");
|
logger.info("Loading config pack \"" + template.getID() + "\"");
|
||||||
|
|
||||||
load(l, main);
|
load(l, main);
|
||||||
|
|
||||||
@@ -190,7 +194,7 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
throw new LoadException("Unable to load pack.yml from ZIP file", e);
|
throw new LoadException("Unable to load pack.yml from ZIP file", e);
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
main.logger().severe("Failed to load config pack from ZIP archive \"" + file.getName() + "\"");
|
logger.error("Failed to load config pack from ZIP archive \"{}\"", file.getName());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,16 +285,14 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
OpenRegistry<T> registry = new OpenRegistryImpl<>();
|
OpenRegistry<T> registry = new OpenRegistryImpl<>();
|
||||||
selfLoader.registerLoader(c, registry);
|
selfLoader.registerLoader(c, registry);
|
||||||
abstractConfigLoader.registerLoader(c, registry);
|
abstractConfigLoader.registerLoader(c, registry);
|
||||||
main.getDebugLogger().info("Registered loader for registry of class " + ReflectionUtil.typeToString(c));
|
logger.debug("Registered loader for registry of class {}", ReflectionUtil.typeToString(c));
|
||||||
|
|
||||||
if(type instanceof ParameterizedType) {
|
if(type instanceof ParameterizedType param) {
|
||||||
ParameterizedType param = (ParameterizedType) type;
|
|
||||||
Type base = param.getRawType();
|
Type base = param.getRawType();
|
||||||
if(base instanceof Class // should always be true but we'll check anyways
|
if(base instanceof Class // should always be true but we'll check anyways
|
||||||
&& Supplier.class.isAssignableFrom((Class<?>) base)) { // If it's a supplier
|
&& Supplier.class.isAssignableFrom((Class<?>) base)) { // If it's a supplier
|
||||||
Type supplied = param.getActualTypeArguments()[0]; // Grab the supplied type
|
Type supplied = param.getActualTypeArguments()[0]; // Grab the supplied type
|
||||||
if(supplied instanceof ParameterizedType) {
|
if(supplied instanceof ParameterizedType suppliedParam) {
|
||||||
ParameterizedType suppliedParam = (ParameterizedType) supplied;
|
|
||||||
Type suppliedBase = suppliedParam.getRawType();
|
Type suppliedBase = suppliedParam.getRawType();
|
||||||
if(suppliedBase instanceof Class // should always be true but we'll check anyways
|
if(suppliedBase instanceof Class // should always be true but we'll check anyways
|
||||||
&& ObjectTemplate.class.isAssignableFrom((Class<?>) suppliedBase)) {
|
&& ObjectTemplate.class.isAssignableFrom((Class<?>) suppliedBase)) {
|
||||||
@@ -299,8 +301,7 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
(Registry<Supplier<ObjectTemplate<Supplier<ObjectTemplate<?>>>>>) registry);
|
(Registry<Supplier<ObjectTemplate<Supplier<ObjectTemplate<?>>>>>) registry);
|
||||||
selfLoader.registerLoader(templateType, loader);
|
selfLoader.registerLoader(templateType, loader);
|
||||||
abstractConfigLoader.registerLoader(templateType, loader);
|
abstractConfigLoader.registerLoader(templateType, loader);
|
||||||
main.getDebugLogger().info(
|
logger.debug("Registered template loader for registry of class {}", ReflectionUtil.typeToString(templateType));
|
||||||
"Registered template loader for registry of class " + ReflectionUtil.typeToString(templateType));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,13 +362,9 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkDeadEntries(TerraPlugin main) {
|
private void checkDeadEntries(TerraPlugin main) {
|
||||||
registryMap.forEach((clazz, pair) -> ((OpenRegistryImpl<?>) pair.getLeft()).getDeadEntries()
|
registryMap.forEach((clazz, pair) -> ((OpenRegistryImpl<?>) pair.getLeft())
|
||||||
.forEach((id, value) -> main.getDebugLogger()
|
.getDeadEntries()
|
||||||
.warning("Dead entry in '" +
|
.forEach((id, value) -> logger.warn("Dead entry in '{}' registry: '{}'", ReflectionUtil.typeToString(clazz), id)));
|
||||||
ReflectionUtil.typeToString(
|
|
||||||
clazz) +
|
|
||||||
"' registry: '" +
|
|
||||||
id + "'")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@@ -431,9 +428,8 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main.getEventManager().callEvent(new ConfigPackPostLoadEvent(this, template -> selfLoader.load(template, configuration)));
|
main.getEventManager().callEvent(new ConfigPackPostLoadEvent(this, template -> selfLoader.load(template, configuration)));
|
||||||
main.logger().info(
|
logger.info("Loaded config pack \"{}\" v{} by {} in {}ms.",
|
||||||
"Loaded config pack \"" + template.getID() + "\" v" + template.getVersion() + " by " + template.getAuthor() + " in " +
|
template.getID(), template.getVersion(), template.getAuthor(), (System.nanoTime() - start) / 1000000.0D);
|
||||||
(System.nanoTime() - start) / 1000000D + "ms.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<Type, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> getRegistryMap() {
|
protected Map<Type, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> getRegistryMap() {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.dfsek.terra.event;
|
package com.dfsek.terra.event;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import org.slf4j.Logger;
|
||||||
import java.io.StringWriter;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -21,6 +22,8 @@ import com.dfsek.terra.api.util.reflection.TypeKey;
|
|||||||
|
|
||||||
|
|
||||||
public class FunctionalEventHandlerImpl implements FunctionalEventHandler {
|
public class FunctionalEventHandlerImpl implements FunctionalEventHandler {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FunctionalEventHandlerImpl.class);
|
||||||
|
|
||||||
private final Map<Type, List<EventContextImpl<?>>> contextMap = new HashMap<>();
|
private final Map<Type, List<EventContextImpl<?>>> contextMap = new HashMap<>();
|
||||||
|
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
@@ -42,13 +45,10 @@ public class FunctionalEventHandlerImpl implements FunctionalEventHandler {
|
|||||||
((EventContextImpl<Event>) context).handle(event);
|
((EventContextImpl<Event>) context).handle(event);
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
if(context.isFailThrough() && event instanceof FailThroughEvent) throw e; // Rethrow if it's fail-through.
|
if(context.isFailThrough() && event instanceof FailThroughEvent)
|
||||||
StringWriter writer = new StringWriter();
|
throw e; // Rethrow if it's fail-through.
|
||||||
e.printStackTrace(new PrintWriter(writer));
|
// else warn
|
||||||
main.logger().warning("Exception occurred during event handling:");
|
logger.warn("Exception occurred during event handling. Report this to the maintainers of {}, {}", context.getAddon().getName(), context.getAddon().getAuthor(), e);
|
||||||
main.logger().warning(writer.toString());
|
|
||||||
main.logger().warning(
|
|
||||||
"Report this to the maintainers of " + context.getAddon().getName() + ", " + context.getAddon().getAuthor());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.registry.config;
|
package com.dfsek.terra.registry.config;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@@ -10,6 +13,8 @@ import com.dfsek.terra.registry.OpenRegistryImpl;
|
|||||||
|
|
||||||
|
|
||||||
public class ConfigTypeRegistry extends OpenRegistryImpl<ConfigType<?, ?>> {
|
public class ConfigTypeRegistry extends OpenRegistryImpl<ConfigType<?, ?>> {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ConfigTypeRegistry.class);
|
||||||
|
|
||||||
private final BiConsumer<String, ConfigType<?, ?>> callback;
|
private final BiConsumer<String, ConfigType<?, ?>> callback;
|
||||||
|
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
@@ -23,8 +28,8 @@ public class ConfigTypeRegistry extends OpenRegistryImpl<ConfigType<?, ?>> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean register(String identifier, Entry<ConfigType<?, ?>> value) {
|
public boolean register(String identifier, Entry<ConfigType<?, ?>> value) {
|
||||||
callback.accept(identifier, value.getValue());
|
callback.accept(identifier, value.getValue());
|
||||||
main.getDebugLogger().info("Registered config registry with ID " + identifier + " to type " +
|
logger.debug("Registered config registry with ID {} to type {}", identifier,
|
||||||
ReflectionUtil.typeToString(value.getValue().getTypeKey().getType()));
|
ReflectionUtil.typeToString(value.getValue().getTypeKey().getType()));
|
||||||
return super.register(identifier, value);
|
return super.register(identifier, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.dfsek.terra.registry.master;
|
package com.dfsek.terra.registry.master;
|
||||||
|
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -13,6 +15,7 @@ import com.dfsek.terra.addon.PreLoadAddon;
|
|||||||
import com.dfsek.terra.addon.exception.AddonLoadException;
|
import com.dfsek.terra.addon.exception.AddonLoadException;
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
|
import com.dfsek.terra.api.injection.Injector;
|
||||||
import com.dfsek.terra.api.injection.exception.InjectionException;
|
import com.dfsek.terra.api.injection.exception.InjectionException;
|
||||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||||
import com.dfsek.terra.inject.InjectorImpl;
|
import com.dfsek.terra.inject.InjectorImpl;
|
||||||
@@ -20,6 +23,8 @@ import com.dfsek.terra.registry.OpenRegistryImpl;
|
|||||||
|
|
||||||
|
|
||||||
public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
||||||
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(AddonRegistry.class);
|
||||||
|
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
|
||||||
public AddonRegistry(TerraPlugin main) {
|
public AddonRegistry(TerraPlugin main) {
|
||||||
@@ -35,7 +40,7 @@ public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
|||||||
public boolean register(String identifier, TerraAddon addon) {
|
public boolean register(String identifier, TerraAddon addon) {
|
||||||
if(contains(identifier)) throw new IllegalArgumentException("Addon " + identifier + " is already registered.");
|
if(contains(identifier)) throw new IllegalArgumentException("Addon " + identifier + " is already registered.");
|
||||||
addon.initialize();
|
addon.initialize();
|
||||||
main.logger().info("Loaded addon " + addon.getName() + " v" + addon.getVersion() + ", by " + addon.getAuthor());
|
logger.info("Loaded addon {} v{}, by {}", addon.getName(), addon.getVersion(), addon.getAuthor());
|
||||||
return super.register(identifier, addon);
|
return super.register(identifier, addon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +57,7 @@ public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
|||||||
return loadAll(TerraPlugin.class.getClassLoader());
|
return loadAll(TerraPlugin.class.getClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "NestedTryStatement", "ThrowCaughtLocally" })
|
||||||
public boolean loadAll(ClassLoader parent) {
|
public boolean loadAll(ClassLoader parent) {
|
||||||
InjectorImpl<TerraPlugin> pluginInjector = new InjectorImpl<>(main);
|
InjectorImpl<TerraPlugin> pluginInjector = new InjectorImpl<>(main);
|
||||||
pluginInjector.addExplicitTarget(TerraPlugin.class);
|
pluginInjector.addExplicitTarget(TerraPlugin.class);
|
||||||
@@ -64,7 +70,7 @@ public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for(File jar : addonsFolder.listFiles(file -> file.getName().endsWith(".jar"))) {
|
for(File jar : addonsFolder.listFiles(file -> file.getName().endsWith(".jar"))) {
|
||||||
main.logger().info("Loading Addon(s) from: " + jar.getName());
|
logger.info("Loading Addon(s) from: " + jar.getName());
|
||||||
for(Class<? extends TerraAddon> addonClass : AddonClassLoader.fetchAddonClasses(jar, parent)) {
|
for(Class<? extends TerraAddon> addonClass : AddonClassLoader.fetchAddonClasses(jar, parent)) {
|
||||||
pool.add(new PreLoadAddon(addonClass, jar));
|
pool.add(new PreLoadAddon(addonClass, jar));
|
||||||
}
|
}
|
||||||
@@ -82,8 +88,9 @@ public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
|||||||
if(!LogManager.getLogManager().addLogger(addonLogger)) {
|
if(!LogManager.getLogManager().addLogger(addonLogger)) {
|
||||||
addonLogger = LogManager.getLogManager().getLogger(logPrefix);
|
addonLogger = LogManager.getLogManager().getLogger(logPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
InjectorImpl<Logger> loggerInjector = new InjectorImpl<>(addonLogger);
|
// TODO: 2021-08-30 Remove logger injector entirely?
|
||||||
|
Injector<Logger> loggerInjector = new InjectorImpl<>(addonLogger);
|
||||||
loggerInjector.addExplicitTarget(Logger.class);
|
loggerInjector.addExplicitTarget(Logger.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -97,19 +104,24 @@ public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
|||||||
pluginInjector.inject(loadedAddon);
|
pluginInjector.inject(loadedAddon);
|
||||||
loggerInjector.inject(loadedAddon);
|
loggerInjector.inject(loadedAddon);
|
||||||
} catch(InstantiationException | IllegalAccessException | InvocationTargetException | InjectionException e) {
|
} catch(InstantiationException | IllegalAccessException | InvocationTargetException | InjectionException e) {
|
||||||
throw new AddonLoadException("Failed to load com.dfsek.terra.addon \" + " + addon.getId() + "\": ", e);
|
throw new AddonLoadException(String.format("Failed to load addon \"%s\"", addon.getId()), e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
registerChecked(loadedAddon.getName(), loadedAddon);
|
registerChecked(loadedAddon.getName(), loadedAddon);
|
||||||
} catch(DuplicateEntryException e) {
|
} catch(DuplicateEntryException e) {
|
||||||
valid = false;
|
valid = false;
|
||||||
main.logger().severe("Duplicate addon ID; addon with ID " + loadedAddon.getName() + " is already loaded.");
|
logger.error("""
|
||||||
main.logger().severe("Existing addon class: " + get(loadedAddon.getName()).getClass().getCanonicalName());
|
Duplicate addon ID; addon with ID {} is already loaded.
|
||||||
main.logger().severe("Duplicate addon class: " + addonClass.getCanonicalName());
|
Existing addon class: {}
|
||||||
|
Duplicate addon class: {}
|
||||||
|
""",
|
||||||
|
loadedAddon.getName(),
|
||||||
|
get(loadedAddon.getName()).getClass().getCanonicalName(),
|
||||||
|
addonClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(AddonLoadException | IOException e) {
|
} catch(AddonLoadException | IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("Failed during addon loading", e);
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.dfsek.terra.registry.master;
|
package com.dfsek.terra.registry.master;
|
||||||
|
|
||||||
import com.dfsek.tectonic.exception.ConfigException;
|
import com.dfsek.tectonic.exception.ConfigException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -16,6 +18,8 @@ import com.dfsek.terra.registry.OpenRegistryImpl;
|
|||||||
* Class to hold config packs
|
* Class to hold config packs
|
||||||
*/
|
*/
|
||||||
public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ConfigRegistry.class);
|
||||||
|
|
||||||
public void load(File folder, TerraPlugin main) throws ConfigException {
|
public void load(File folder, TerraPlugin main) throws ConfigException {
|
||||||
ConfigPack pack = new ConfigPackImpl(folder, main);
|
ConfigPack pack = new ConfigPackImpl(folder, main);
|
||||||
register(pack.getID(), pack);
|
register(pack.getID(), pack);
|
||||||
@@ -29,16 +33,16 @@ public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
|||||||
try {
|
try {
|
||||||
load(dir, main);
|
load(dir, main);
|
||||||
} catch(ConfigException e) {
|
} catch(ConfigException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error loading config pack {}", dir.getName(), e);
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(File zip : packsFolder.listFiles(file -> file.getName().endsWith(".zip") || file.getName().endsWith(".terra"))) {
|
for(File zip : packsFolder.listFiles(file -> file.getName().endsWith(".zip") || file.getName().endsWith(".terra"))) {
|
||||||
try {
|
try {
|
||||||
main.getDebugLogger().info("Loading ZIP archive: " + zip.getName());
|
logger.info("Loading ZIP archive: " + zip.getName());
|
||||||
load(new ZipFile(zip), main);
|
load(new ZipFile(zip), main);
|
||||||
} catch(IOException | ConfigException e) {
|
} catch(IOException | ConfigException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error loading config pack {}", zip.getName(), e);
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.dfsek.terra.util.logging;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
public class DebugLogger implements Logger {
|
|
||||||
private final Logger logger;
|
|
||||||
private boolean debug = false;
|
|
||||||
|
|
||||||
public DebugLogger(Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void info(String message) {
|
|
||||||
if(debug) logger.info(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void warning(String message) {
|
|
||||||
if(debug) logger.warning(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void severe(String message) {
|
|
||||||
if(debug) logger.severe(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stack(Throwable e) {
|
|
||||||
if(debug) e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDebug() {
|
|
||||||
return debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDebug(boolean debug) {
|
|
||||||
this.debug = debug;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.dfsek.terra.util.logging;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
public class JavaLogger implements Logger {
|
|
||||||
private final java.util.logging.Logger logger;
|
|
||||||
|
|
||||||
public JavaLogger(java.util.logging.Logger logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String message) {
|
|
||||||
logger.info(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(String message) {
|
|
||||||
logger.warning(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void severe(String message) {
|
|
||||||
logger.severe(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,8 @@ val purpurURL = "https://ci.pl3x.net/job/Purpur/lastSuccessfulBuild/artifact/fin
|
|||||||
dependencies {
|
dependencies {
|
||||||
"shadedApi"(project(":common:implementation"))
|
"shadedApi"(project(":common:implementation"))
|
||||||
|
|
||||||
|
"shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||||
|
|
||||||
"compileOnly"("io.papermc.paper:paper-api:1.17-R0.1-SNAPSHOT")
|
"compileOnly"("io.papermc.paper:paper-api:1.17-R0.1-SNAPSHOT")
|
||||||
"shadedImplementation"("io.papermc:paperlib:1.0.5")
|
"shadedImplementation"("io.papermc:paperlib:1.0.5")
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -31,6 +33,7 @@ import com.dfsek.terra.commands.TerraCommandManager;
|
|||||||
|
|
||||||
public class TerraBukkitPlugin extends JavaPlugin {
|
public class TerraBukkitPlugin extends JavaPlugin {
|
||||||
public static final BukkitVersion BUKKIT_VERSION;
|
public static final BukkitVersion BUKKIT_VERSION;
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(TerraBukkitPlugin.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String ver = Bukkit.getServer().getClass().getPackage().getName();
|
String ver = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
@@ -53,9 +56,9 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getLogger().info("Running on version " + BUKKIT_VERSION);
|
logger.info("Running on version {}", BUKKIT_VERSION);
|
||||||
if(BUKKIT_VERSION == BukkitVersion.UNKNOWN) {
|
if(BUKKIT_VERSION == BukkitVersion.UNKNOWN) {
|
||||||
getLogger().warning("Terra is running on an unknown Bukkit version. Proceed with caution.");
|
logger.warn("Terra is running on an unknown Bukkit version. Proceed with caution.");
|
||||||
}
|
}
|
||||||
|
|
||||||
terraPlugin.getEventManager().callEvent(new PlatformInitializationEvent());
|
terraPlugin.getEventManager().callEvent(new PlatformInitializationEvent());
|
||||||
@@ -72,9 +75,12 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
manager.register("save-data", SaveDataCommand.class);
|
manager.register("save-data", SaveDataCommand.class);
|
||||||
manager.register("fix-chunk", FixChunkCommand.class);
|
manager.register("fix-chunk", FixChunkCommand.class);
|
||||||
} catch(MalformedCommandException e) { // This should never happen.
|
} catch(MalformedCommandException e) { // This should never happen.
|
||||||
terraPlugin.logger().severe("Errors occurred while registering commands.");
|
logger.error("""
|
||||||
e.printStackTrace();
|
TERRA HAS BEEN DISABLED
|
||||||
terraPlugin.logger().severe("Please report this to Terra.");
|
|
||||||
|
Errors occurred while registering commands.
|
||||||
|
Please report this to Terra.
|
||||||
|
""", e);
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -115,21 +121,21 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
private void registerSpigotEvents(boolean outdated) {
|
private void registerSpigotEvents(boolean outdated) {
|
||||||
if(outdated) {
|
if(outdated) {
|
||||||
getLogger().severe("You are using an outdated version of Paper.");
|
logger.error("You are using an outdated version of Paper.");
|
||||||
getLogger().severe("This version does not contain StructureLocateEvent.");
|
logger.error("This version does not contain StructureLocateEvent.");
|
||||||
getLogger().severe("Terra will now fall back to Spigot events.");
|
logger.error("Terra will now fall back to Spigot events.");
|
||||||
getLogger().severe("This will prevent cartographer villagers from spawning,");
|
logger.error("This will prevent cartographer villagers from spawning,");
|
||||||
getLogger().severe("and cause structure location to not function.");
|
logger.error("and cause structure location to not function.");
|
||||||
getLogger().severe("If you want these functionalities, update to the latest build of Paper.");
|
logger.error("If you want these functionalities, update to the latest build of Paper.");
|
||||||
getLogger().severe("If you use a fork, update to the latest version, then if you still");
|
logger.error("If you use a fork, update to the latest version, then if you still");
|
||||||
getLogger().severe("receive this message, ask the fork developer to update upstream.");
|
logger.error("receive this message, ask the fork developer to update upstream.");
|
||||||
} else {
|
} else {
|
||||||
getLogger().severe("Paper is not in use. Falling back to Spigot events.");
|
logger.error("Paper is not in use. Falling back to Spigot events.");
|
||||||
getLogger().severe("This will prevent cartographer villagers from spawning,");
|
logger.error("This will prevent cartographer villagers from spawning,");
|
||||||
getLogger().severe("and cause structure location to not function.");
|
logger.error("and cause structure location to not function.");
|
||||||
getLogger().severe("If you want these functionalities (and all the other");
|
logger.error("If you want these functionalities (and all the other");
|
||||||
getLogger().severe("benefits that Paper offers), upgrade your server to Paper.");
|
logger.error("benefits that Paper offers), upgrade your server to Paper.");
|
||||||
getLogger().severe("Find out more at https://papermc.io/");
|
logger.error("Find out more at https://papermc.io/");
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new SpigotListener(terraPlugin), this); // Register Spigot event listener
|
Bukkit.getPluginManager().registerEvents(new SpigotListener(terraPlugin), this); // Register Spigot event listener
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import java.util.Locale;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.dfsek.terra.AbstractTerraPlugin;
|
import com.dfsek.terra.AbstractTerraPlugin;
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.handle.ItemHandle;
|
import com.dfsek.terra.api.handle.ItemHandle;
|
||||||
@@ -19,7 +18,6 @@ import com.dfsek.terra.api.world.biome.Biome;
|
|||||||
import com.dfsek.terra.bukkit.handles.BukkitItemHandle;
|
import com.dfsek.terra.bukkit.handles.BukkitItemHandle;
|
||||||
import com.dfsek.terra.bukkit.handles.BukkitWorldHandle;
|
import com.dfsek.terra.bukkit.handles.BukkitWorldHandle;
|
||||||
import com.dfsek.terra.bukkit.world.BukkitBiome;
|
import com.dfsek.terra.bukkit.world.BukkitBiome;
|
||||||
import com.dfsek.terra.util.logging.JavaLogger;
|
|
||||||
|
|
||||||
|
|
||||||
public class TerraPluginImpl extends AbstractTerraPlugin {
|
public class TerraPluginImpl extends AbstractTerraPlugin {
|
||||||
@@ -78,11 +76,6 @@ public class TerraPluginImpl extends AbstractTerraPlugin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Logger createLogger() {
|
|
||||||
return new JavaLogger(plugin.getLogger());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Optional<TerraAddon> getPlatformAddon() {
|
protected Optional<TerraAddon> getPlatformAddon() {
|
||||||
return Optional.of(new BukkitAddon(this));
|
return Optional.of(new BukkitAddon(this));
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -20,6 +22,8 @@ import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
|||||||
|
|
||||||
|
|
||||||
public class BukkitCommandAdapter implements CommandExecutor, TabCompleter {
|
public class BukkitCommandAdapter implements CommandExecutor, TabCompleter {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(BukkitCommandAdapter.class);
|
||||||
|
|
||||||
private final CommandManager manager;
|
private final CommandManager manager;
|
||||||
|
|
||||||
public BukkitCommandAdapter(CommandManager manager) {
|
public BukkitCommandAdapter(CommandManager manager) {
|
||||||
@@ -51,7 +55,7 @@ public class BukkitCommandAdapter implements CommandExecutor, TabCompleter {
|
|||||||
.filter(s -> s.toLowerCase(Locale.ROOT).startsWith(args[args.length - 1].toLowerCase(Locale.ROOT))).sorted(
|
.filter(s -> s.toLowerCase(Locale.ROOT).startsWith(args[args.length - 1].toLowerCase(Locale.ROOT))).sorted(
|
||||||
String::compareTo).collect(Collectors.toList());
|
String::compareTo).collect(Collectors.toList());
|
||||||
} catch(CommandException e) {
|
} catch(CommandException e) {
|
||||||
e.printStackTrace();
|
logger.warn("Exception occurred during tab completion", e);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.dfsek.terra.bukkit.generator;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -23,6 +25,7 @@ import com.dfsek.terra.bukkit.world.BukkitBiomeGrid;
|
|||||||
|
|
||||||
|
|
||||||
public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGenerator implements GeneratorWrapper {
|
public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGenerator implements GeneratorWrapper {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(BukkitChunkGeneratorWrapper.class);
|
||||||
|
|
||||||
private static final Map<com.dfsek.terra.api.world.World, PopulationManager> popMap = new HashMap<>();
|
private static final Map<com.dfsek.terra.api.world.World, PopulationManager> popMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -44,17 +47,17 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
|||||||
|
|
||||||
|
|
||||||
public static synchronized void saveAll() {
|
public static synchronized void saveAll() {
|
||||||
for(Map.Entry<com.dfsek.terra.api.world.World, PopulationManager> e : popMap.entrySet()) {
|
for(Map.Entry<com.dfsek.terra.api.world.World, PopulationManager> entry : popMap.entrySet()) {
|
||||||
try {
|
try {
|
||||||
e.getValue().saveBlocks(e.getKey());
|
entry.getValue().saveBlocks(entry.getKey());
|
||||||
} catch(IOException ioException) {
|
} catch(IOException e) {
|
||||||
ioException.printStackTrace();
|
logger.error("Error occurred while saving population manager", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void fixChunk(Chunk c) {
|
public static synchronized void fixChunk(Chunk chunk) {
|
||||||
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
|
popMap.get(chunk.getWorld()).checkNeighbors(chunk.getX(), chunk.getZ(), chunk.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(com.dfsek.terra.api.world.World w) {
|
private void load(com.dfsek.terra.api.world.World w) {
|
||||||
@@ -63,7 +66,7 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
|||||||
} catch(FileNotFoundException ignore) {
|
} catch(FileNotFoundException ignore) {
|
||||||
|
|
||||||
} catch(IOException | ClassNotFoundException e) {
|
} catch(IOException | ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error occurred while loading terra world", e);
|
||||||
}
|
}
|
||||||
popMap.put(w, popMan);
|
popMap.put(w, popMan);
|
||||||
needsLoad = false;
|
needsLoad = false;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
||||||
import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
|
|
||||||
@@ -18,6 +20,8 @@ import com.dfsek.terra.api.TerraPlugin;
|
|||||||
* StructureLocateEvent).
|
* StructureLocateEvent).
|
||||||
*/
|
*/
|
||||||
public class SpigotListener implements Listener {
|
public class SpigotListener implements Listener {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SpigotListener.class);
|
||||||
|
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
|
||||||
public SpigotListener(TerraPlugin main) {
|
public SpigotListener(TerraPlugin main) {
|
||||||
@@ -26,46 +30,57 @@ public class SpigotListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEnderEye(EntitySpawnEvent e) {
|
public void onEnderEye(EntitySpawnEvent e) {
|
||||||
/*
|
/*
|
||||||
Entity entity = e.getEntity();
|
Entity entity = e.getEntity();
|
||||||
if(e.getEntityType().equals(EntityType.ENDER_SIGNAL)) {
|
if(e.getEntityType() == EntityType.ENDER_SIGNAL) {
|
||||||
main.getDebugLogger().info("Detected Ender Signal...");
|
logger.info("Detected Ender Signal...");
|
||||||
World w = BukkitAdapter.adapt(e.getEntity().getWorld());
|
World w = BukkitAdapter.adapt(e.getEntity().getWorld());
|
||||||
EnderSignal signal = (EnderSignal) entity;
|
EnderSignal signal = (EnderSignal) entity;
|
||||||
ConfiguredStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(w.getConfig().getLocatable().get
|
ConfiguredStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(w.getConfig().getLocatable().get
|
||||||
("STRONGHOLD"));
|
("STRONGHOLD"));
|
||||||
if(config != null) {
|
if(config != null) {
|
||||||
main.getDebugLogger().info("Overriding Ender Signal...");
|
logger.info("Overriding Ender Signal...");
|
||||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getLocation()
|
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getLocation()
|
||||||
.toVector()), tw.getWorld(), 0, 500, location -> {
|
.toVector()), tw.getWorld(), 0, 500, location -> {
|
||||||
if(location != null)
|
if(location != null)
|
||||||
signal.setTargetLocation(BukkitAdapter.adapt(location).toLocation(e.getLocation().getWorld()));
|
signal.setTargetLocation(BukkitAdapter.adapt(location).toLocation(e.getLocation().getWorld()));
|
||||||
main.getDebugLogger().info("Location: " + location);
|
logger.info("Location: {}", location);
|
||||||
}, main);
|
}, main);
|
||||||
finder.run(); // Do this synchronously so eye doesn't change direction several ticks after spawning.
|
finder.run(); // Do this synchronously so eye doesn't change direction several ticks after spawning.
|
||||||
} else
|
} else
|
||||||
main.logger().warning("No overrides are defined for Strongholds. Ender Signals will not work correctly.");
|
logger.warn("No overrides are defined for Strongholds. Ender Signals will not work correctly.");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCartographerChange(VillagerAcquireTradeEvent e) {
|
public void onCartographerChange(VillagerAcquireTradeEvent e) {
|
||||||
if(!(e.getEntity() instanceof Villager)) return;
|
if(!(e.getEntity() instanceof Villager))
|
||||||
if(((Villager) e.getEntity()).getProfession().equals(Villager.Profession.CARTOGRAPHER)) {
|
return;
|
||||||
main.logger().severe("Prevented server crash by stopping Cartographer villager from spawning.");
|
if(((Villager) e.getEntity()).getProfession() == Villager.Profession.CARTOGRAPHER) {
|
||||||
main.logger().severe("Please upgrade to Paper, which has a StructureLocateEvent that fixes this issue");
|
logger.error("""
|
||||||
main.logger().severe("at the source, and doesn't require us to do stupid band-aids.");
|
.------------------------------------------------------------------------.
|
||||||
|
| Prevented server crash by stopping Cartographer villager from |
|
||||||
|
| spawning. Please upgrade to Paper, which has a StructureLocateEvent |
|
||||||
|
| that fixes this issue at the source, and doesn't require us to do |
|
||||||
|
| stupid band-aids. |
|
||||||
|
|------------------------------------------------------------------------|
|
||||||
|
""");
|
||||||
e.setCancelled(true); // Cancel leveling if the villager is a Cartographer, to prevent crashing server.
|
e.setCancelled(true); // Cancel leveling if the villager is a Cartographer, to prevent crashing server.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCartographerLevel(VillagerCareerChangeEvent e) {
|
public void onCartographerLevel(VillagerCareerChangeEvent e) {
|
||||||
if(e.getProfession().equals(Villager.Profession.CARTOGRAPHER)) {
|
if(e.getProfession() == Villager.Profession.CARTOGRAPHER) {
|
||||||
main.logger().severe("Prevented server crash by stopping Cartographer villager from spawning.");
|
logger.error("""
|
||||||
main.logger().severe("Please upgrade to Paper, which has a StructureLocateEvent that fixes this issue");
|
.------------------------------------------------------------------------.
|
||||||
main.logger().severe("at the source, and doesn't require us to do stupid band-aids.");
|
| Prevented server crash by stopping Cartographer villager from leveling |
|
||||||
|
| up. Please upgrade to Paper, which has a StructureLocateEvent that |
|
||||||
|
| fixes this issue at the source, and doesn't require us to do stupid |
|
||||||
|
| band-aids. |
|
||||||
|
|------------------------------------------------------------------------|
|
||||||
|
""");
|
||||||
e.getEntity().setProfession(Villager.Profession.NITWIT); // Give villager new profession to prevent server crash.
|
e.getEntity().setProfession(Villager.Profession.NITWIT); // Give villager new profession to prevent server crash.
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ tasks.named<ShadowJar>("shadowJar") {
|
|||||||
dependencies {
|
dependencies {
|
||||||
"shadedApi"(project(":common:implementation"))
|
"shadedApi"(project(":common:implementation"))
|
||||||
|
|
||||||
|
"shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||||
|
|
||||||
"minecraft"("com.mojang:minecraft:1.17.1")
|
"minecraft"("com.mojang:minecraft:1.17.1")
|
||||||
"mappings"("net.fabricmc:yarn:1.17.1+build.1:v2")
|
"mappings"("net.fabricmc:yarn:1.17.1+build.1:v2")
|
||||||
"modImplementation"("net.fabricmc:fabric-loader:0.11.3")
|
"modImplementation"("net.fabricmc:fabric-loader:0.11.3")
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import net.minecraft.util.registry.BuiltinRegistries;
|
|||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -33,6 +35,8 @@ import com.dfsek.terra.fabric.util.FabricUtil;
|
|||||||
@Author("Terra")
|
@Author("Terra")
|
||||||
@Version("1.0.0")
|
@Version("1.0.0")
|
||||||
public final class FabricAddon extends TerraAddon {
|
public final class FabricAddon extends TerraAddon {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FabricAddon.class);
|
||||||
|
|
||||||
private final TerraPluginImpl terraFabricPlugin;
|
private final TerraPluginImpl terraFabricPlugin;
|
||||||
private final Map<ConfigPack, Pair<PreLoadCompatibilityOptions, PostLoadCompatibilityOptions>> templates = new HashMap<>();
|
private final Map<ConfigPack, Pair<PreLoadCompatibilityOptions, PostLoadCompatibilityOptions>> templates = new HashMap<>();
|
||||||
|
|
||||||
@@ -50,7 +54,7 @@ public final class FabricAddon extends TerraAddon {
|
|||||||
try {
|
try {
|
||||||
event.loadTemplate(template);
|
event.loadTemplate(template);
|
||||||
} catch(ConfigException e) {
|
} catch(ConfigException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error loading config template", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(template.doRegistryInjection()) {
|
if(template.doRegistryInjection()) {
|
||||||
@@ -59,8 +63,7 @@ public final class FabricAddon extends TerraAddon {
|
|||||||
try {
|
try {
|
||||||
event.getPack().getCheckedRegistry(Tree.class).register(entry.getKey().getValue().toString(),
|
event.getPack().getCheckedRegistry(Tree.class).register(entry.getKey().getValue().toString(),
|
||||||
(Tree) entry.getValue());
|
(Tree) entry.getValue());
|
||||||
terraFabricPlugin.getDebugLogger().info(
|
logger.info("Injected ConfiguredFeature {} as Tree.", entry.getKey().getValue());
|
||||||
"Injected ConfiguredFeature " + entry.getKey().getValue() + " as Tree.");
|
|
||||||
} catch(DuplicateEntryException ignored) {
|
} catch(DuplicateEntryException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +82,7 @@ public final class FabricAddon extends TerraAddon {
|
|||||||
try {
|
try {
|
||||||
event.loadTemplate(template);
|
event.loadTemplate(template);
|
||||||
} catch(ConfigException e) {
|
} catch(ConfigException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error loading config templatE", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.get(event.getPack()).setRight(template);
|
templates.get(event.getPack()).setRight(template);
|
||||||
@@ -91,7 +94,7 @@ public final class FabricAddon extends TerraAddon {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(this, BiomeRegistrationEvent.class)
|
.register(this, BiomeRegistrationEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
terraFabricPlugin.logger().info("Registering biomes...");
|
logger.info("Registering biomes...");
|
||||||
Registry<Biome> biomeRegistry = event.getRegistryManager().get(Registry.BIOME_KEY);
|
Registry<Biome> biomeRegistry = event.getRegistryManager().get(Registry.BIOME_KEY);
|
||||||
terraFabricPlugin.getConfigRegistry().forEach(pack -> pack.getCheckedRegistry(TerraBiome.class)
|
terraFabricPlugin.getConfigRegistry().forEach(pack -> pack.getCheckedRegistry(TerraBiome.class)
|
||||||
.forEach(
|
.forEach(
|
||||||
@@ -102,7 +105,7 @@ public final class FabricAddon extends TerraAddon {
|
|||||||
pack, id)),
|
pack, id)),
|
||||||
FabricUtil.createBiome(biome, pack,
|
FabricUtil.createBiome(biome, pack,
|
||||||
event.getRegistryManager())))); // Register all Terra biomes.
|
event.getRegistryManager())))); // Register all Terra biomes.
|
||||||
terraFabricPlugin.logger().info("Biomes registered.");
|
logger.info("Biomes registered.");
|
||||||
})
|
})
|
||||||
.global();
|
.global();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ import com.dfsek.tectonic.loading.TypeRegistry;
|
|||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.BuiltinRegistries;
|
import net.minecraft.util.registry.BuiltinRegistries;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.dfsek.terra.AbstractTerraPlugin;
|
import com.dfsek.terra.AbstractTerraPlugin;
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
import com.dfsek.terra.api.handle.ItemHandle;
|
import com.dfsek.terra.api.handle.ItemHandle;
|
||||||
import com.dfsek.terra.api.handle.WorldHandle;
|
import com.dfsek.terra.api.handle.WorldHandle;
|
||||||
@@ -72,27 +70,6 @@ public class TerraPluginImpl extends AbstractTerraPlugin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Logger createLogger() {
|
|
||||||
final org.apache.logging.log4j.Logger log4jLogger = LogManager.getLogger();
|
|
||||||
return new Logger() {
|
|
||||||
@Override
|
|
||||||
public void info(String message) {
|
|
||||||
log4jLogger.info(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(String message) {
|
|
||||||
log4jLogger.warn(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void severe(String message) {
|
|
||||||
log4jLogger.error(message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Optional<TerraAddon> getPlatformAddon() {
|
protected Optional<TerraAddon> getPlatformAddon() {
|
||||||
return Optional.of(new FabricAddon(this));
|
return Optional.of(new FabricAddon(this));
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import net.minecraft.world.gen.chunk.StructuresConfig;
|
|||||||
import net.minecraft.world.gen.chunk.VerticalBlockSample;
|
import net.minecraft.world.gen.chunk.VerticalBlockSample;
|
||||||
import net.minecraft.world.gen.feature.StructureFeature;
|
import net.minecraft.world.gen.feature.StructureFeature;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@@ -42,6 +44,8 @@ import com.dfsek.terra.util.FastRandom;
|
|||||||
|
|
||||||
|
|
||||||
public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.ChunkGenerator implements GeneratorWrapper {
|
public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.ChunkGenerator implements GeneratorWrapper {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FabricChunkGeneratorWrapper.class);
|
||||||
|
|
||||||
public static final Codec<ConfigPack> PACK_CODEC = RecordCodecBuilder.create(
|
public static final Codec<ConfigPack> PACK_CODEC = RecordCodecBuilder.create(
|
||||||
config -> config.group(
|
config -> config.group(
|
||||||
Codec.STRING.fieldOf("pack")
|
Codec.STRING.fieldOf("pack")
|
||||||
@@ -71,7 +75,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
this.pack = configPack;
|
this.pack = configPack;
|
||||||
|
|
||||||
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
||||||
delegate.getMain().logger().info("Loading world with config pack " + pack.getID());
|
logger.info("Loading world with config pack {}", pack.getID());
|
||||||
this.biomeSource = biomeSource;
|
this.biomeSource = biomeSource;
|
||||||
|
|
||||||
this.seed = seed;
|
this.seed = seed;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import net.minecraft.world.gen.Spawner;
|
|||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.ServerWorldProperties;
|
import net.minecraft.world.level.ServerWorldProperties;
|
||||||
import net.minecraft.world.level.storage.LevelStorage;
|
import net.minecraft.world.level.storage.LevelStorage;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -18,12 +20,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
|
||||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||||
|
|
||||||
|
|
||||||
@Mixin(ServerWorld.class)
|
@Mixin(ServerWorld.class)
|
||||||
public abstract class ServerWorldMixin {
|
public abstract class ServerWorldMixin {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ServerWorldMixin.class);
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session,
|
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session,
|
||||||
ServerWorldProperties properties, RegistryKey<World> registryKey, DimensionType dimensionType,
|
ServerWorldProperties properties, RegistryKey<World> registryKey, DimensionType dimensionType,
|
||||||
@@ -31,7 +34,7 @@ public abstract class ServerWorldMixin {
|
|||||||
boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
||||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
||||||
((FabricChunkGeneratorWrapper) chunkGenerator).setWorld((ServerWorld) (Object) this);
|
((FabricChunkGeneratorWrapper) chunkGenerator).setWorld((ServerWorld) (Object) this);
|
||||||
FabricEntryPoint.getTerraPlugin().logger().info("Registered world " + this);
|
logger.info("Registered world {}", this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ java {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
"shadedApi"(project(":common:implementation"))
|
"shadedApi"(project(":common:implementation"))
|
||||||
|
|
||||||
|
"shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||||
|
|
||||||
"annotationProcessor"("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
"annotationProcessor"("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
||||||
"shadedImplementation"("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
"shadedImplementation"("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
||||||
"annotationProcessor"("org.spongepowered:mixin:0.8.2:processor")
|
"annotationProcessor"("org.spongepowered:mixin:0.8.2:processor")
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import org.spongepowered.api.Sponge;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import com.dfsek.terra.AbstractTerraPlugin;
|
import com.dfsek.terra.AbstractTerraPlugin;
|
||||||
import com.dfsek.terra.api.Logger;
|
|
||||||
import com.dfsek.terra.api.handle.ItemHandle;
|
import com.dfsek.terra.api.handle.ItemHandle;
|
||||||
import com.dfsek.terra.api.handle.WorldHandle;
|
import com.dfsek.terra.api.handle.WorldHandle;
|
||||||
import com.dfsek.terra.sponge.handle.SpongeWorldHandle;
|
import com.dfsek.terra.sponge.handle.SpongeWorldHandle;
|
||||||
@@ -44,24 +43,4 @@ public class TerraPluginImpl extends AbstractTerraPlugin {
|
|||||||
public ItemHandle getItemHandle() {
|
public ItemHandle getItemHandle() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Logger createLogger() {
|
|
||||||
return new Logger() {
|
|
||||||
@Override
|
|
||||||
public void info(String message) {
|
|
||||||
plugin.getPluginContainer().logger().info(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(String message) {
|
|
||||||
plugin.getPluginContainer().logger().warn(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void severe(String message) {
|
|
||||||
plugin.getPluginContainer().logger().error(message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user