diff --git a/pom.xml b/pom.xml index 9a26ec6..22b94ea 100644 --- a/pom.xml +++ b/pom.xml @@ -95,8 +95,13 @@ org.slf4j:slf4j-api com.maxmind.geoip:geoip-api com.google.code.gson:gson + cn.citycraft:PluginHelper + + cn.citycraft.PluginHelper + ${project.groupId}.${project.artifactId} + diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index e0518dc..9195682 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -72,6 +72,7 @@ public class AuthMe extends JavaPlugin { public NewAPI api; public ConcurrentHashMap cap = new ConcurrentHashMap<>(); public ConcurrentHashMap captcha = new ConcurrentHashMap<>(); + public FileConfig config; public DataSource database; public DataManager dataManager; public boolean delayedAntiBot = true; @@ -80,9 +81,7 @@ public class AuthMe extends JavaPlugin { public AuthMeInventoryPacketAdapter inventoryProtector; public Management management; public OtherAccounts otherAccounts; - public FileConfig config; - // Hooks TODO: move into modules public Permission permission; public ConcurrentHashMap realIp = new ConcurrentHashMap<>(); @@ -285,7 +284,7 @@ public class AuthMe extends JavaPlugin { if (Backup) { ConsoleLogger.info("数据文件备份完成."); } else { - ConsoleLogger.showError("Error while performing the backup!"); + ConsoleLogger.showError("备份数据文件时发生错误 备份失败!"); } } @@ -315,6 +314,7 @@ public class AuthMe extends JavaPlugin { try { settings = new Settings(this); Settings.reloadcfg(); + Settings.loadVariables(); } catch (final Exception e) { ConsoleLogger.writeStackTrace(e); ConsoleLogger.showError("无法载入配置文件... 某些配置是错误的, 为了安全考虑 服务器即将关闭!"); @@ -347,7 +347,6 @@ public class AuthMe extends JavaPlugin { // AntiBot delay if (Settings.enableAntiBot) { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override public void run() { delayedAntiBot = false; @@ -374,7 +373,7 @@ public class AuthMe extends JavaPlugin { if (new PerformBackup(this).doBackup()) { ConsoleLogger.info("数据备份完成..."); } else { - ConsoleLogger.showError("Error while performing the backup!"); + ConsoleLogger.showError("备份数据文件时发生错误 备份失败!"); } } @@ -384,7 +383,7 @@ public class AuthMe extends JavaPlugin { } catch (final Exception e) { ConsoleLogger.writeStackTrace(e); ConsoleLogger.showError(e.getMessage()); - ConsoleLogger.showError("连接数据库期间发生错误! Authme 初始化 中断!"); + ConsoleLogger.showError("连接数据库期间发生错误! Authme 初始化被中断!"); stopOrUnload(); return; } diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java index bc95a9e..0d844f3 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java @@ -122,16 +122,16 @@ public class SQLite implements DataSource { while (rs.next()) { PlayerAuth pAuth; if (rs.getString(columnIp).isEmpty()) { - pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), - rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); + pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs + .getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); } else { if (!columnSalt.isEmpty()) { - pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), - rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), - rs.getString(columnRealName)); + pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs + .getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs + .getString(columnRealName)); } else { - pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), - rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); + pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs + .getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); } } auths.add(pAuth); @@ -227,16 +227,16 @@ public class SQLite implements DataSource { rs = pst.executeQuery(); if (rs.next()) { if (rs.getString(columnIp).isEmpty()) { - return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), - rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); + return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs + .getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); } else { if (!columnSalt.isEmpty()) { - return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), - rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), - rs.getString(columnRealName)); + return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs + .getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs + .getString(columnRealName)); } else { - return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), - rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); + return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs + .getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); } } } else { @@ -284,16 +284,16 @@ public class SQLite implements DataSource { while (rs.next()) { PlayerAuth pAuth; if (rs.getString(columnIp).isEmpty()) { - pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), - rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); + pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs + .getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); } else { if (!columnSalt.isEmpty()) { - pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), - rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), - rs.getString(columnRealName)); + pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs + .getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs + .getString(columnRealName)); } else { - pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), - rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); + pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs + .getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName)); } } auths.add(pAuth); @@ -613,7 +613,7 @@ public class SQLite implements DataSource { private synchronized void connect() throws ClassNotFoundException, SQLException { Class.forName("org.sqlite.JDBC"); - ConsoleLogger.info("SQLite driver loaded"); + ConsoleLogger.info("SQLite 驱动载入成功..."); this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db"); } @@ -672,6 +672,6 @@ public class SQLite implements DataSource { close(rs); close(st); } - ConsoleLogger.info("SQLite Setup finished"); + ConsoleLogger.info("SQLite 数据表已初始化并载入完毕..."); } } diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index ce2819b..bf322ac 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -60,7 +60,6 @@ public final class Settings extends FileConfig { customAttributes, generateImage, isRemoveSpeedEnabled; public static final File LOG_FILE = new File(APLUGIN_FOLDER, "authme.log"); public static File messageFile; - public static final File MODULE_FOLDER = new File(APLUGIN_FOLDER, "modules"); public static int purgeDelay = 60; public static final File SETTINGS_FILE = new File(APLUGIN_FOLDER, "config.yml"); public static List unsafePasswords; @@ -80,19 +79,6 @@ public final class Settings extends FileConfig { configFile = (FileConfig) plugin.getConfig(); } - public static String checkLang(final String lang) { - if (new File(APLUGIN_FOLDER, "messages" + File.separator + "messages_" + lang + ".yml").exists()) { - ConsoleLogger.info("配置语言文件: " + lang); - return lang; - } - if (AuthMe.class.getResourceAsStream("/messages/messages_" + lang + ".yml") != null) { - ConsoleLogger.info("配置语言文件: " + lang); - return lang; - } - ConsoleLogger.info("语言文件未找到 " + lang + ", 使用默认语言: en !"); - return "en"; - } - /** * Config option for setting and check restricted user by username;ip , * return false if ip and name doesnt amtch with player that join the @@ -149,7 +135,6 @@ public final class Settings extends FileConfig { } public static void loadVariables() { - messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "zhcn").toLowerCase()); isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false); isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true); isRegistrationEnabled = configFile.getBoolean("settings.registration.enabled", true); @@ -311,7 +296,7 @@ public final class Settings extends FileConfig { forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole"); customAttributes = configFile.getBoolean("Hooks.customAttributes"); generateImage = configFile.getBoolean("Email.generateImage", true); - + messageFile = new File(APLUGIN_FOLDER, "messages_zhcn.yml"); // Load the welcome message getWelcomeMessage(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 8e26886..a3a24bc 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -275,7 +275,7 @@ Security: console: # 移除控制台消息 noConsoleSpam: false - # 当玩家输入类似 /login 指令时,在后台替换显示的密码 + # 当玩家输入类似 /login 指令时,在后台替换显示的密码 removePassword: true captcha: # 当玩家输入错误密码很多次后需要填写验证码 @@ -337,4 +337,4 @@ Protection: # Max number of player allowed to login in 5 secs before enable AntiBot system automatically antiBotSensibility: 5 # Duration in minutes of the antibot automatic system - antiBotDuration: 10 + antiBotDuration: 10 \ No newline at end of file diff --git a/src/main/resources/messages/messages_en.yml b/src/main/resources/messages/messages_en.yml deleted file mode 100644 index 16218f3..0000000 --- a/src/main/resources/messages/messages_en.yml +++ /dev/null @@ -1,58 +0,0 @@ -unknown_user: '&cCan''t find the requested user in the database!' -unsafe_spawn: '&cYour quit location was unsafe, you have been teleported to the world''s spawnpoint.' -not_logged_in: '&cYou''re not logged in!' -reg_voluntarily: 'You can register yourself to the server with the command "/register "' -usage_log: '&cUsage: /login ' -wrong_pwd: '&cWrong password!' -unregistered: '&cSuccessfully unregistered!' -reg_disabled: '&cIn-game registration is disabled!' -valid_session: '&2Logged-in due to Session Reconnection.' -login: '&2Successful login!' -vb_nonActiv: '&cYour account isn''t activated yet, please check your emails!' -user_regged: '&cYou already have registered this username!' -usage_reg: '&cUsage: /register ' -max_reg: '&cYou have exceeded the maximum number of registrations for your connection!' -no_perm: '&4You don''t have the permission to perform this action!' -error: '&4An unexpected error occurred, please contact an Administrator!' -login_msg: '&cPlease, login with the command "/login "' -reg_msg: '&3Please, register to the server with the command "/register "' -reg_email_msg: '&3Please, register to the server with the command "/register "' -usage_unreg: '&cUsage: /unregister ' -pwd_changed: '&2Password changed successfully!' -user_unknown: '&cThis user isn''t registered!' -password_error: '&cPasswords didn''t match, check them again!' -password_error_nick: '&cYou can''t use your name as password, please choose another one...' -password_error_unsafe: '&cThe chosen password isn''t safe, please choose another one...' -invalid_session: '&cYour IP has been changed and your session data has expired!' -reg_only: '&4Only registered users can join the server! Please visit http://example.com to register yourself!' -logged_in: '&cYou''re already logged in!' -logout: '&2Logged-out successfully!' -same_nick: '&4The same username is already playing on the server!' -registered: '&2Successfully registered!' -pass_len: '&cYour password is too short or too long! Please try with another one!' -reload: '&2Configuration and database have been reloaded correctly!' -timeout: '&4Login timeout exceeded, you have been kicked from the server, please try again!' -usage_changepassword: '&cUsage: /changepassword ' -name_len: '&4Your username is either too short or too long!' -regex: '&4Your username contains illegal characters. Allowed chars: REG_EX' -add_email: '&3Please add your email to your account with the command "/email add "' -recovery_email: '&3Forgot your password? Please use the command "/email recovery "' -usage_captcha: '&3To login you have to solve a captcha code, please use the command "/captcha "' -wrong_captcha: '&cWrong Captcha, please type "/captcha THE_CAPTCHA" into the chat!' -valid_captcha: '&2Captcha code solved correctly!' -kick_forvip: '&3A VIP Player has joined the server when it was full!' -kick_fullserver: '&4The server is full, try again later!' -usage_email_add: '&cUsage: /email add ' -usage_email_change: '&cUsage: /email change ' -usage_email_recovery: '&cUsage: /email recovery ' -new_email_invalid: '&cInvalid New Email, try again!' -old_email_invalid: '&cInvalid Old Email, try again!' -email_invalid: '&cInvalid Email address, try again!' -email_added: '&2Email address successfully added to your account!' -email_confirm: '&cPlease confirm your email address!' -email_changed: '&2Email address changed correctly!' -email_send: '&2Recovery email sent correctly! Check your email inbox!' -email_exists: '&cA recovery email was already sent! You can discart it and send a new one using the command below:' -country_banned: '&4Your country is banned from this server!' -antibot_auto_enabled: '&4[AntiBotService] AntiBot enabled due to the huge number of connections!' -antibot_auto_disabled: '&2[AntiBotService] AntiBot disabled disabled after %m minutes!' diff --git a/src/main/resources/messages/messages_zhcn.yml b/src/main/resources/messages_zhcn.yml similarity index 50% rename from src/main/resources/messages/messages_zhcn.yml rename to src/main/resources/messages_zhcn.yml index 2d28081..a513105 100644 Binary files a/src/main/resources/messages/messages_zhcn.yml and b/src/main/resources/messages_zhcn.yml differ