mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-16 13:51:41 +00:00
preparations for Sponge API8
This commit is contained in:
@@ -7,6 +7,7 @@ import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.util.JarUtil;
|
||||
import com.dfsek.terra.api.util.logging.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -14,7 +15,6 @@ import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.time.Duration;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class PluginConfig implements ConfigTemplate {
|
||||
@@ -63,7 +63,7 @@ public class PluginConfig implements ConfigTemplate {
|
||||
private int maxRecursion = 1000;
|
||||
|
||||
public void load(TerraPlugin main) {
|
||||
Logger logger = main.getLogger();
|
||||
Logger logger = main.logger();
|
||||
logger.info("Loading config values");
|
||||
try(FileInputStream file = new FileInputStream(new File(main.getDataFolder(), "config.yml"))) {
|
||||
ConfigLoader loader = new ConfigLoader();
|
||||
|
||||
@@ -2,22 +2,20 @@ package com.dfsek.terra.config.lang;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.CommandSender;
|
||||
import com.dfsek.terra.api.util.logging.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.dfsek.terra.api.util.JarUtil.copyResourcesToDirectory;
|
||||
|
||||
public final class LangUtil {
|
||||
private static Language language;
|
||||
private static Logger logger;
|
||||
|
||||
public static void load(String langID, TerraPlugin main) {
|
||||
logger = main.getLogger();
|
||||
Logger logger = main.logger();
|
||||
File file = new File(main.getDataFolder(), "lang");
|
||||
try(JarFile jar = new JarFile(new File(TerraPlugin.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||
copyResourcesToDirectory(jar, "lang", file.toString());
|
||||
@@ -41,10 +39,6 @@ public final class LangUtil {
|
||||
return language;
|
||||
}
|
||||
|
||||
public static void log(String messageID, Level level, String... args) {
|
||||
language.getMessage(messageID).log(logger, level, args);
|
||||
}
|
||||
|
||||
public static void send(String messageID, CommandSender sender, String... args) {
|
||||
language.getMessage(messageID).send(sender, args);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.dfsek.terra.config.factories.TreeFactory;
|
||||
import com.dfsek.terra.config.fileloaders.FolderLoader;
|
||||
import com.dfsek.terra.config.fileloaders.Loader;
|
||||
import com.dfsek.terra.config.fileloaders.ZIPLoader;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.config.loaders.config.BufferedImageLoader;
|
||||
import com.dfsek.terra.config.loaders.config.biome.templates.source.BiomePipelineTemplate;
|
||||
import com.dfsek.terra.config.loaders.config.biome.templates.source.ImageProviderTemplate;
|
||||
@@ -79,7 +78,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
@@ -136,7 +134,7 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
try {
|
||||
selfLoader.load(template, new FileInputStream(pack));
|
||||
|
||||
main.getLogger().info("Loading config pack \"" + template.getID() + "\"");
|
||||
main.logger().info("Loading config pack \"" + template.getID() + "\"");
|
||||
|
||||
load(l, main);
|
||||
ConfigPackPostTemplate packPostTemplate = new ConfigPackPostTemplate();
|
||||
@@ -147,7 +145,7 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
throw new LoadException("No pack.yml file found in " + folder.getAbsolutePath(), e);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
main.getLogger().severe("Failed to load config pack from folder \"" + folder.getAbsolutePath() + "\"");
|
||||
main.logger().severe("Failed to load config pack from folder \"" + folder.getAbsolutePath() + "\"");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -178,7 +176,7 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
if(pack == null) throw new LoadException("No pack.yml file found in " + file.getName());
|
||||
|
||||
selfLoader.load(template, file.getInputStream(pack));
|
||||
main.getLogger().info("Loading config pack \"" + template.getID() + "\"");
|
||||
main.logger().info("Loading config pack \"" + template.getID() + "\"");
|
||||
|
||||
load(l, main);
|
||||
|
||||
@@ -191,7 +189,7 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
throw new LoadException("Unable to load pack.yml from ZIP file", e);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
main.getLogger().severe("Failed to load config pack from ZIP archive \"" + file.getName() + "\"");
|
||||
main.logger().severe("Failed to load config pack from ZIP archive \"" + file.getName() + "\"");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -236,7 +234,7 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
.open("biomes", ".yml").then(streams -> buildAll(new BiomeFactory(this), biomeRegistry, abstractConfigLoader.load(streams, () -> new BiomeTemplate(this, main)), main)).close();
|
||||
|
||||
main.getEventManager().callEvent(new ConfigPackPostLoadEvent(this));
|
||||
LangUtil.log("config-pack.loaded", Level.INFO, template.getID(), String.valueOf((System.nanoTime() - start) / 1000000D), template.getAuthor(), template.getVersion());
|
||||
main.logger().info("Loaded config pack \"" + template.getID() + "\" v" + template.getVersion() + " by " + template.getAuthor() + " in " + (System.nanoTime() - start) / 1000000D + "ms.");
|
||||
}
|
||||
|
||||
public TerraBiome getBiome(String id) {
|
||||
|
||||
Reference in New Issue
Block a user