diff --git a/VillagerOptimizer-1.16.5/pom.xml b/VillagerOptimizer-1.16.5/pom.xml
index f312289..e8561a0 100644
--- a/VillagerOptimizer-1.16.5/pom.xml
+++ b/VillagerOptimizer-1.16.5/pom.xml
@@ -7,7 +7,7 @@
me.xginko.VillagerOptimizer
VillagerOptimizer
- 1.0.1
+ 1.0.2
1.16.5
diff --git a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerCache.java b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerCache.java
index d871eac..9d59b13 100644
--- a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerCache.java
+++ b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerCache.java
@@ -39,7 +39,7 @@ public final class VillagerCache {
}
public @NotNull WrappedVillager add(@NotNull Villager villager) {
- return add(new WrappedVillager(villager));
+ return this.add(new WrappedVillager(villager));
}
public boolean contains(@NotNull UUID uuid) {
diff --git a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java
index df4ddd7..e3d42c9 100644
--- a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java
+++ b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java
@@ -19,14 +19,13 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
+import java.util.*;
import java.util.jar.JarFile;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
public final class VillagerOptimizer extends JavaPlugin {
@@ -118,56 +117,51 @@ public final class VillagerOptimizer extends JavaPlugin {
languageCacheMap = new HashMap<>();
ConsoleCommandSender console = getServer().getConsoleSender();
try {
- File langDirectory = new File(getDataFolder() + "/lang");
+ File langDirectory = new File(getDataFolder() + File.separator + "lang");
Files.createDirectories(langDirectory.toPath());
for (String fileName : getDefaultLanguageFiles()) {
- String localeString = fileName.substring(fileName.lastIndexOf('/') + 1, fileName.lastIndexOf('.'));
+ final String localeString = fileName.substring(fileName.lastIndexOf(File.separator) + 1, fileName.lastIndexOf('.'));
if (startup) console.sendMessage(
Component.text("│ ").style(plugin_style)
- .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
- .append(Component.text(" │").style(plugin_style)));
- else logger.info("Found language file for " + localeString);
- LanguageCache langCache = new LanguageCache(localeString);
- languageCacheMap.put(localeString, langCache);
+ .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
+ .append(Component.text(" │").style(plugin_style)));
+ else logger.info(String.format("Found language file for %s", localeString));
+ languageCacheMap.put(localeString, new LanguageCache(localeString));
}
- Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
+ final Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
for (File langFile : langDirectory.listFiles()) {
- Matcher langMatcher = langPattern.matcher(langFile.getName());
+ final Matcher langMatcher = langPattern.matcher(langFile.getName());
if (langMatcher.find()) {
String localeString = langMatcher.group(1).toLowerCase();
if (!languageCacheMap.containsKey(localeString)) { // make sure it wasn't a default file that we already loaded
if (startup) console.sendMessage(
Component.text("│ ").style(plugin_style)
- .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
- .append(Component.text(" │").style(plugin_style)));
- else logger.info("Found language file for " + localeString);
- LanguageCache langCache = new LanguageCache(localeString);
- languageCacheMap.put(localeString, langCache);
+ .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
+ .append(Component.text(" │").style(plugin_style)));
+ else logger.info(String.format("Found language file for %s", localeString));
+ languageCacheMap.put(localeString, new LanguageCache(localeString));
}
}
}
} catch (Exception e) {
if (startup) console.sendMessage(
Component.text("│ ").style(plugin_style)
- .append(Component.text("LANG ERROR").color(NamedTextColor.RED).decorate(TextDecoration.BOLD))
- .append(Component.text(" │").style(plugin_style)));
+ .append(Component.text("LANG ERROR").color(NamedTextColor.RED).decorate(TextDecoration.BOLD))
+ .append(Component.text(" │").style(plugin_style)));
else logger.severe("Error loading language files! Language files will not reload to avoid errors, make sure to correct this before restarting the server!");
e.printStackTrace();
}
}
private Set getDefaultLanguageFiles() {
- Set languageFiles = new HashSet<>();
- try (JarFile jarFile = new JarFile(this.getFile())) {
- jarFile.entries().asIterator().forEachRemaining(jarFileEntry -> {
- final String path = jarFileEntry.getName();
- if (path.startsWith("lang/") && path.endsWith(".yml"))
- languageFiles.add(path);
- });
+ try (final JarFile pluginJarFile = new JarFile(this.getFile())) {
+ return pluginJarFile.stream()
+ .map(ZipEntry::getName)
+ .filter(name -> name.startsWith("lang" + File.separator) && name.endsWith(".yml"))
+ .collect(Collectors.toSet());
} catch (IOException e) {
- logger.severe("Error while getting default language files! - " + e.getLocalizedMessage());
- e.printStackTrace();
+ logger.severe("Failed getting default lang files! - "+e.getLocalizedMessage());
+ return Collections.emptySet();
}
- return languageFiles;
}
}
diff --git a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/Config.java b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/Config.java
index 9f169d0..9e40ef4 100644
--- a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/Config.java
+++ b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/Config.java
@@ -18,58 +18,58 @@ public class Config {
public final long cache_keep_time_seconds;
public Config() throws Exception {
- this.config = loadConfig(new File(VillagerOptimizer.getInstance().getDataFolder(), "config.yml"));
+ // Create plugin folder first if it does not exist yet
+ File pluginFolder = VillagerOptimizer.getInstance().getDataFolder();
+ if (!pluginFolder.exists() && !pluginFolder.mkdir())
+ VillagerOptimizer.getLog().severe("Failed to create plugin directory.");
+ // Load config.yml with ConfigMaster
+ this.config = ConfigFile.loadConfig(new File(pluginFolder, "config.yml"));
+
structureConfig();
+
this.default_lang = Locale.forLanguageTag(
getString("general.default-language", "en_us",
"The default language that will be used if auto-language is false or no matching language file was found.")
- .replace("_", "-"));
+ .replace("_", "-"));
this.auto_lang = getBoolean("general.auto-language", true,
"If set to true, will display messages based on client language");
this.cache_keep_time_seconds = getInt("general.cache-keep-time-seconds", 30,
"The amount of time in seconds a villager will be kept in the plugin's cache.");
}
- private ConfigFile loadConfig(File ymlFile) throws Exception {
- File parent = ymlFile.getParentFile();
- if (!parent.exists() && !parent.mkdir())
- VillagerOptimizer.getLog().severe("Unable to create plugin config directory.");
- return ConfigFile.loadConfig(ymlFile);
- }
-
public void saveConfig() {
try {
- config.save();
+ this.config.save();
} catch (Exception e) {
VillagerOptimizer.getLog().severe("Failed to save config file! - " + e.getLocalizedMessage());
}
}
private void structureConfig() {
- config.addDefault("config-version", 1.00);
- createTitledSection("General", "general");
- createTitledSection("Optimization", "optimization-methods");
- config.addDefault("optimization-methods.commands.unoptimizevillagers", null);
- config.addComment("optimization-methods.commands", """
+ this.config.addDefault("config-version", 1.00);
+ this.createTitledSection("General", "general");
+ this.createTitledSection("Optimization", "optimization-methods");
+ this.config.addDefault("optimization-methods.commands.unoptimizevillagers", null);
+ this.config.addComment("optimization-methods.commands", """
If you want to disable commands, negate the following permissions:\s
villageroptimizer.cmd.optimize\s
villageroptimizer.cmd.unoptimize
""");
- config.addDefault("optimization-methods.nametag-optimization.enable", true);
- createTitledSection("Villager Chunk Limit", "villager-chunk-limit");
- createTitledSection("Gameplay", "gameplay");
- config.addDefault("gameplay.restock-optimized-trades", null);
- config.addDefault("gameplay.level-optimized-profession", null);
- config.addDefault("gameplay.rename-optimized-villagers.enable", true);
- config.addDefault("gameplay.villagers-spawn-as-adults.enable", false);
- config.addDefault("gameplay.prevent-trading-with-unoptimized.enable", false);
- config.addDefault("gameplay.prevent-entities-from-targeting-optimized.enable", true);
- config.addDefault("gameplay.prevent-damage-to-optimized.enable", true);
+ this.config.addDefault("optimization-methods.nametag-optimization.enable", true);
+ this.createTitledSection("Villager Chunk Limit", "villager-chunk-limit");
+ this.createTitledSection("Gameplay", "gameplay");
+ this.config.addDefault("gameplay.restock-optimized-trades", null);
+ this.config.addDefault("gameplay.level-optimized-profession", null);
+ this.config.addDefault("gameplay.rename-optimized-villagers.enable", true);
+ this.config.addDefault("gameplay.villagers-spawn-as-adults.enable", false);
+ this.config.addDefault("gameplay.prevent-trading-with-unoptimized.enable", false);
+ this.config.addDefault("gameplay.prevent-entities-from-targeting-optimized.enable", true);
+ this.config.addDefault("gameplay.prevent-damage-to-optimized.enable", true);
}
public void createTitledSection(@NotNull String title, @NotNull String path) {
- config.addSection(title);
- config.addDefault(path, null);
+ this.config.addSection(title);
+ this.config.addDefault(path, null);
}
public @NotNull ConfigFile master() {
@@ -77,70 +77,70 @@ public class Config {
}
public boolean getBoolean(@NotNull String path, boolean def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getBoolean(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getBoolean(path, def);
}
public boolean getBoolean(@NotNull String path, boolean def) {
- config.addDefault(path, def);
- return config.getBoolean(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getBoolean(path, def);
}
public @NotNull String getString(@NotNull String path, @NotNull String def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getString(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getString(path, def);
}
public @NotNull String getString(@NotNull String path, @NotNull String def) {
- config.addDefault(path, def);
- return config.getString(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getString(path, def);
}
public double getDouble(@NotNull String path, @NotNull Double def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getDouble(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getDouble(path, def);
}
public double getDouble(@NotNull String path, @NotNull Double def) {
- config.addDefault(path, def);
- return config.getDouble(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getDouble(path, def);
}
public int getInt(@NotNull String path, int def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getInteger(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getInteger(path, def);
}
public int getInt(@NotNull String path, int def) {
- config.addDefault(path, def);
- return config.getInteger(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getInteger(path, def);
}
public @NotNull List getList(@NotNull String path, @NotNull List def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getStringList(path);
+ this.config.addDefault(path, def, comment);
+ return this.config.getStringList(path);
}
public @NotNull List getList(@NotNull String path, @NotNull List def) {
- config.addDefault(path, def);
- return config.getStringList(path);
+ this.config.addDefault(path, def);
+ return this.config.getStringList(path);
}
public @NotNull ConfigSection getConfigSection(@NotNull String path, @NotNull Map defaultKeyValue) {
- config.addDefault(path, null);
- config.makeSectionLenient(path);
- defaultKeyValue.forEach((string, object) -> config.addExample(path+"."+string, object));
- return config.getConfigSection(path);
+ this.config.addDefault(path, null);
+ this.config.makeSectionLenient(path);
+ defaultKeyValue.forEach((string, object) -> this.config.addExample(path+"."+string, object));
+ return this.config.getConfigSection(path);
}
public @NotNull ConfigSection getConfigSection(@NotNull String path, @NotNull Map defaultKeyValue, @NotNull String comment) {
- config.addDefault(path, null, comment);
- config.makeSectionLenient(path);
- defaultKeyValue.forEach((string, object) -> config.addExample(path+"."+string, object));
- return config.getConfigSection(path);
+ this.config.addDefault(path, null, comment);
+ this.config.makeSectionLenient(path);
+ defaultKeyValue.forEach((string, object) -> this.config.addExample(path+"."+string, object));
+ return this.config.getConfigSection(path);
}
public void addComment(@NotNull String path, @NotNull String comment) {
- config.addComment(path, comment);
+ this.config.addComment(path, comment);
}
-}
+}
\ No newline at end of file
diff --git a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java
index 65fdac5..0e82321 100644
--- a/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java
+++ b/VillagerOptimizer-1.16.5/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java
@@ -27,7 +27,7 @@ public class LanguageCache {
// Check if the lang folder has already been created
File parent = langYML.getParentFile();
if (!parent.exists() && !parent.mkdir())
- VillagerOptimizer.getLog().severe("Unable to create lang directory.");
+ VillagerOptimizer.getLog().severe("Failed to create lang directory.");
// Check if the file already exists and save the one from the plugins resources folder if it does not
if (!langYML.exists())
plugin.saveResource("lang/" + locale + ".yml", false);
diff --git a/VillagerOptimizer-1.20.2/pom.xml b/VillagerOptimizer-1.20.2/pom.xml
index bc9e8ca..d607e6c 100644
--- a/VillagerOptimizer-1.20.2/pom.xml
+++ b/VillagerOptimizer-1.20.2/pom.xml
@@ -7,7 +7,7 @@
me.xginko.VillagerOptimizer
VillagerOptimizer
- 1.0.1
+ 1.0.2
1.20.2
diff --git a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerCache.java b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerCache.java
index d871eac..9d59b13 100644
--- a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerCache.java
+++ b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerCache.java
@@ -39,7 +39,7 @@ public final class VillagerCache {
}
public @NotNull WrappedVillager add(@NotNull Villager villager) {
- return add(new WrappedVillager(villager));
+ return this.add(new WrappedVillager(villager));
}
public boolean contains(@NotNull UUID uuid) {
diff --git a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java
index df4ddd7..e3d42c9 100644
--- a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java
+++ b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/VillagerOptimizer.java
@@ -19,14 +19,13 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
+import java.util.*;
import java.util.jar.JarFile;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
public final class VillagerOptimizer extends JavaPlugin {
@@ -118,56 +117,51 @@ public final class VillagerOptimizer extends JavaPlugin {
languageCacheMap = new HashMap<>();
ConsoleCommandSender console = getServer().getConsoleSender();
try {
- File langDirectory = new File(getDataFolder() + "/lang");
+ File langDirectory = new File(getDataFolder() + File.separator + "lang");
Files.createDirectories(langDirectory.toPath());
for (String fileName : getDefaultLanguageFiles()) {
- String localeString = fileName.substring(fileName.lastIndexOf('/') + 1, fileName.lastIndexOf('.'));
+ final String localeString = fileName.substring(fileName.lastIndexOf(File.separator) + 1, fileName.lastIndexOf('.'));
if (startup) console.sendMessage(
Component.text("│ ").style(plugin_style)
- .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
- .append(Component.text(" │").style(plugin_style)));
- else logger.info("Found language file for " + localeString);
- LanguageCache langCache = new LanguageCache(localeString);
- languageCacheMap.put(localeString, langCache);
+ .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
+ .append(Component.text(" │").style(plugin_style)));
+ else logger.info(String.format("Found language file for %s", localeString));
+ languageCacheMap.put(localeString, new LanguageCache(localeString));
}
- Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
+ final Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
for (File langFile : langDirectory.listFiles()) {
- Matcher langMatcher = langPattern.matcher(langFile.getName());
+ final Matcher langMatcher = langPattern.matcher(langFile.getName());
if (langMatcher.find()) {
String localeString = langMatcher.group(1).toLowerCase();
if (!languageCacheMap.containsKey(localeString)) { // make sure it wasn't a default file that we already loaded
if (startup) console.sendMessage(
Component.text("│ ").style(plugin_style)
- .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
- .append(Component.text(" │").style(plugin_style)));
- else logger.info("Found language file for " + localeString);
- LanguageCache langCache = new LanguageCache(localeString);
- languageCacheMap.put(localeString, langCache);
+ .append(Component.text(" "+localeString).color(NamedTextColor.WHITE).decorate(TextDecoration.BOLD))
+ .append(Component.text(" │").style(plugin_style)));
+ else logger.info(String.format("Found language file for %s", localeString));
+ languageCacheMap.put(localeString, new LanguageCache(localeString));
}
}
}
} catch (Exception e) {
if (startup) console.sendMessage(
Component.text("│ ").style(plugin_style)
- .append(Component.text("LANG ERROR").color(NamedTextColor.RED).decorate(TextDecoration.BOLD))
- .append(Component.text(" │").style(plugin_style)));
+ .append(Component.text("LANG ERROR").color(NamedTextColor.RED).decorate(TextDecoration.BOLD))
+ .append(Component.text(" │").style(plugin_style)));
else logger.severe("Error loading language files! Language files will not reload to avoid errors, make sure to correct this before restarting the server!");
e.printStackTrace();
}
}
private Set getDefaultLanguageFiles() {
- Set languageFiles = new HashSet<>();
- try (JarFile jarFile = new JarFile(this.getFile())) {
- jarFile.entries().asIterator().forEachRemaining(jarFileEntry -> {
- final String path = jarFileEntry.getName();
- if (path.startsWith("lang/") && path.endsWith(".yml"))
- languageFiles.add(path);
- });
+ try (final JarFile pluginJarFile = new JarFile(this.getFile())) {
+ return pluginJarFile.stream()
+ .map(ZipEntry::getName)
+ .filter(name -> name.startsWith("lang" + File.separator) && name.endsWith(".yml"))
+ .collect(Collectors.toSet());
} catch (IOException e) {
- logger.severe("Error while getting default language files! - " + e.getLocalizedMessage());
- e.printStackTrace();
+ logger.severe("Failed getting default lang files! - "+e.getLocalizedMessage());
+ return Collections.emptySet();
}
- return languageFiles;
}
}
diff --git a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/Config.java b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/Config.java
index 9f169d0..1c9584c 100644
--- a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/Config.java
+++ b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/Config.java
@@ -18,58 +18,58 @@ public class Config {
public final long cache_keep_time_seconds;
public Config() throws Exception {
- this.config = loadConfig(new File(VillagerOptimizer.getInstance().getDataFolder(), "config.yml"));
+ // Create plugin folder first if it does not exist yet
+ File pluginFolder = VillagerOptimizer.getInstance().getDataFolder();
+ if (!pluginFolder.exists() && !pluginFolder.mkdir())
+ VillagerOptimizer.getLog().severe("Failed to create plugin directory.");
+ // Load config.yml with ConfigMaster
+ this.config = ConfigFile.loadConfig(new File(pluginFolder, "config.yml"));
+
structureConfig();
+
this.default_lang = Locale.forLanguageTag(
getString("general.default-language", "en_us",
"The default language that will be used if auto-language is false or no matching language file was found.")
- .replace("_", "-"));
+ .replace("_", "-"));
this.auto_lang = getBoolean("general.auto-language", true,
"If set to true, will display messages based on client language");
this.cache_keep_time_seconds = getInt("general.cache-keep-time-seconds", 30,
"The amount of time in seconds a villager will be kept in the plugin's cache.");
}
- private ConfigFile loadConfig(File ymlFile) throws Exception {
- File parent = ymlFile.getParentFile();
- if (!parent.exists() && !parent.mkdir())
- VillagerOptimizer.getLog().severe("Unable to create plugin config directory.");
- return ConfigFile.loadConfig(ymlFile);
- }
-
public void saveConfig() {
try {
- config.save();
+ this.config.save();
} catch (Exception e) {
VillagerOptimizer.getLog().severe("Failed to save config file! - " + e.getLocalizedMessage());
}
}
private void structureConfig() {
- config.addDefault("config-version", 1.00);
- createTitledSection("General", "general");
- createTitledSection("Optimization", "optimization-methods");
- config.addDefault("optimization-methods.commands.unoptimizevillagers", null);
- config.addComment("optimization-methods.commands", """
+ this.config.addDefault("config-version", 1.00);
+ this.createTitledSection("General", "general");
+ this.createTitledSection("Optimization", "optimization-methods");
+ this.config.addDefault("optimization-methods.commands.unoptimizevillagers", null);
+ this.config.addComment("optimization-methods.commands", """
If you want to disable commands, negate the following permissions:\s
villageroptimizer.cmd.optimize\s
villageroptimizer.cmd.unoptimize
""");
- config.addDefault("optimization-methods.nametag-optimization.enable", true);
- createTitledSection("Villager Chunk Limit", "villager-chunk-limit");
- createTitledSection("Gameplay", "gameplay");
- config.addDefault("gameplay.restock-optimized-trades", null);
- config.addDefault("gameplay.level-optimized-profession", null);
- config.addDefault("gameplay.rename-optimized-villagers.enable", true);
- config.addDefault("gameplay.villagers-spawn-as-adults.enable", false);
- config.addDefault("gameplay.prevent-trading-with-unoptimized.enable", false);
- config.addDefault("gameplay.prevent-entities-from-targeting-optimized.enable", true);
- config.addDefault("gameplay.prevent-damage-to-optimized.enable", true);
+ this.config.addDefault("optimization-methods.nametag-optimization.enable", true);
+ this.createTitledSection("Villager Chunk Limit", "villager-chunk-limit");
+ this.createTitledSection("Gameplay", "gameplay");
+ this.config.addDefault("gameplay.restock-optimized-trades", null);
+ this.config.addDefault("gameplay.level-optimized-profession", null);
+ this.config.addDefault("gameplay.rename-optimized-villagers.enable", true);
+ this.config.addDefault("gameplay.villagers-spawn-as-adults.enable", false);
+ this.config.addDefault("gameplay.prevent-trading-with-unoptimized.enable", false);
+ this.config.addDefault("gameplay.prevent-entities-from-targeting-optimized.enable", true);
+ this.config.addDefault("gameplay.prevent-damage-to-optimized.enable", true);
}
public void createTitledSection(@NotNull String title, @NotNull String path) {
- config.addSection(title);
- config.addDefault(path, null);
+ this.config.addSection(title);
+ this.config.addDefault(path, null);
}
public @NotNull ConfigFile master() {
@@ -77,70 +77,70 @@ public class Config {
}
public boolean getBoolean(@NotNull String path, boolean def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getBoolean(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getBoolean(path, def);
}
public boolean getBoolean(@NotNull String path, boolean def) {
- config.addDefault(path, def);
- return config.getBoolean(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getBoolean(path, def);
}
public @NotNull String getString(@NotNull String path, @NotNull String def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getString(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getString(path, def);
}
public @NotNull String getString(@NotNull String path, @NotNull String def) {
- config.addDefault(path, def);
- return config.getString(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getString(path, def);
}
public double getDouble(@NotNull String path, @NotNull Double def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getDouble(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getDouble(path, def);
}
public double getDouble(@NotNull String path, @NotNull Double def) {
- config.addDefault(path, def);
- return config.getDouble(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getDouble(path, def);
}
public int getInt(@NotNull String path, int def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getInteger(path, def);
+ this.config.addDefault(path, def, comment);
+ return this.config.getInteger(path, def);
}
public int getInt(@NotNull String path, int def) {
- config.addDefault(path, def);
- return config.getInteger(path, def);
+ this.config.addDefault(path, def);
+ return this.config.getInteger(path, def);
}
public @NotNull List getList(@NotNull String path, @NotNull List def, @NotNull String comment) {
- config.addDefault(path, def, comment);
- return config.getStringList(path);
+ this.config.addDefault(path, def, comment);
+ return this.config.getStringList(path);
}
public @NotNull List getList(@NotNull String path, @NotNull List def) {
- config.addDefault(path, def);
- return config.getStringList(path);
+ this.config.addDefault(path, def);
+ return this.config.getStringList(path);
}
public @NotNull ConfigSection getConfigSection(@NotNull String path, @NotNull Map defaultKeyValue) {
- config.addDefault(path, null);
- config.makeSectionLenient(path);
- defaultKeyValue.forEach((string, object) -> config.addExample(path+"."+string, object));
- return config.getConfigSection(path);
+ this.config.addDefault(path, null);
+ this.config.makeSectionLenient(path);
+ defaultKeyValue.forEach((string, object) -> this.config.addExample(path+"."+string, object));
+ return this.config.getConfigSection(path);
}
public @NotNull ConfigSection getConfigSection(@NotNull String path, @NotNull Map defaultKeyValue, @NotNull String comment) {
- config.addDefault(path, null, comment);
- config.makeSectionLenient(path);
- defaultKeyValue.forEach((string, object) -> config.addExample(path+"."+string, object));
- return config.getConfigSection(path);
+ this.config.addDefault(path, null, comment);
+ this.config.makeSectionLenient(path);
+ defaultKeyValue.forEach((string, object) -> this.config.addExample(path+"."+string, object));
+ return this.config.getConfigSection(path);
}
public void addComment(@NotNull String path, @NotNull String comment) {
- config.addComment(path, comment);
+ this.config.addComment(path, comment);
}
}
diff --git a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java
index 0af1bec..cf2c9a3 100644
--- a/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java
+++ b/VillagerOptimizer-1.20.2/src/main/java/me/xginko/villageroptimizer/config/LanguageCache.java
@@ -27,7 +27,7 @@ public class LanguageCache {
// Check if the lang folder has already been created
File parent = langYML.getParentFile();
if (!parent.exists() && !parent.mkdir())
- VillagerOptimizer.getLog().severe("Unable to create lang directory.");
+ VillagerOptimizer.getLog().severe("Failed to create lang directory.");
// Check if the file already exists and save the one from the plugins resources folder if it does not
if (!langYML.exists())
plugin.saveResource("lang/" + locale + ".yml", false);
diff --git a/pom.xml b/pom.xml
index 7a846e3..1bc9b5c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.xginko.VillagerOptimizer
VillagerOptimizer
- 1.0.1
+ 1.0.2
VillagerOptimizer-1.20.2
VillagerOptimizer-1.16.5