55
									
								
								src/main/resources/__resources__/lang/en_US.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								src/main/resources/__resources__/lang/en_US.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
LOCALE:
 | 
			
		||||
  TITLE-SEND-TO-NON-PLAYER: 'This TLocale type can only be sent to player:{0}'
 | 
			
		||||
  PLUGIN-NOT-FOUND: 'Invaild plugin: &4{0}'
 | 
			
		||||
  BOOK-ARGUMENTS-IDENTIFICATION-FAILED: 'TlocaleBook variables identiy failed: {0}'
 | 
			
		||||
  BAR-COLOR-IDENTIFICATION-FAILED: 'TLocaleBossBar color identify failed: {0}'
 | 
			
		||||
  BAR-STYLE-IDENTIFICATION-FAILED: 'TLocaleBossBar type identify failed: {0}'
 | 
			
		||||
  BAR-PLUGIN-NOT-FOUND: 'TLocaleBossBar is depend on BossBarAPI'
 | 
			
		||||
  CALLER-PLUGIN-NOT-FOUND: '{0} is not called by a plugin'
 | 
			
		||||
  STATIC-CLASS-LOADER: '{0} Initialized by a static class loader, unable to get its plugin'
 | 
			
		||||
 | 
			
		||||
MISC:
 | 
			
		||||
  FIELD-COPY-FAILED: 'Failed to copy {0}'
 | 
			
		||||
  FIELD-COPY-ERROR: 'Error when copy {0}:{1}'
 | 
			
		||||
 | 
			
		||||
MYSQL-HIKARI:
 | 
			
		||||
  CREATE-SUCCESS: '&7插件 &f{0} &7注册新的连接池: &f{1}'
 | 
			
		||||
  CREATE-EXISTS: '&7插件 &f{0} &7引用插件 &f{1} &7注册的连接池.'
 | 
			
		||||
  CLOSE-SUCCESS: '&7插件 &f{0} &7注册的连接池 &f{1} &7已被注销.'
 | 
			
		||||
  CLOSE-FAIL: '&7插件 &f{0} &7注册的连接池正在被 &f{1} &7个插件使用, 无法注销!'
 | 
			
		||||
 | 
			
		||||
COMMANDS:
 | 
			
		||||
  GLOBAL:
 | 
			
		||||
    ONLY-PLAYER: '&8[&3&lTabooLib&8] &4This is only for player.'
 | 
			
		||||
    ONLY-STORAGE-SQL: '&8[&3&lTabooLib&8] &4只有启用数据库储存时才能这么做'
 | 
			
		||||
  INTERNAL:
 | 
			
		||||
    TYPE-ERROR: '&8[&3&lTabooLib&8] &7Command &f{0} &7can only be executed by &f{1} &7.'
 | 
			
		||||
    TYPE-PLAYER: 'Player'
 | 
			
		||||
    TYPE-CONSOLE: 'Console'
 | 
			
		||||
    ERROR-USAGE:
 | 
			
		||||
      - '&8[&3&lTabooLib&8] &7Command &f{0} &7'
 | 
			
		||||
      - '&8[&3&lTabooLib&8] &7正确用法:'
 | 
			
		||||
      - '&8[&3&lTabooLib&8] &7{1}'
 | 
			
		||||
    ERROR-COMMAND:
 | 
			
		||||
      - '&8[&3&lTabooLib&8] &7指令 &f{0} &7不存在'
 | 
			
		||||
      - '&8[&3&lTabooLib&8] &7你可能想要:'
 | 
			
		||||
      - '&8[&3&lTabooLib&8] &7{1}'
 | 
			
		||||
    COMMAND-CREATE-FAILED: '&c插件 &7{0} &c的 &7{1} &c命令注册失败: &7{2}'
 | 
			
		||||
    COMMAND-HELP: ' §f/{0} {1} {2}§6- §e{3}'
 | 
			
		||||
    COMMAND-HELP-EMPTY: ' §f/{0} {1} {2}'
 | 
			
		||||
    COMMAND-ARGUMENT: '§7<§8{0}§7>'
 | 
			
		||||
    COMMAND-ARGUMENT-REQUIRE: '§7[§8{0}§7]'
 | 
			
		||||
  PARAMETER:
 | 
			
		||||
    UNKNOWN: '&8[&3&lTabooLib&8] &4指令错误'
 | 
			
		||||
    INSUFFICIENT: '&8[&3&lTabooLib&8] &4参数不足'
 | 
			
		||||
 | 
			
		||||
