From dd3baee1b05faf9ce72b288701f94fa35751f46f Mon Sep 17 00:00:00 2001 From: j502647092 Date: Sat, 30 May 2015 23:22:37 +0800 Subject: [PATCH] add auto version check... Signed-off-by: j502647092 --- .../bekvon/bukkit/residence/Residence.java | 20 +++++++++++++++---- .../residence/ResidenceCommandListener.java | 15 +++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/com/bekvon/bukkit/residence/Residence.java b/src/com/bekvon/bukkit/residence/Residence.java index b6bc390..3079e43 100644 --- a/src/com/bekvon/bukkit/residence/Residence.java +++ b/src/com/bekvon/bukkit/residence/Residence.java @@ -23,7 +23,6 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -55,6 +54,7 @@ import com.bekvon.bukkit.residence.selection.WorldEditSelectionManager; import com.bekvon.bukkit.residence.text.Language; import com.bekvon.bukkit.residence.text.help.HelpEntry; import com.bekvon.bukkit.residence.text.help.InformationPager; +import com.bekvon.bukkit.residence.utils.VersionChecker; import com.bekvon.bukkit.residence.utils.ZipLibrary; import com.bekvon.bukkit.residence.vaultinterface.ResidenceVaultAdapter; import com.earth2me.essentials.Essentials; @@ -82,6 +82,7 @@ public class Residence extends JavaPlugin { protected static RentManager rentmanager; protected static ChatManager chatmanager; protected static Server server; + protected static VersionChecker versionChecker; protected static HelpEntry helppages; protected static Language language; protected static Logger log; @@ -187,6 +188,10 @@ public class Residence extends JavaPlugin { return tmanager; } + public static VersionChecker getVersionChecker() { + return versionChecker; + } + public static WorldFlagManager getWorldFlags() { return wmanager; } @@ -291,8 +296,13 @@ public class Residence extends JavaPlugin { } public void consoleMessage(String message) { - ConsoleCommandSender console = Bukkit.getConsoleSender(); - console.sendMessage("[Residence] " + message); + this.getLogger().info(message); + } + + public void consoleMessage(String[] msg) { + for (String s : msg) { + consoleMessage(s); + } } @Override @@ -579,9 +589,11 @@ public class Residence extends JavaPlugin { } catch (Exception ex) { initsuccess = false; getServer().getPluginManager().disablePlugin(this); - this.getLogger().warning(" - 初始化失败! 卸载插件! 请报告一下错误给作者,谢谢!"); + this.getLogger().warning(" - 初始化失败! 卸载插件! 请报告以下错误给作者,谢谢!"); this.getLogger().warning("错误: " + ex); } + versionChecker = new VersionChecker(this); + versionChecker.VersionCheck(null); } @Override diff --git a/src/com/bekvon/bukkit/residence/ResidenceCommandListener.java b/src/com/bekvon/bukkit/residence/ResidenceCommandListener.java index 5a6f614..bd8e3d2 100644 --- a/src/com/bekvon/bukkit/residence/ResidenceCommandListener.java +++ b/src/com/bekvon/bukkit/residence/ResidenceCommandListener.java @@ -52,8 +52,7 @@ public class ResidenceCommandListener extends Residence { } @SuppressWarnings("deprecation") - private boolean commandRes(String[] args, boolean resadmin, Command command, - CommandSender sender) { + private boolean commandRes(String[] args, boolean resadmin, Command command, CommandSender sender) { if (args.length > 0 && args[args.length - 1].equalsIgnoreCase("?") || args.length > 1 && args[args.length - 2].equals("?")) return commandHelp(args, resadmin, sender); @@ -111,8 +110,7 @@ public class ResidenceCommandListener extends Residence { sender.sendMessage(ChatColor.DARK_AQUA + "插件命令列表,帮助, 请查看wiki:"); sender.sendMessage(ChatColor.GREEN + "http://residencebukkitmod.wikispaces.com/"); sender.sendMessage(ChatColor.AQUA + "重制版本请查看Jenkins:"); - sender.sendMessage(ChatColor.BLUE - + "http://ci.citycraft.cn:8800/jenkins/job/Residence-Fix/"); + sender.sendMessage(ChatColor.BLUE + this.getDescription().getWebsite()); sender.sendMessage(ChatColor.GRAY + "------------------------------------"); return true; } @@ -629,8 +627,7 @@ public class ResidenceCommandListener extends Residence { return true; } - private boolean commandResConfirm(String[] args, boolean resadmin, CommandSender sender, - int page) { + private boolean commandResConfirm(String[] args, boolean resadmin, CommandSender sender, int page) { Player player = null; String name = "Console"; if (sender instanceof Player) { @@ -932,8 +929,7 @@ public class ResidenceCommandListener extends Residence { return false; } - private boolean commandResMarketAutorenew(String[] args, boolean resadmin, Player player, - int page) { + private boolean commandResMarketAutorenew(String[] args, boolean resadmin, Player player, int page) { if (!cmanager.enableEconomy()) { player.sendMessage(ChatColor.RED + language.getPhrase("MarketDisabled")); return true; @@ -991,8 +987,7 @@ public class ResidenceCommandListener extends Residence { return true; } - private boolean commandResMarketRentable(String[] args, boolean resadmin, Player player, - int page) { + private boolean commandResMarketRentable(String[] args, boolean resadmin, Player player, int page) { if (args.length < 5 || args.length > 6) return false; if (!cmanager.enabledRentSystem()) {