mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
Make logging actually work
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
@@ -94,45 +94,18 @@ public abstract class AbstractPlatform implements Platform {
|
||||
|
||||
private final Registry<BaseAddon> lockedAddonRegistry = new LockedRegistryImpl<>(addonRegistry);
|
||||
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
loaders.register(registry);
|
||||
public ConfigRegistry getRawConfigRegistry() {
|
||||
return configRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginConfig getTerraConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return LangUtil.getLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckedRegistry<ConfigPack> getConfigRegistry() {
|
||||
return checkedConfigRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registry<BaseAddon> getAddons() {
|
||||
return lockedAddonRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventManager getEventManager() {
|
||||
return eventManager;
|
||||
public CommandManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
protected Optional<BaseAddon> platformAddon() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profiler getProfiler() {
|
||||
return profiler;
|
||||
}
|
||||
|
||||
protected void load() {
|
||||
if(LOADED.get()) {
|
||||
throw new IllegalStateException(
|
||||
@@ -257,11 +230,38 @@ public abstract class AbstractPlatform implements Platform {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public ConfigRegistry getRawConfigRegistry() {
|
||||
return configRegistry;
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
loaders.register(registry);
|
||||
}
|
||||
|
||||
public CommandManager getManager() {
|
||||
return manager;
|
||||
@Override
|
||||
public PluginConfig getTerraConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return LangUtil.getLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckedRegistry<ConfigPack> getConfigRegistry() {
|
||||
return checkedConfigRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registry<BaseAddon> getAddons() {
|
||||
return lockedAddonRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventManager getEventManager() {
|
||||
return eventManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profiler getProfiler() {
|
||||
return profiler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.io.UncheckedIOException;
|
||||
import java.time.Duration;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.util.Logger;
|
||||
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.Objects;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.lang.Language;
|
||||
import com.dfsek.terra.api.util.Logger;
|
||||
|
||||
|
||||
public final class LangUtil {
|
||||
|
||||
@@ -65,8 +65,8 @@ public class FunctionalEventHandlerImpl implements FunctionalEventHandler {
|
||||
if(context.isFailThrough() && event instanceof FailThroughEvent)
|
||||
throw e; // Rethrow if it's fail-through.
|
||||
// else warn
|
||||
logger.warn("Exception occurred during event handling. Report this to the maintainers of {}, {}",
|
||||
context.getAddon().getID(), context.getAddon().getAuthor(), e);
|
||||
logger.warn("Exception occurred during event handling. Report this to the maintainers of {}@{}",
|
||||
context.getAddon().getID(), context.getAddon().getVersion().getFormatted(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
|
||||
package com.dfsek.terra.addon;
|
||||
|
||||
import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -26,31 +31,29 @@ import java.nio.file.Path;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.addon.exception.AddonLoadException;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
|
||||
public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAddon<?>> {
|
||||
private final Platform platform;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BootstrapAddonLoader.class);
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
private final Platform platform;
|
||||
|
||||
public BootstrapAddonLoader(Platform platform) { this.platform = platform; }
|
||||
|
||||
@Override
|
||||
public Iterable<BootstrapBaseAddon<?>> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
Path bootstrapAddons = addonsFolder.resolve("bootstrap");
|
||||
platform.logger().info("Loading bootstrap addons from " + bootstrapAddons);
|
||||
logger.info("Loading bootstrap addons from {}", bootstrapAddons);
|
||||
try {
|
||||
return Files.walk(bootstrapAddons, 1)
|
||||
.filter(path -> path.toFile().isFile() && path.toString().endsWith(".jar"))
|
||||
.map(path -> {
|
||||
try {
|
||||
platform.logger().info("Loading bootstrap addon from JAR " + path);
|
||||
logger.info("Loading bootstrap addon from JAR {}", path);
|
||||
JarFile jar = new JarFile(path.toFile());
|
||||
String entry = jar.getManifest().getMainAttributes().getValue("Bootstrap-Addon-Entry-Point");
|
||||
|
||||
@@ -65,7 +68,7 @@ public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAdd
|
||||
if(!(in instanceof BootstrapBaseAddon)) {
|
||||
throw new AddonLoadException(in.getClass() + " does not extend " + BootstrapBaseAddon.class);
|
||||
}
|
||||
platform.logger().info("Loaded bootstrap addon " + ((BootstrapBaseAddon<?>) in).getID());
|
||||
logger.info("Loaded bootstrap addon {}", ((BootstrapBaseAddon<?>) in).getID());
|
||||
return (BootstrapBaseAddon<?>) in;
|
||||
} catch(InvocationTargetException e) {
|
||||
throw new AddonLoadException("Exception occurred while instantiating addon: ", e);
|
||||
|
||||
@@ -17,7 +17,8 @@ val purpurURL = "https://ci.pl3x.net/job/Purpur/lastSuccessfulBuild/artifact/fin
|
||||
dependencies {
|
||||
"shadedApi"(project(":common:implementation"))
|
||||
|
||||
"shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
shadedImplementation("org.slf4j:slf4j-log4j12:1.7.32")
|
||||
// "shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
|
||||
"compileOnly"("io.papermc.paper:paper-api:1.17-R0.1-SNAPSHOT")
|
||||
"shadedImplementation"("io.papermc:paperlib:1.0.5")
|
||||
|
||||
@@ -24,7 +24,8 @@ val fabricLoader = "0.12.5"
|
||||
dependencies {
|
||||
"shadedApi"(project(":common:implementation"))
|
||||
|
||||
"shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
shadedImplementation("org.slf4j:slf4j-log4j12:1.7.32")
|
||||
// shadedImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
|
||||
"minecraft"("com.mojang:minecraft:$minecraft")
|
||||
"mappings"("net.fabricmc:yarn:$minecraft+build.$yarn:v2")
|
||||
|
||||
@@ -20,12 +20,6 @@ package com.dfsek.terra.fabric;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.gen.decorator.Decorator;
|
||||
import net.minecraft.world.gen.decorator.NopeDecoratorConfig;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ package com.dfsek.terra.fabric;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -33,9 +30,9 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.AbstractPlatform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.util.Logger;
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
|
||||
@@ -17,17 +17,6 @@
|
||||
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generator.Chunkified;
|
||||
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
|
||||
import com.dfsek.terra.util.FastRandom;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -46,15 +35,18 @@ import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.biome.source.BiomeAccess;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil.MultiNoiseSampler;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil.NoiseValuePoint;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.GenerationStep.Carver;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.Blender;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
import net.minecraft.world.gen.chunk.VerticalBlockSample;
|
||||
import net.minecraft.world.gen.feature.*;
|
||||
import net.minecraft.world.gen.feature.NetherFortressFeature;
|
||||
import net.minecraft.world.gen.feature.OceanMonumentFeature;
|
||||
import net.minecraft.world.gen.feature.PillagerOutpostFeature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import net.minecraft.world.gen.feature.SwampHutFeature;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -62,6 +54,17 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generator.Chunkified;
|
||||
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
|
||||
import com.dfsek.terra.util.FastRandom;
|
||||
|
||||
|
||||
public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.ChunkGenerator implements GeneratorWrapper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FabricChunkGeneratorWrapper.class);
|
||||
@@ -110,15 +113,17 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
return new FabricChunkGeneratorWrapper((TerraBiomeSource) this.biomeSource.withSeed(seed), seed, pack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiNoiseSampler getMultiNoiseSampler() {
|
||||
return (x, y, z) -> new NoiseValuePoint(0, 0, 0, 0, 0, 0);
|
||||
public void setPack(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
||||
biomeSource.setPack(pack);
|
||||
|
||||
logger.debug("Loading world with config pack {}", pack.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void carve(ChunkRegion chunkRegion, long seed, BiomeAccess biomeAccess, StructureAccessor structureAccessor, Chunk chunk,
|
||||
Carver generationStep) {
|
||||
|
||||
public MultiNoiseUtil.MultiNoiseSampler getMultiNoiseSampler() {
|
||||
return (x, y, z) -> new MultiNoiseUtil.NoiseValuePoint(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -285,12 +290,10 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
return pack;
|
||||
}
|
||||
|
||||
public void setPack(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
||||
biomeSource.setPack(pack);
|
||||
@Override
|
||||
public void carve(ChunkRegion chunkRegion, long seed, BiomeAccess biomeAccess, StructureAccessor structureAccessor, Chunk chunk,
|
||||
GenerationStep.Carver generationStep) {
|
||||
|
||||
delegate.getPlatform().logger().info("Loading world with config pack " + pack.getID());
|
||||
}
|
||||
|
||||
public void setWorld(ServerWorld world) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ repositories {
|
||||
dependencies {
|
||||
"shadedApi"(project(":common:implementation"))
|
||||
|
||||
"shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
shadedImplementation("org.slf4j:slf4j-log4j12:1.7.32")
|
||||
// "shadedImplementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
|
||||
"annotationProcessor"("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
||||
"shadedImplementation"("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
||||
|
||||
Reference in New Issue
Block a user