COMMUNICATION:
 | 
			
		||||
  FAILED-LOAD-SETTINGS: '§8[§3§lTabooLibClient§8] &4配置载入失败: {0}'
 | 
			
		||||
  FAILED-CONNECT-SERVER: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接失败.'
 | 
			
		||||
  FAILED-CONNECT-CLIENT: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接出错: {0}'
 | 
			
		||||
  FAILED-READING-PACKET: '§8[§3§lTabooLibClient§8] &4本地通讯网络数据包读取失败: {0}'
 | 
			
		||||
  SUCCESS-CONNECTED: '§8[§3§lTabooLibClient§8] &7本地通讯网络连接成功.'
 | 
			
		||||
  CLIENT-JOINED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7加入本地通讯网络.'
 | 
			
		||||
  CLIENT-QUITED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7退出本地通讯网络.'
 | 
			
		||||
  PACKET-MESSAGE: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7发送信息: &f{1}'
 | 
			
		||||
  PACKET-COMMAND: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7运行命令: &f{1}'
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
TRY-LOADING-LANG: '尝试为 {0} 加载 {1} 语言文件'
 | 
			
		||||
SUCCESS-LOADING-LANG-NORMAL: '成功为 {0} 加载 {1} 语言文件, 共 {2} 项'
 | 
			
		||||
SUCCESS-LOADING-LANG-UPDATE: '成功为 {0} 加载 {1} 语言文件, 共 {2} 项, 及 {3} 项新条目'
 | 
			
		||||
ERROR-LOADING-LANG: '加载 {0} 插件的语言文件时发生异常:{1}'
 | 
			
		||||
FETCH-LOCALE-ERROR: '语言文件获取失败:{0}'
 | 
			
		||||
SEND-LOCALE-ERROR: '语言文件发送失败:{0}'
 | 
			
		||||
LOCALE-ERROR-REASON: '原因:{0}'
 | 
			
		||||
MISSING-ARGUMENT: '语言文本含有没有找到的参数 {0}'
 | 
			
		||||
DEPENDENCY-DOWNLOAD-START: '  正在下载 {0} 库文件'
 | 
			
		||||
DEPENDENCY-LOAD-FAIL: '  {0} 请求的库文件 {1} 加载失败'
 | 
			
		||||
TRY-LOADING-LANG: 'Try loading language {1} for {0}...'
 | 
			
		||||
SUCCESS-LOADING-LANG-NORMAL: 'Loaded {1} for {0} as locale, in total {2} nodes'
 | 
			
		||||
SUCCESS-LOADING-LANG-UPDATE: 'Loaded {1} for {0} as locale, in total {2} nodes, {3} new nodes'
 | 
			
		||||
ERROR-LOADING-LANG: 'Error occureed when loading language for {0}: {1}'
 | 
			
		||||
FETCH-LOCALE-ERROR: 'Failed fetching language:{0}'
 | 
			
		||||
SEND-LOCALE-ERROR: 'Failed sending language:{0}'
 | 
			
		||||
LOCALE-ERROR-REASON: 'Reason:{0}'
 | 
			
		||||
MISSING-ARGUMENT: 'Missing argument {0}'
 | 
			
		||||
DEPENDENCY-DOWNLOAD-START: '  Download {0} library'
 | 
			
		||||
DEPENDENCY-LOAD-FAIL: '  The requested library file {1} by {0} failed to load'
 | 
			
		||||
