From 9af34b9940a62c2078b60181c65114398c55f2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sat, 6 Jul 2019 00:25:35 +0800 Subject: [PATCH] Taboolib 5.0 fully refactored & Not a plugin now. --- .../scala/io/izzel/taboolib/PluginLoader.java | 2 +- .../scala/io/izzel/taboolib/TabooLib.java | 2 +- .../command/TabooLibExecuteCommand.java | 2 +- .../command/TabooLibLocaleCommand.java | 4 +- .../command/TabooLibPluginCommand.java | 2 +- .../module/command/TCommandHandler.java | 2 +- .../module/command/base/BaseMainCommand.java | 2 +- .../module/command/base/BaseSubCommand.java | 2 +- .../module/command/base/CommandArgument.java | 2 +- .../izzel/taboolib/module/config/TConfig.java | 2 +- .../dependency/TDependencyInjector.java | 2 +- .../module/dependency/TDependencyLoader.java | 32 ++++ .../taboolib/module/item/ItemBuilder.java | 2 +- .../io/izzel/taboolib/module/item/Items.java | 2 +- .../taboolib/module/lite/SimpleI18n.java | 2 +- .../taboolib/{ => module}/locale/TLocale.java | 2 +- .../{ => module}/locale/TLocaleInstance.java | 4 +- .../taboolib/module/locale/TLocaleLoader.java | 152 ++++++++++++++++++ .../{ => module}/locale/TLocaleSender.java | 2 +- .../{ => module}/locale/TLocaleSerialize.java | 2 +- .../locale/type/TLocaleActionBar.java | 6 +- .../{ => module}/locale/type/TLocaleBook.java | 6 +- .../locale/type/TLocaleBossBar.java | 6 +- .../{ => module}/locale/type/TLocaleJson.java | 6 +- .../locale/type/TLocaleSound.java | 4 +- .../{ => module}/locale/type/TLocaleText.java | 6 +- .../locale/type/TLocaleTitle.java | 6 +- .../izzel/taboolib/module/logger/TLogger.java | 2 +- .../module/mysql/hikari/HikariHandler.java | 2 +- .../taboolib/module/tellraw/TellrawJson.java | 2 +- .../origin/client/TabooLibClient.java | 2 +- .../origin/client/packet/impl/PacketJoin.java | 2 +- .../client/packet/impl/PacketMessage.java | 2 +- .../origin/client/packet/impl/PacketQuit.java | 2 +- .../origin/cronus/util/StringExpression.java | 2 +- .../origin/database/PluginDataManager.java | 2 +- .../io/izzel/taboolib/origin/lite/Logs.java | 2 +- .../scala/io/izzel/taboolib/util/Files.java | 2 +- .../scala/io/lzzel/tlibscala/Prelude.scala | 2 +- .../lzzel/tlibscala/runtime/RichPlayer.scala | 2 +- 40 files changed, 237 insertions(+), 53 deletions(-) create mode 100644 src/main/scala/io/izzel/taboolib/module/dependency/TDependencyLoader.java rename src/main/scala/io/izzel/taboolib/{ => module}/locale/TLocale.java (99%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/TLocaleInstance.java (97%) create mode 100644 src/main/scala/io/izzel/taboolib/module/locale/TLocaleLoader.java rename src/main/scala/io/izzel/taboolib/{ => module}/locale/TLocaleSender.java (87%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/TLocaleSerialize.java (98%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/type/TLocaleActionBar.java (91%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/type/TLocaleBook.java (95%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/type/TLocaleBossBar.java (95%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/type/TLocaleJson.java (98%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/type/TLocaleSound.java (95%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/type/TLocaleText.java (96%) rename src/main/scala/io/izzel/taboolib/{ => module}/locale/type/TLocaleTitle.java (94%) diff --git a/src/main/scala/io/izzel/taboolib/PluginLoader.java b/src/main/scala/io/izzel/taboolib/PluginLoader.java index 2d997c2..b5cf65c 100644 --- a/src/main/scala/io/izzel/taboolib/PluginLoader.java +++ b/src/main/scala/io/izzel/taboolib/PluginLoader.java @@ -2,7 +2,7 @@ package io.izzel.taboolib; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import io.izzel.taboolib.locale.TLocaleLoader; +import io.izzel.taboolib.module.locale.TLocaleLoader; import io.izzel.taboolib.module.command.TCommandHandler; import io.izzel.taboolib.module.config.TConfig; import io.izzel.taboolib.module.config.TConfigWatcher; diff --git a/src/main/scala/io/izzel/taboolib/TabooLib.java b/src/main/scala/io/izzel/taboolib/TabooLib.java index e02c10b..c67ae4b 100644 --- a/src/main/scala/io/izzel/taboolib/TabooLib.java +++ b/src/main/scala/io/izzel/taboolib/TabooLib.java @@ -1,6 +1,6 @@ package io.izzel.taboolib; -import io.izzel.taboolib.locale.TLocaleLoader; +import io.izzel.taboolib.module.locale.TLocaleLoader; import io.izzel.taboolib.module.config.TConfig; import io.izzel.taboolib.module.config.TConfigWatcher; import io.izzel.taboolib.module.dependency.Dependency; diff --git a/src/main/scala/io/izzel/taboolib/command/TabooLibExecuteCommand.java b/src/main/scala/io/izzel/taboolib/command/TabooLibExecuteCommand.java index 000728b..08738dc 100644 --- a/src/main/scala/io/izzel/taboolib/command/TabooLibExecuteCommand.java +++ b/src/main/scala/io/izzel/taboolib/command/TabooLibExecuteCommand.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.command; import io.izzel.taboolib.TabooLibAPI; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; import io.izzel.taboolib.module.command.TCommand; diff --git a/src/main/scala/io/izzel/taboolib/command/TabooLibLocaleCommand.java b/src/main/scala/io/izzel/taboolib/command/TabooLibLocaleCommand.java index 487daad..ca4dfa2 100644 --- a/src/main/scala/io/izzel/taboolib/command/TabooLibLocaleCommand.java +++ b/src/main/scala/io/izzel/taboolib/command/TabooLibLocaleCommand.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.command; -import io.izzel.taboolib.locale.TLocale; -import io.izzel.taboolib.locale.TLocaleLoader; +import io.izzel.taboolib.module.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocaleLoader; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; import io.izzel.taboolib.module.command.TCommand; diff --git a/src/main/scala/io/izzel/taboolib/command/TabooLibPluginCommand.java b/src/main/scala/io/izzel/taboolib/command/TabooLibPluginCommand.java index 8b3cf9f..5ee11aa 100644 --- a/src/main/scala/io/izzel/taboolib/command/TabooLibPluginCommand.java +++ b/src/main/scala/io/izzel/taboolib/command/TabooLibPluginCommand.java @@ -2,7 +2,7 @@ package io.izzel.taboolib.command; import com.google.common.base.Joiner; import io.izzel.taboolib.TabooLibAPI; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.TCommand; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; diff --git a/src/main/scala/io/izzel/taboolib/module/command/TCommandHandler.java b/src/main/scala/io/izzel/taboolib/module/command/TCommandHandler.java index 3a56449..783f540 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/TCommandHandler.java +++ b/src/main/scala/io/izzel/taboolib/module/command/TCommandHandler.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.module.command; import io.izzel.taboolib.TabooLibAPI; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.inject.TFunction; import io.izzel.taboolib.module.lite.SimpleReflection; diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java b/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java index 48012ef..8e8f3fd 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java @@ -5,7 +5,7 @@ import com.google.common.collect.Lists; import io.izzel.taboolib.TabooLib; import io.izzel.taboolib.TabooLibAPI; import io.izzel.taboolib.Version; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.util.ArrayUtil; import io.izzel.taboolib.util.Strings; import org.bukkit.Bukkit; diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java b/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java index 0ef8c9f..f3b4303 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java @@ -1,6 +1,6 @@ package io.izzel.taboolib.module.command.base; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/CommandArgument.java b/src/main/scala/io/izzel/taboolib/module/command/base/CommandArgument.java index 432c07b..75e0900 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/CommandArgument.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/CommandArgument.java @@ -1,6 +1,6 @@ package io.izzel.taboolib.module.command.base; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import java.util.Objects; diff --git a/src/main/scala/io/izzel/taboolib/module/config/TConfig.java b/src/main/scala/io/izzel/taboolib/module/config/TConfig.java index 6ad1bbc..136134f 100644 --- a/src/main/scala/io/izzel/taboolib/module/config/TConfig.java +++ b/src/main/scala/io/izzel/taboolib/module/config/TConfig.java @@ -3,7 +3,7 @@ package io.izzel.taboolib.module.config; import com.google.common.collect.Maps; import io.izzel.taboolib.TabooLib; import io.izzel.taboolib.TabooLibAPI; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.logger.TLogger; import io.izzel.taboolib.util.Files; import io.izzel.taboolib.util.Ref; diff --git a/src/main/scala/io/izzel/taboolib/module/dependency/TDependencyInjector.java b/src/main/scala/io/izzel/taboolib/module/dependency/TDependencyInjector.java index 4f386cf..c35294c 100644 --- a/src/main/scala/io/izzel/taboolib/module/dependency/TDependencyInjector.java +++ b/src/main/scala/io/izzel/taboolib/module/dependency/TDependencyInjector.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.module.dependency; import io.izzel.taboolib.TabooLibAPI; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import org.bukkit.plugin.Plugin; /** diff --git a/src/main/scala/io/izzel/taboolib/module/dependency/TDependencyLoader.java b/src/main/scala/io/izzel/taboolib/module/dependency/TDependencyLoader.java new file mode 100644 index 0000000..e9efb01 --- /dev/null +++ b/src/main/scala/io/izzel/taboolib/module/dependency/TDependencyLoader.java @@ -0,0 +1,32 @@ +package io.izzel.taboolib.module.dependency; + +import org.bukkit.plugin.Plugin; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; + +public class TDependencyLoader { + + public static synchronized void addToPath(Plugin plugin, URL url) { + try { + Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); + method.setAccessible(true); + method.invoke(plugin.getClass().getClassLoader(), url); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + public static synchronized void addToPath(Plugin plugin, File file) { + try { + addToPath(plugin, file.toURI().toURL()); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/scala/io/izzel/taboolib/module/item/ItemBuilder.java b/src/main/scala/io/izzel/taboolib/module/item/ItemBuilder.java index 8ea6d4a..036f29d 100644 --- a/src/main/scala/io/izzel/taboolib/module/item/ItemBuilder.java +++ b/src/main/scala/io/izzel/taboolib/module/item/ItemBuilder.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.module.item; import io.izzel.taboolib.Version; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.util.ArrayUtil; import org.bukkit.Color; import org.bukkit.Material; diff --git a/src/main/scala/io/izzel/taboolib/module/item/Items.java b/src/main/scala/io/izzel/taboolib/module/item/Items.java index c423167..f1483b7 100644 --- a/src/main/scala/io/izzel/taboolib/module/item/Items.java +++ b/src/main/scala/io/izzel/taboolib/module/item/Items.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.module.item; import io.izzel.taboolib.Version; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.lite.SimpleI18n; import io.izzel.taboolib.module.nms.NMSHandler; import io.izzel.taboolib.module.nms.nbt.NBTBase; diff --git a/src/main/scala/io/izzel/taboolib/module/lite/SimpleI18n.java b/src/main/scala/io/izzel/taboolib/module/lite/SimpleI18n.java index d17ed27..1066f8e 100644 --- a/src/main/scala/io/izzel/taboolib/module/lite/SimpleI18n.java +++ b/src/main/scala/io/izzel/taboolib/module/lite/SimpleI18n.java @@ -2,7 +2,7 @@ package io.izzel.taboolib.module.lite; import io.izzel.taboolib.TabooLib; import io.izzel.taboolib.Version; -import io.izzel.taboolib.locale.TLocaleLoader; +import io.izzel.taboolib.module.locale.TLocaleLoader; import io.izzel.taboolib.module.inject.TFunction; import io.izzel.taboolib.module.nms.NMSHandler; import io.izzel.taboolib.module.nms.nbt.NBTCompound; diff --git a/src/main/scala/io/izzel/taboolib/locale/TLocale.java b/src/main/scala/io/izzel/taboolib/module/locale/TLocale.java similarity index 99% rename from src/main/scala/io/izzel/taboolib/locale/TLocale.java rename to src/main/scala/io/izzel/taboolib/module/locale/TLocale.java index 4a6f908..89770a5 100644 --- a/src/main/scala/io/izzel/taboolib/locale/TLocale.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/TLocale.java @@ -1,4 +1,4 @@ -package io.izzel.taboolib.locale; +package io.izzel.taboolib.module.locale; import io.izzel.taboolib.TabooLib; import io.izzel.taboolib.module.logger.TLoggerManager; diff --git a/src/main/scala/io/izzel/taboolib/locale/TLocaleInstance.java b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleInstance.java similarity index 97% rename from src/main/scala/io/izzel/taboolib/locale/TLocaleInstance.java rename to src/main/scala/io/izzel/taboolib/module/locale/TLocaleInstance.java index f42b653..8effd83 100644 --- a/src/main/scala/io/izzel/taboolib/locale/TLocaleInstance.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleInstance.java @@ -1,8 +1,8 @@ -package io.izzel.taboolib.locale; +package io.izzel.taboolib.module.locale; import com.google.common.collect.ImmutableList; import io.izzel.taboolib.TabooLib; -import io.izzel.taboolib.locale.type.TLocaleText; +import io.izzel.taboolib.module.locale.type.TLocaleText; import io.izzel.taboolib.util.Strings; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; diff --git a/src/main/scala/io/izzel/taboolib/module/locale/TLocaleLoader.java b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleLoader.java new file mode 100644 index 0000000..c597f0e --- /dev/null +++ b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleLoader.java @@ -0,0 +1,152 @@ +package io.izzel.taboolib.module.locale; + +import io.izzel.taboolib.TabooLib; +import io.izzel.taboolib.TabooLibAPI; +import io.izzel.taboolib.module.locale.type.*; +import io.izzel.taboolib.module.config.TConfigWatcher; +import io.izzel.taboolib.module.logger.TLogger; +import io.izzel.taboolib.util.Files; +import io.izzel.taboolib.util.IO; +import io.izzel.taboolib.util.Strings; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.configuration.serialization.ConfigurationSerialization; +import org.bukkit.plugin.Plugin; + +import java.io.File; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +public class TLocaleLoader { + + private static final Map map = new ConcurrentHashMap<>(); + + static { + ConfigurationSerialization.registerClass(TLocaleText.class, "TEXT"); + ConfigurationSerialization.registerClass(TLocaleJson.class, "JSON"); + ConfigurationSerialization.registerClass(TLocaleBook.class, "BOOK"); + ConfigurationSerialization.registerClass(TLocaleSound.class, "SOUND"); + ConfigurationSerialization.registerClass(TLocaleTitle.class, "TITLE"); + ConfigurationSerialization.registerClass(TLocaleBossBar.class, "BAR"); + ConfigurationSerialization.registerClass(TLocaleActionBar.class, "ACTION"); + } + + public static void sendTo(Plugin plugin, String path, CommandSender sender, String... args) { + TabooLibAPI.debug(plugin, "TLocaleLoader.sendTo: " + plugin + ", path: " + path + ", sender: " + sender + ", args: " + Arrays.asList(args)); + if (Bukkit.isPrimaryThread()) { + Optional.ofNullable(map.get(plugin.getName())).ifPresent(localeInstance -> localeInstance.sendTo(path, sender, args)); + } else { + synchronized (TLocaleLoader.class) { + Optional.ofNullable(map.get(plugin.getName())).ifPresent(localeInstance -> localeInstance.sendTo(path, sender, args)); + } + } + } + + public static String asString(Plugin plugin, String path, String... args) { + TabooLibAPI.debug(plugin, "TLocaleLoader.asString: " + plugin.getName() + ", path: " + path + ", args: " + Arrays.asList(args)); + TLocaleInstance tLocaleInstance = map.get(plugin.getName()); + if (tLocaleInstance != null) { + return tLocaleInstance.asString(path, args); + } else { + return ""; + } + } + + public static List asStringList(Plugin plugin, String path, String... args) { + TabooLibAPI.debug(plugin, "TLocaleLoader.asStringList: " + plugin + ", path: " + path + ", args: " + Arrays.asList(args)); + TLocaleInstance tLocaleInstance = map.get(plugin.getName()); + if (tLocaleInstance != null) { + return tLocaleInstance.asStringList(path, args); + } else { + return Collections.emptyList(); + } + } + + public static void load(Plugin plugin, boolean isCover) { + try { + if (isLoadLocale(plugin, isCover)) { + // 获取文件 + File localeFile = getLocaleFile(plugin); + if (localeFile == null) { + return; + } + // 加载文件 + YamlConfiguration localeConfiguration = Files.loadYaml(plugin, localeFile); + YamlConfiguration localeConfigurationAtStream = getLocaleAtStream(plugin, localeFile); + // 载入配置 + loadPluginLocale(plugin, localeFile, localeConfiguration, localeConfigurationAtStream); + // 注册监听 + TConfigWatcher.getInst().removeListener(localeFile); + TConfigWatcher.getInst().addListener(localeFile, null, obj -> loadPluginLocale(plugin, localeFile, Files.loadYaml(plugin, localeFile), getLocaleAtStream(plugin, localeFile))); + } + } catch (Exception e) { + errorLogger("ERROR-LOADING-LANG", plugin.getName(), e.toString() + "\n" + e.getStackTrace()[0].toString()); + } + } + + public static boolean isLocaleLoaded(Plugin plugin) { + return map.containsKey(plugin.getName()); + } + + public static boolean isDependWithTabooLib(Plugin plugin) { + return plugin.getClass().getSuperclass().getSimpleName().equals("TabooPlugin"); + } + + public static List getLocalePriority() { + return TabooLib.getConfig().contains("LOCALE.PRIORITY") ? TabooLib.getConfig().getStringList("LOCALE.PRIORITY") : Collections.singletonList("zh_CN"); + } + + private static boolean isLoadLocale(Plugin plugin, boolean isCover) { + return isCover || !isLocaleLoaded(plugin); + } + + private static void infoLogger(String path, String... args) { + TLogger.getGlobalLogger().info(Strings.replaceWithOrder(io.izzel.taboolib.TabooLib.getInst().getInternal().getString(path), args)); + } + + private static void errorLogger(String path, String... args) { + TLogger.getGlobalLogger().error(Strings.replaceWithOrder(io.izzel.taboolib.TabooLib.getInst().getInternal().getString(path), args)); + } + + private static File getLocaleFile(Plugin plugin) { + releaseLocales(plugin); + return getLocalePriority().stream().map(localeName -> new File("plugins/" + plugin.getName() + "/lang/" + localeName + ".yml")).filter(File::exists).findFirst().orElse(null); + } + + private static void releaseLocales(Plugin plugin) { + getLocalePriority().stream().filter(localeName -> !new File("plugins/" + plugin.getName() + "/lang/" + localeName + ".yml").exists() && plugin.getResource("lang/" + localeName + ".yml") != null).forEach(localeName -> plugin.saveResource("lang/" + localeName + ".yml", true)); + } + + private static TLocaleInstance getLocaleInstance(Plugin plugin) { + TLocaleInstance instance = new TLocaleInstance(plugin); + map.put(plugin.getName(), instance); + return instance; + } + + private static YamlConfiguration getLocaleAtStream(Plugin plugin, File localeFile) { + InputStream localeInputSteam = Files.getResource(plugin, "lang/" + localeFile.getName()); + try { + YamlConfiguration yaml = new YamlConfiguration(); + yaml.loadFromString(IO.readFully(localeInputSteam, Charset.forName("utf-8"))); + return yaml; + } catch (Exception ignored) { + return null; + } + } + + private static void loadPluginLocale(Plugin plugin, File localeFile, YamlConfiguration localeConfiguration, YamlConfiguration localeConfigurationAtStream) { + TLocaleInstance localeInstance = getLocaleInstance(plugin); + if (localeConfigurationAtStream != null) { + localeInstance.load(localeConfigurationAtStream); + } + localeInstance.load(localeConfiguration); + if (localeInstance.getLatestUpdateNodes().get() <= 0) { + infoLogger("SUCCESS-LOADING-LANG-NORMAL", plugin.getName(), localeFile.getName().split("\\.")[0], String.valueOf(localeInstance.size())); + } else { + infoLogger("SUCCESS-LOADING-LANG-UPDATE", plugin.getName(), localeFile.getName().split("\\.")[0], String.valueOf(localeInstance.size()), String.valueOf(localeInstance.getLatestUpdateNodes().get())); + } + } +} diff --git a/src/main/scala/io/izzel/taboolib/locale/TLocaleSender.java b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleSender.java similarity index 87% rename from src/main/scala/io/izzel/taboolib/locale/TLocaleSender.java rename to src/main/scala/io/izzel/taboolib/module/locale/TLocaleSender.java index 4a56088..f5f013d 100644 --- a/src/main/scala/io/izzel/taboolib/locale/TLocaleSender.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleSender.java @@ -1,4 +1,4 @@ -package io.izzel.taboolib.locale; +package io.izzel.taboolib.module.locale; import org.bukkit.command.CommandSender; diff --git a/src/main/scala/io/izzel/taboolib/locale/TLocaleSerialize.java b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleSerialize.java similarity index 98% rename from src/main/scala/io/izzel/taboolib/locale/TLocaleSerialize.java rename to src/main/scala/io/izzel/taboolib/module/locale/TLocaleSerialize.java index db71467..7f3b662 100644 --- a/src/main/scala/io/izzel/taboolib/locale/TLocaleSerialize.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/TLocaleSerialize.java @@ -1,4 +1,4 @@ -package io.izzel.taboolib.locale; +package io.izzel.taboolib.module.locale; import org.bukkit.command.CommandSender; import org.bukkit.configuration.serialization.ConfigurationSerializable; diff --git a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleActionBar.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleActionBar.java similarity index 91% rename from src/main/scala/io/izzel/taboolib/locale/type/TLocaleActionBar.java rename to src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleActionBar.java index c990156..5679094 100644 --- a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleActionBar.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleActionBar.java @@ -1,8 +1,8 @@ -package io.izzel.taboolib.locale.type; +package io.izzel.taboolib.module.locale.type; import com.google.common.collect.Maps; -import io.izzel.taboolib.locale.TLocale; -import io.izzel.taboolib.locale.TLocaleSerialize; +import io.izzel.taboolib.module.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocaleSerialize; import io.izzel.taboolib.module.compat.PlaceholderHook; import io.izzel.taboolib.util.Strings; import org.bukkit.ChatColor; diff --git a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleBook.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleBook.java similarity index 95% rename from src/main/scala/io/izzel/taboolib/locale/type/TLocaleBook.java rename to src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleBook.java index 6b0068b..c398ea5 100644 --- a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleBook.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleBook.java @@ -1,9 +1,9 @@ -package io.izzel.taboolib.locale.type; +package io.izzel.taboolib.module.locale.type; import com.google.common.collect.Maps; import io.izzel.taboolib.TabooLib; -import io.izzel.taboolib.locale.TLocale; -import io.izzel.taboolib.locale.TLocaleSerialize; +import io.izzel.taboolib.module.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocaleSerialize; import io.izzel.taboolib.module.tellraw.TellrawJson; import io.izzel.taboolib.origin.book.BookFormatter; import io.izzel.taboolib.origin.book.builder.BookBuilder; diff --git a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleBossBar.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleBossBar.java similarity index 95% rename from src/main/scala/io/izzel/taboolib/locale/type/TLocaleBossBar.java rename to src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleBossBar.java index 4692f7c..c4c4b7b 100644 --- a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleBossBar.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleBossBar.java @@ -1,7 +1,7 @@ -package io.izzel.taboolib.locale.type; +package io.izzel.taboolib.module.locale.type; -import io.izzel.taboolib.locale.TLocale; -import io.izzel.taboolib.locale.TLocaleSerialize; +import io.izzel.taboolib.module.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocaleSerialize; import io.izzel.taboolib.util.Strings; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; diff --git a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleJson.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java similarity index 98% rename from src/main/scala/io/izzel/taboolib/locale/type/TLocaleJson.java rename to src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java index 7049717..6eb160b 100644 --- a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleJson.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java @@ -1,11 +1,11 @@ -package io.izzel.taboolib.locale.type; +package io.izzel.taboolib.module.locale.type; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import io.izzel.taboolib.TabooLib; -import io.izzel.taboolib.locale.TLocale; -import io.izzel.taboolib.locale.TLocaleSerialize; +import io.izzel.taboolib.module.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocaleSerialize; import io.izzel.taboolib.module.compat.PlaceholderHook; import io.izzel.taboolib.module.tellraw.TellrawJson; import io.izzel.taboolib.util.Strings; diff --git a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleSound.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleSound.java similarity index 95% rename from src/main/scala/io/izzel/taboolib/locale/type/TLocaleSound.java rename to src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleSound.java index a586b3e..06defee 100644 --- a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleSound.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleSound.java @@ -1,7 +1,7 @@ -package io.izzel.taboolib.locale.type; +package io.izzel.taboolib.module.locale.type; import com.google.common.collect.Maps; -import io.izzel.taboolib.locale.TLocaleSerialize; +import io.izzel.taboolib.module.locale.TLocaleSerialize; import io.izzel.taboolib.origin.lite.Sounds; import org.bukkit.command.CommandSender; import org.bukkit.configuration.serialization.SerializableAs; diff --git a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleText.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleText.java similarity index 96% rename from src/main/scala/io/izzel/taboolib/locale/type/TLocaleText.java rename to src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleText.java index b1a1f9a..b4b1166 100644 --- a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleText.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleText.java @@ -1,10 +1,10 @@ -package io.izzel.taboolib.locale.type; +package io.izzel.taboolib.module.locale.type; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -import io.izzel.taboolib.locale.TLocale; -import io.izzel.taboolib.locale.TLocaleSerialize; +import io.izzel.taboolib.module.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocaleSerialize; import io.izzel.taboolib.util.Strings; import org.bukkit.command.CommandSender; import org.bukkit.configuration.serialization.SerializableAs; diff --git a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleTitle.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleTitle.java similarity index 94% rename from src/main/scala/io/izzel/taboolib/locale/type/TLocaleTitle.java rename to src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleTitle.java index 32128bd..f29cc7b 100644 --- a/src/main/scala/io/izzel/taboolib/locale/type/TLocaleTitle.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleTitle.java @@ -1,8 +1,8 @@ -package io.izzel.taboolib.locale.type; +package io.izzel.taboolib.module.locale.type; import com.google.common.collect.Maps; -import io.izzel.taboolib.locale.TLocale; -import io.izzel.taboolib.locale.TLocaleSerialize; +import io.izzel.taboolib.module.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocaleSerialize; import io.izzel.taboolib.util.Strings; import org.bukkit.command.CommandSender; import org.bukkit.configuration.serialization.SerializableAs; diff --git a/src/main/scala/io/izzel/taboolib/module/logger/TLogger.java b/src/main/scala/io/izzel/taboolib/module/logger/TLogger.java index 95d7a20..711f0c7 100644 --- a/src/main/scala/io/izzel/taboolib/module/logger/TLogger.java +++ b/src/main/scala/io/izzel/taboolib/module/logger/TLogger.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.module.logger; import io.izzel.taboolib.TabooLibAPI; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.util.Strings; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/main/scala/io/izzel/taboolib/module/mysql/hikari/HikariHandler.java b/src/main/scala/io/izzel/taboolib/module/mysql/hikari/HikariHandler.java index bfa9761..791ecd5 100644 --- a/src/main/scala/io/izzel/taboolib/module/mysql/hikari/HikariHandler.java +++ b/src/main/scala/io/izzel/taboolib/module/mysql/hikari/HikariHandler.java @@ -2,7 +2,7 @@ package io.izzel.taboolib.module.mysql.hikari; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.config.TConfig; import io.izzel.taboolib.module.inject.TInject; import io.izzel.taboolib.module.mysql.IHost; diff --git a/src/main/scala/io/izzel/taboolib/module/tellraw/TellrawJson.java b/src/main/scala/io/izzel/taboolib/module/tellraw/TellrawJson.java index e48189d..3ce5607 100644 --- a/src/main/scala/io/izzel/taboolib/module/tellraw/TellrawJson.java +++ b/src/main/scala/io/izzel/taboolib/module/tellraw/TellrawJson.java @@ -1,6 +1,6 @@ package io.izzel.taboolib.module.tellraw; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.util.ArrayUtil; import io.izzel.taboolib.util.Strings; import io.izzel.taboolib.util.chat.*; diff --git a/src/main/scala/io/izzel/taboolib/origin/client/TabooLibClient.java b/src/main/scala/io/izzel/taboolib/origin/client/TabooLibClient.java index 9efb69f..445f364 100644 --- a/src/main/scala/io/izzel/taboolib/origin/client/TabooLibClient.java +++ b/src/main/scala/io/izzel/taboolib/origin/client/TabooLibClient.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.origin.client; import io.izzel.taboolib.TabooLib; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.lite.SimpleCommandBuilder; import io.izzel.taboolib.origin.client.packet.Packet; import io.izzel.taboolib.origin.client.packet.PacketSerializer; diff --git a/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketJoin.java b/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketJoin.java index 593b41f..d67d77d 100644 --- a/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketJoin.java +++ b/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketJoin.java @@ -1,6 +1,6 @@ package io.izzel.taboolib.origin.client.packet.impl; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.origin.client.TabooLibServer; import io.izzel.taboolib.origin.client.packet.Packet; import io.izzel.taboolib.origin.client.packet.PacketType; diff --git a/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketMessage.java b/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketMessage.java index 33e141e..f63a8a4 100644 --- a/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketMessage.java +++ b/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketMessage.java @@ -1,6 +1,6 @@ package io.izzel.taboolib.origin.client.packet.impl; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.origin.client.TabooLibServer; import io.izzel.taboolib.origin.client.packet.Packet; import io.izzel.taboolib.origin.client.packet.PacketType; diff --git a/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketQuit.java b/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketQuit.java index 3eeba14..9d27054 100644 --- a/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketQuit.java +++ b/src/main/scala/io/izzel/taboolib/origin/client/packet/impl/PacketQuit.java @@ -1,6 +1,6 @@ package io.izzel.taboolib.origin.client.packet.impl; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.origin.client.TabooLibServer; import io.izzel.taboolib.origin.client.packet.Packet; import io.izzel.taboolib.origin.client.packet.PacketType; diff --git a/src/main/scala/io/izzel/taboolib/origin/cronus/util/StringExpression.java b/src/main/scala/io/izzel/taboolib/origin/cronus/util/StringExpression.java index e923da8..f5ed441 100644 --- a/src/main/scala/io/izzel/taboolib/origin/cronus/util/StringExpression.java +++ b/src/main/scala/io/izzel/taboolib/origin/cronus/util/StringExpression.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.origin.cronus.util; import io.izzel.taboolib.module.logger.TLogger; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.inject.TInject; import java.util.regex.Matcher; diff --git a/src/main/scala/io/izzel/taboolib/origin/database/PluginDataManager.java b/src/main/scala/io/izzel/taboolib/origin/database/PluginDataManager.java index 744dc8b..ef56402 100644 --- a/src/main/scala/io/izzel/taboolib/origin/database/PluginDataManager.java +++ b/src/main/scala/io/izzel/taboolib/origin/database/PluginDataManager.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.origin.database; import io.izzel.taboolib.TabooLib; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.util.Files; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; diff --git a/src/main/scala/io/izzel/taboolib/origin/lite/Logs.java b/src/main/scala/io/izzel/taboolib/origin/lite/Logs.java index 8e97dba..0657a98 100644 --- a/src/main/scala/io/izzel/taboolib/origin/lite/Logs.java +++ b/src/main/scala/io/izzel/taboolib/origin/lite/Logs.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.origin.lite; import io.izzel.taboolib.TabooLib; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.TCommand; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; diff --git a/src/main/scala/io/izzel/taboolib/util/Files.java b/src/main/scala/io/izzel/taboolib/util/Files.java index a686ecd..fb7ca05 100644 --- a/src/main/scala/io/izzel/taboolib/util/Files.java +++ b/src/main/scala/io/izzel/taboolib/util/Files.java @@ -1,7 +1,7 @@ package io.izzel.taboolib.util; import io.izzel.taboolib.TabooLib; -import io.izzel.taboolib.locale.TLocale; +import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.plugin.InternalPlugin; import io.izzel.taboolib.util.eagletdl.EagletTask; import io.izzel.taboolib.util.eagletdl.ProgressEvent; diff --git a/src/main/scala/io/lzzel/tlibscala/Prelude.scala b/src/main/scala/io/lzzel/tlibscala/Prelude.scala index 464505a..e2db6f7 100644 --- a/src/main/scala/io/lzzel/tlibscala/Prelude.scala +++ b/src/main/scala/io/lzzel/tlibscala/Prelude.scala @@ -1,6 +1,6 @@ package io.lzzel.tlibscala -import io.izzel.taboolib.locale.TLocale.Logger +import io.izzel.taboolib.module.locale.TLocale.Logger import org.bukkit.Bukkit import org.bukkit.event.{Event, EventException, EventPriority, Listener} import org.bukkit.plugin.{EventExecutor, Plugin} diff --git a/src/main/scala/io/lzzel/tlibscala/runtime/RichPlayer.scala b/src/main/scala/io/lzzel/tlibscala/runtime/RichPlayer.scala index e594edf..1263ae1 100644 --- a/src/main/scala/io/lzzel/tlibscala/runtime/RichPlayer.scala +++ b/src/main/scala/io/lzzel/tlibscala/runtime/RichPlayer.scala @@ -1,6 +1,6 @@ package io.lzzel.tlibscala.runtime -import io.izzel.taboolib.locale.TLocale +import io.izzel.taboolib.module.locale.TLocale import io.izzel.taboolib.module.compat.PermissionHook import io.izzel.taboolib.origin.lite.Boards import org.bukkit.entity.Player