mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-14 03:36:03 +00:00
reformat
This commit is contained in:
@@ -18,12 +18,6 @@
|
||||
package com.dfsek.terra;
|
||||
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
|
||||
import com.dfsek.terra.addon.EphemeralAddon;
|
||||
import com.dfsek.terra.addon.InternalAddon;
|
||||
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,6 +41,8 @@ import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.addon.BootstrapAddonLoader;
|
||||
import com.dfsek.terra.addon.DependencySorter;
|
||||
import com.dfsek.terra.addon.EphemeralAddon;
|
||||
import com.dfsek.terra.addon.InternalAddon;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.command.CommandManager;
|
||||
@@ -61,6 +57,7 @@ import com.dfsek.terra.api.inject.impl.InjectorImpl;
|
||||
import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.mutable.MutableBoolean;
|
||||
import com.dfsek.terra.commands.CommandUtil;
|
||||
import com.dfsek.terra.commands.TerraCommandManager;
|
||||
@@ -184,14 +181,14 @@ public abstract class AbstractPlatform implements Platform {
|
||||
BootstrapAddonLoader bootstrapAddonLoader = new BootstrapAddonLoader();
|
||||
|
||||
Path addonsFolder = getDataFolder().toPath().resolve("addons");
|
||||
|
||||
|
||||
Injector<Platform> platformInjector = new InjectorImpl<>(this);
|
||||
platformInjector.addExplicitTarget(Platform.class);
|
||||
|
||||
|
||||
bootstrapAddonLoader.loadAddons(addonsFolder, getClass().getClassLoader())
|
||||
.forEach(bootstrapAddon -> {
|
||||
platformInjector.inject(bootstrapAddon);
|
||||
|
||||
|
||||
bootstrapAddon.loadAddons(addonsFolder, getClass().getClassLoader())
|
||||
.forEach(addonList::add);
|
||||
});
|
||||
@@ -201,7 +198,7 @@ public abstract class AbstractPlatform implements Platform {
|
||||
builder.append("Loading ")
|
||||
.append(addonList.size())
|
||||
.append(" Terra addons:");
|
||||
|
||||
|
||||
for(BaseAddon addon : addonList) {
|
||||
builder.append("\n ")
|
||||
.append("- ")
|
||||
@@ -209,10 +206,10 @@ public abstract class AbstractPlatform implements Platform {
|
||||
.append("@")
|
||||
.append(addon.getVersion().getFormatted());
|
||||
}
|
||||
|
||||
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
|
||||
DependencySorter sorter = new DependencySorter();
|
||||
addonList.forEach(sorter::add);
|
||||
sorter.sort().forEach(addon -> {
|
||||
@@ -222,7 +219,7 @@ public abstract class AbstractPlatform implements Platform {
|
||||
addonRegistry.register(addon.getID(), addon);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventManager.getHandler(FunctionalEventHandler.class)
|
||||
.register(internalAddon, PlatformInitializationEvent.class)
|
||||
.then(event -> {
|
||||
@@ -231,10 +228,10 @@ public abstract class AbstractPlatform implements Platform {
|
||||
logger.info("Loaded packs.");
|
||||
})
|
||||
.global();
|
||||
|
||||
|
||||
|
||||
|
||||
logger.info("Terra addons successfully loaded.");
|
||||
|
||||
|
||||
try {
|
||||
CommandUtil.registerAll(manager);
|
||||
} catch(MalformedCommandException e) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
public class InternalAddon implements BaseAddon {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "terra";
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.dfsek.terra.addon.dependency;
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
public class CircularDependencyException extends DependencyException{
|
||||
public class CircularDependencyException extends DependencyException {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -6098780459461482651L;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.dfsek.terra.addon.dependency;
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
public class DependencyVersionException extends DependencyException{
|
||||
public class DependencyVersionException extends DependencyException {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3564288935278878135L;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.dfsek.terra.commands.profiler.ProfileCommand;
|
||||
|
||||
public final class CommandUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CommandUtil.class);
|
||||
|
||||
public static void registerAll(CommandManager manager) throws MalformedCommandException {
|
||||
logger.info("Registering Terra commands...");
|
||||
manager.register("profile", ProfileCommand.class);
|
||||
|
||||
@@ -42,10 +42,10 @@ public class ProfileCommand implements CommandTemplate {
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
sender.sendMessage("""
|
||||
---------------Terra/profile---------------"
|
||||
- "start - Starts the profiler"
|
||||
- "stop - Stops the profiler"
|
||||
- "query - Fetches profiler data"
|
||||
- "reset - Resets profiler data""");
|
||||
---------------Terra/profile---------------"
|
||||
- "start - Starts the profiler"
|
||||
- "stop - Stops the profiler"
|
||||
- "query - Fetches profiler data"
|
||||
- "reset - Resets profiler data""");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,12 @@
|
||||
|
||||
package com.dfsek.terra.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.exception.ConfigException;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
|
||||
import com.dfsek.terra.api.config.PluginConfig;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -33,9 +30,9 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.time.Duration;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.PluginConfig;
|
||||
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
@@ -100,6 +97,7 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
||||
public boolean dumpDefaultConfig() {
|
||||
return dumpDefaultData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugCommands() {
|
||||
return debugCommands;
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.dfsek.terra.config.loaders;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.Map;
|
||||
@@ -27,8 +28,6 @@ import java.util.Map;
|
||||
import com.dfsek.terra.api.util.ConstantRange;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RangeLoader implements TypeLoader<Range> {
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
package com.dfsek.terra.config.pack;
|
||||
|
||||
import ca.solostudios.strata.version.VersionRange;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
@@ -161,7 +161,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
ConfigPackAddonsTemplate addonsTemplate = new ConfigPackAddonsTemplate();
|
||||
selfLoader.load(addonsTemplate, packManifest);
|
||||
this.addons = addonsTemplate.getAddons();
|
||||
|
||||
|
||||
Map<String, Configuration> configurations = discoverConfigurations();
|
||||
registerMeta(configurations);
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package com.dfsek.terra.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
package com.dfsek.terra.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -28,7 +28,6 @@ import java.util.Map;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.GenerationStageProvider;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MetaListLikePreprocessor extends MetaPreprocessor<Meta> {
|
||||
public @NotNull <T> Result<T> process(AnnotatedType t, T c, ConfigLoader loader, Meta annotation) {
|
||||
if(t.getType() instanceof ParameterizedType parameterizedType) {
|
||||
if(parameterizedType.getRawType() instanceof Class<?> baseClass) { // Should always be true but we check anyways
|
||||
|
||||
|
||||
if((List.class.isAssignableFrom(baseClass) || Set.class.isAssignableFrom(baseClass)) &&
|
||||
c instanceof List) { // List or set metaconfig
|
||||
List<Object> list = (List<Object>) c;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MetaMapPreprocessor extends MetaPreprocessor<Meta> {
|
||||
public @NotNull <T> Result<T> process(AnnotatedType t, T c, ConfigLoader loader, Meta annotation) {
|
||||
if(t.getType() instanceof ParameterizedType parameterizedType) {
|
||||
if(parameterizedType.getRawType() instanceof Class<?> baseClass) { // Should always be true but we check anyways
|
||||
|
||||
|
||||
if(Map.class.isAssignableFrom(baseClass) && c instanceof Map) { // Map metaconfig
|
||||
Map<Object, Object> map = (Map<Object, Object>) c;
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package com.dfsek.terra.config.prototype;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.dfsek.terra.registry;
|
||||
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.Collection;
|
||||
@@ -30,7 +31,6 @@ import java.util.function.Consumer;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.dfsek.terra.registry;
|
||||
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.Collection;
|
||||
@@ -29,8 +30,6 @@ import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper for a registry that forbids all write access.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.Configuration;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class RegistryTest {
|
||||
test.registerChecked("test", "bazinga2");
|
||||
fail("Shouldn't be able to re-register with #registerChecked!");
|
||||
} catch(DuplicateEntryException ignore) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class RegistryTest {
|
||||
test.register("test", "bazinga2");
|
||||
fail("Shouldn't be able to re-register in CheckedRegistry!");
|
||||
} catch(DuplicateEntryException ignore) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user