@@ -87,8 +87,8 @@ public class SimpleI18n {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static File getLocaleFile(Plugin plugin) {
 | 
			
		||||
        TLocaleLoader.getLocalePriority().forEach(localeName -> Files.releaseResource(plugin, "simpleI18n/" + getVersion() + "/" + localeName + ".yml", false));
 | 
			
		||||
        return TLocaleLoader.getLocalePriority().stream().map(localeName -> new File("plugins/TabooLib/simpleI18n/" + getVersion() + "/" + localeName + ".yml")).filter(File::exists).findFirst().orElse(null);
 | 
			
		||||
        TLocaleLoader.getLocalePriority(plugin).forEach(localeName -> Files.releaseResource(plugin, "simpleI18n/" + getVersion() + "/" + localeName + ".yml", false));
 | 
			
		||||
        return TLocaleLoader.getLocalePriority(plugin).stream().map(localeName -> new File("plugins/TabooLib/simpleI18n/" + getVersion() + "/" + localeName + ".yml")).filter(File::exists).findFirst().orElse(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static String getVersion() {
 | 
			
		||||
 
 | 
			
		||||
@@ -118,7 +118,7 @@ public class TLocale {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void reload() {
 | 
			
		||||
        Ref.getCallerClass(3).ifPresent(clazz -> TLocaleLoader.load(Ref.getCallerPlugin(clazz), false));
 | 
			
		||||
        Ref.getCallerClass(3).ifPresent(clazz -> TLocaleLoader.load(Ref.getCallerPlugin(clazz), true));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static final class Tellraw extends TLocale {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
 | 
			
		||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
 | 
			
		||||
import org.bukkit.plugin.Plugin;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
@@ -22,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
 | 
			
		||||
public class TLocaleLoader {
 | 
			
		||||
 | 
			
		||||
    private static final Map<String, List<String>> localePriority = new HashMap<>();
 | 
			
		||||
    private static final Map<String, TLocaleInstance> map = new ConcurrentHashMap<>();
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
@@ -76,6 +78,12 @@ public class TLocaleLoader {
 | 
			
		||||
    public static void load(Plugin plugin, boolean isCover) {
 | 
			
		||||
        try {
 | 
			
		||||
            if (isLoadLocale(plugin, isCover)) {
 | 
			
		||||
                // 启用插件指定的独立语言加载顺序
 | 
			
		||||
                File settings = new File("plugins/" + plugin.getName() + "/settings.yml");
 | 
			
		||||
                List<String> priority = settings.exists() ? YamlConfiguration.loadConfiguration(settings).getStringList("LOCALE-PRIORITY") : plugin.getResource("settings.yml") != null ? YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(plugin.getResource("settings.yml")))).getStringList("LOCALE-PRIORITY") : new ArrayList<>();
 | 
			
		||||
                if (!priority.isEmpty()) {
 | 
			
		||||
                    setLocalePriority(plugin, priority);
 | 
			
		||||
                }
 | 
			
		||||
                // 获取文件
 | 
			
		||||
                File localeFile = getLocaleFile(plugin);
 | 
			
		||||
                if (localeFile == null) {
 | 
			
		||||
@@ -107,8 +115,12 @@ public class TLocaleLoader {
 | 
			
		||||
        return plugin.getClass().getSuperclass().getSimpleName().equals("TabooPlugin");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static List<String> getLocalePriority() {
 | 
			
		||||
        return TabooLib.getConfig().contains("LOCALE.PRIORITY") ? TabooLib.getConfig().getStringList("LOCALE.PRIORITY") : Collections.singletonList("zh_CN");
 | 
			
		||||
    public static List<String> getLocalePriority(Plugin plugin) {
 | 
			
		||||
        return localePriority.getOrDefault(plugin.getName(), TabooLib.getConfig().contains("LOCALE.PRIORITY") ? TabooLib.getConfig().getStringList("LOCALE.PRIORITY") : Collections.singletonList("zh_CN"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static List<String> setLocalePriority(Plugin plugin, List<String> priority) {
 | 
			
		||||
        return localePriority.put(plugin.getName(), priority);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean isLoadLocale(Plugin plugin, boolean isCover) {
 | 
			
		||||
@@ -124,8 +136,8 @@ public class TLocaleLoader {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static File getLocaleFile(Plugin plugin) {
 | 
			
		||||
        getLocalePriority().forEach(localeName -> Files.releaseResource(plugin, "lang/" + localeName + ".yml", false));
 | 
			
		||||
        return getLocalePriority().stream().map(localeName -> new File("plugins/" + plugin.getName() + "/lang/" + localeName + ".yml")).filter(File::exists).findFirst().orElse(null);
 | 
			
		||||
        getLocalePriority(plugin).forEach(localeName -> Files.releaseResource(plugin, "lang/" + localeName + ".yml", false));
 | 
			
		||||
        return getLocalePriority(plugin).stream().map(localeName -> new File("plugins/" + plugin.getName() + "/lang/" + localeName + ".yml")).filter(File::exists).findFirst().orElse(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static TLocaleInstance getLocaleInstance(Plugin plugin) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user