From fec466dd294acc8c40106025f9ea85e17d095d47 Mon Sep 17 00:00:00 2001 From: Xephi Date: Fri, 31 Jan 2014 17:56:36 +0100 Subject: [PATCH] Fix useWelcomeMessage + implement broadcast conf --- pom.xml | 2 +- src/main/java/fr/xephi/authme/AuthMe.java | 9 +++-- src/main/java/fr/xephi/authme/Management.java | 14 ++++++-- .../authme/commands/RegisterCommand.java | 12 +++++-- .../xephi/authme/plugin/manager/EssSpawn.java | 1 + .../fr/xephi/authme/settings/Settings.java | 15 +++++--- src/main/resources/config.yml | 2 ++ src/main/resources/messages_zhcn.yml | 36 +++++++++---------- src/main/resources/plugin.yml | 2 +- 9 files changed, 62 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index b0aa34b6..123c682f 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ - 3.3.1-DEV-1 + 3.3.2-DEV-1 org.bukkit diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 9f1bdb68..5d06ac6e 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -433,8 +433,13 @@ public class AuthMe extends JavaPlugin { ess = null; } if (this.getServer().getPluginManager().getPlugin("EssentialsSpawn") != null && this.getServer().getPluginManager().getPlugin("EssentialsSpawn").isEnabled()) { - this.essentialsSpawn = new EssSpawn().getLocation(); - ConsoleLogger.info("Hook with EssentialsSpawn plugin"); + try { + essentialsSpawn = new EssSpawn().getLocation(); + ConsoleLogger.info("Hook with EssentialsSpawn plugin"); + } catch (Exception e) { + essentialsSpawn = null; + ConsoleLogger.showError("Error while reading /plugins/Essentials/spawn.yml file "); + } } else { ess = null; } diff --git a/src/main/java/fr/xephi/authme/Management.java b/src/main/java/fr/xephi/authme/Management.java index aa9d8fab..eeef7a60 100644 --- a/src/main/java/fr/xephi/authme/Management.java +++ b/src/main/java/fr/xephi/authme/Management.java @@ -418,10 +418,18 @@ public class Management extends Thread { // The Loginevent now fires (as intended) after everything is processed Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true)); player.saveData(); - + // Login is finish, display welcome message - for (String s : Settings.welcomeMsg) - player.sendMessage(plugin.replaceAllInfos(s, player)); + if(Settings.useWelcomeMessage) + if(Settings.broadcastWelcomeMessage) { + for (String s : Settings.welcomeMsg) { + Bukkit.getServer().broadcastMessage(s); + } + } else { + for (String s : Settings.welcomeMsg) { + player.sendMessage(plugin.replaceAllInfos(s, player)); + } + } // Login is now finish , we can force all commands forceCommands(); diff --git a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java b/src/main/java/fr/xephi/authme/commands/RegisterCommand.java index 1260179e..0366ef81 100644 --- a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java +++ b/src/main/java/fr/xephi/authme/commands/RegisterCommand.java @@ -262,8 +262,16 @@ public class RegisterCommand implements CommandExecutor { player.saveData(); // Register is finish and player is logged, display welcome message - for (String s : Settings.welcomeMsg) - player.sendMessage(plugin.replaceAllInfos(s, player)); + if(Settings.useWelcomeMessage) + if(Settings.broadcastWelcomeMessage) { + for (String s : Settings.welcomeMsg) { + Bukkit.getServer().broadcastMessage(s); + } + } else { + for (String s : Settings.welcomeMsg) { + player.sendMessage(plugin.replaceAllInfos(s, player)); + } + } // Register is now finish , we can force all commands forceCommands(player); diff --git a/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java b/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java index e5f0fa1b..0b593a4e 100644 --- a/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java +++ b/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java @@ -26,6 +26,7 @@ public class EssSpawn extends CustomConfiguration { public Location getLocation() { try { + if (!this.contains("spawns.default.world")) return null; if (this.getString("spawns.default.world").isEmpty() || this.getString("spawns.default.world") == "") return null; Location location = new Location(Bukkit.getWorld(this.getString("spawns.default.world")), this.getDouble("spawns.default.x"), this.getDouble("spawns.default.y"), this.getDouble("spawns.default.z"), Float.parseFloat(this.getString("spawns.default.yaw")), Float.parseFloat(this.getString("spawns.default.pitch"))); return location; diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index 65868ee2..02fd382d 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -58,7 +58,8 @@ public final class Settings extends YamlConfiguration { useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange, disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd, usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative, - purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage; + purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, + broadcastWelcomeMessage; public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename, @@ -233,6 +234,7 @@ public void loadConfigOptions() { useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage", true); unsafePasswords = (List) configFile.getList("settings.security.unsafePasswords", new ArrayList()); countriesBlacklist = (List) configFile.getList("Protection.countriesBlacklist", new ArrayList()); + broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false); // Load the welcome message getWelcomeMessage(plugin); @@ -383,6 +385,7 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) { useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage", true); unsafePasswords = (List) configFile.getList("settings.security.unsafePasswords", new ArrayList()); countriesBlacklist = (List) configFile.getList("Protection.countriesBlacklist", new ArrayList()); + broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false); // Reload the welcome message getWelcomeMessage(AuthMe.getInstance()); @@ -516,6 +519,8 @@ public void mergeConfig() { countriesBlacklist.add("A1"); set("Protection.countriesBlacklist", countriesBlacklist); } + if(!contains("settings.broadcastWelcomeMessage")) + set("settings.broadcastWelcomeMessage", false); plugin.getLogger().warning("Merge new Config Options if needed.."); plugin.getLogger().warning("Please check your config.yml file!"); @@ -696,6 +701,10 @@ public void mergeConfig() { } private static void getWelcomeMessage(AuthMe plugin) { + welcomeMsg = new ArrayList(); + if(!useWelcomeMessage) { + return; + } if (!(new File(plugin.getDataFolder() + File.separator + "welcome.txt").exists())) { try { FileWriter fw = new FileWriter(plugin.getDataFolder() + File.separator + "welcome.txt", true); @@ -708,20 +717,18 @@ public void mergeConfig() { e.printStackTrace(); } } - List msg = new ArrayList(); try { FileReader fr = new FileReader(plugin.getDataFolder() + File.separator + "welcome.txt"); BufferedReader br = new BufferedReader(fr); String line = ""; while((line = br.readLine()) != null) { - msg.add(line); + welcomeMsg.add(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } - welcomeMsg = msg; } public enum messagesLang { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6d14e1e3..99527df0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -237,6 +237,8 @@ settings: # {IP} : player ip, {LOGINS} : number of players logged, {WORLD} : player current world, {SERVER} : server name # {VERSION} : get current bukkit version, {COUNTRY} : player country useWelcomeMessage: true + # Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player + broadcastWelcomeMessage: false ExternalBoardOptions: # MySQL column for the salt , needed for some forum/cms support mySQLColumnSalt: '' diff --git a/src/main/resources/messages_zhcn.yml b/src/main/resources/messages_zhcn.yml index 6ce9e7f1..4b893025 100644 --- a/src/main/resources/messages_zhcn.yml +++ b/src/main/resources/messages_zhcn.yml @@ -12,7 +12,7 @@ vb_nonActiv: '&f你的帐号还未激活,请查看你的邮箱!' user_regged: '&c此用户已经在此服务器注册过' usage_reg: '&c正确用法:“/register <密码> <再输入一次以确定密码>”' max_reg: '&f你不允许再为你的IP在服务器注册更多用户了!' -reg_email_msg: '&cPlease register with "/register "' +reg_email_msg: '&c请输入 "/register <邮箱> <确认电子邮件>"' no_perm: '&c没有权限' error: '&f发现错误,请联系管理员' login_msg: '&c请输入“/login <密码>”以登录' @@ -21,7 +21,7 @@ usage_unreg: '&c正确用法:“/unregister <密码>”' pwd_changed: '&c密码已成功修改!' user_unknown: '&c此用户名还未注册过' password_error: '&f密码不相同' -unvalid_session: '&fSession Dataes doesnt corrispond Plaese wait the end of session' +unvalid_session: '&f登陆数据异常,请等待登陆结束' reg_only: '&f只允许注册过的玩家进服!请到http://example.com以注册' logged_in: '&c你已经登陆过了!' logout: '&c已成功登出!' @@ -30,7 +30,7 @@ registered: '&c已成功注册!' pass_len: '&你的密码没有达到要求!' reload: '&f配置以及数据已经重新加载完毕' timeout: '&f给你登录的时间已经过了' -usage_changepassword: '&f正确用法:“/changepassword oldPassword ne”' +usage_changepassword: '&f正确用法:“/changepassword 旧密码 新密码”' name_len: '&c你的用户名太短或者太长了' regex: '&c你的用户名包含非法字母,用户名里允许的字母: REG_EX' add_email: '&c请输入“/email add <你的邮箱> <再输入一次以确认>”以把你的邮箱添加到此帐号' @@ -39,18 +39,18 @@ recovery_email: '&c忘了你的密码?请输入:“/email recovery <你的 usage_captcha: '&c正确用法:/captcha <验证码>' wrong_captcha: '&c错误的验证码,请输入:“/captcha <验证码>”' valid_captcha: '&c你的验证码是有效的!' -kick_forvip: '&cA VIP Player join the full server!' -kick_fullserver: '&cThe server is actually full, Sorry!' -usage_email_add: '&fUsage: /email add ' -usage_email_change: '&fUsage: /email change ' -usage_email_recovery: '&fUsage: /email recovery ' -new_email_invalid: '[AuthMe] New email invalid!' -old_email_invalid: '[AuthMe] Old email invalid!' -email_invalid: '[AuthMe] Invalid Email' -email_added: '[AuthMe] Email Added !' -email_confirm: '[AuthMe] Confirm your Email !' -email_changed: '[AuthMe] Email Change !' -email_send: '[AuthMe] Recovery Email Send !' -country_banned: 'Your country is banned from this server' -antibot_auto_enabled: '[AuthMe] AntiBotMod automatically enabled due to massive connections!' -antibot_auto_disabled: '[AuthMe] AntiBotMod automatically disabled after %m Minutes, hope invasion stopped' \ No newline at end of file +kick_forvip: '&cA VIP玩家加入了已满的服务器!' +kick_fullserver: '&c抱歉,服务器已满!' +usage_email_add: '&f用法: /email add <邮箱> <确认电子邮件> ' +usage_email_change: '&f用法: /email change <旧邮箱> <新邮箱> ' +usage_email_recovery: '&f用法: /email recovery <邮箱>' +new_email_invalid: '[AuthMe] 新邮箱无效!' +old_email_invalid: '[AuthMe] 旧邮箱无效!' +email_invalid: '[AuthMe] 无效的邮箱' +email_added: '[AuthMe] 邮箱已添加 !' +email_confirm: '[AuthMe] 确认你的邮箱 !' +email_changed: '[AuthMe] 邮箱已改变 !' +email_send: '[AuthMe] 恢复邮件已发送 !' +country_banned: '这个服务器禁止该国家登陆' +antibot_auto_enabled: '[AuthMe] 防机器人程序由于大量异常连接而启用' +antibot_auto_disabled: '[AuthMe] 防机器人程序由于异常连接减少而在 %m 分钟后停止' diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3f8f4db8..baa944d3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ author: Xephi59 website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player. main: fr.xephi.authme.AuthMe -version: 3.3.1 +version: 3.3.2-DEV-1 softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn] commands: register: