From bf99304cde835ff6bef931407e260cb2e7220228 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Sat, 30 May 2015 23:42:35 +0800 Subject: [PATCH] change auto update tip... --- .../residence/utils/VersionChecker.java | 118 +++++++++--------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/src/com/bekvon/bukkit/residence/utils/VersionChecker.java b/src/com/bekvon/bukkit/residence/utils/VersionChecker.java index 6c55b26..d1cac7d 100644 --- a/src/com/bekvon/bukkit/residence/utils/VersionChecker.java +++ b/src/com/bekvon/bukkit/residence/utils/VersionChecker.java @@ -1,57 +1,61 @@ -package com.bekvon.bukkit.residence.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; - -import com.bekvon.bukkit.residence.Residence; -import com.google.common.base.Charsets; - -public class VersionChecker { - Residence plugin; - - public VersionChecker(Residence plugin) { - this.plugin = plugin; - } - - public void VersionCheck(final Player player) { - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - @Override - public void run() { - String readURL = "http://ci.citycraft.cn:8800/jenkins/job/Residence-Fix/lastSuccessfulBuild/artifact/src/plugin.yml"; - FileConfiguration config; - String currentVersion = plugin.getDescription().getVersion(); - try { - URL url = new URL(readURL); - BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), - Charsets.UTF_8)); - config = YamlConfiguration.loadConfiguration(br); - String newVersion = config.getString("version"); - br.close(); - if (!newVersion.equals(currentVersion)) { - String[] msg = new String[] { - ChatColor.GREEN + "领地插件最新版本已更新到 v" + newVersion + "!", - ChatColor.RED + "服务器运行版本: " + currentVersion, - ChatColor.GOLD + "点击此链接下载最新版本: " + ChatColor.BLUE - + plugin.getDescription().getWebsite() }; - if (player != null) { - player.sendMessage(msg); - } else { - plugin.consoleMessage(msg); - } - } - } catch (IOException e) { - plugin.getLogger().warning("自动更新版本检查失败!"); - } - } - }); - } - -} +package com.bekvon.bukkit.residence.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; + +import com.bekvon.bukkit.residence.Residence; +import com.google.common.base.Charsets; + +public class VersionChecker { + Residence plugin; + + public VersionChecker(Residence plugin) { + this.plugin = plugin; + } + + public void VersionCheck(final Player player) { + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + String readURL = "http://ci.citycraft.cn:8800/jenkins/job/Residence-Fix/lastSuccessfulBuild/artifact/src/plugin.yml"; + FileConfiguration config; + String currentVersion = plugin.getDescription().getVersion(); + try { + URL url = new URL(readURL); + BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), + Charsets.UTF_8)); + config = YamlConfiguration.loadConfiguration(br); + String newVersion = config.getString("version"); + br.close(); + if (!newVersion.equals(currentVersion)) { + String[] msg = new String[] { + ChatColor.GREEN + "领地插件最新版本 v" + newVersion, + ChatColor.RED + "服务器运行版本: v" + currentVersion, + ChatColor.GOLD + "插件更新网站: " + ChatColor.BLUE + + plugin.getDescription().getWebsite(), + ChatColor.YELLOW + + "查看最新修改: " + + ChatColor.BLUE + + "http://ci.citycraft.cn:8800/jenkins/job/Residence-Fix/changes" }; + if (player != null) { + player.sendMessage(msg); + } else { + plugin.consoleMessage(msg); + } + } + } catch (IOException e) { + plugin.getLogger().warning("版本更新检查失败!"); + } + } + }); + } + +}