Finish update system
This commit is contained in:
parent
b247a49a23
commit
7090ea51cc
@ -135,7 +135,23 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (origArgs.length <= 1) {
|
||||||
tabs.addAll(command.getTabComplete());
|
tabs.addAll(command.getTabComplete());
|
||||||
|
} else {
|
||||||
|
for (String s : command.getTabComplete()) {
|
||||||
|
if (!s.contains(" ")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] split = s.split(" ");
|
||||||
|
|
||||||
|
if (!args[0].equalsIgnoreCase(split[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tabs.add(split[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterTabs(tabs, origArgs);
|
return filterTabs(tabs, origArgs);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package me.libraryaddict.disguise.commands.libsdisguises;
|
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.updates.UpdateChecker;
|
import me.libraryaddict.disguise.utilities.updates.UpdateChecker;
|
||||||
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
|
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -22,7 +23,7 @@ public class LDUpdate implements LDCommand {
|
|||||||
// Update by download
|
// Update by download
|
||||||
// Update check
|
// Update check
|
||||||
// Update to latest dev build
|
// Update to latest dev build
|
||||||
return Arrays.asList("update", "update?", "update!");
|
return Arrays.asList("update", "update dev", "update release", "changelog", "update!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -30,6 +31,25 @@ public class LDUpdate implements LDCommand {
|
|||||||
return "libsdisguises.update";
|
return "libsdisguises.update";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doChangelog(CommandSender sender) {
|
||||||
|
UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker();
|
||||||
|
|
||||||
|
if (checker.getUpdate() == null) {
|
||||||
|
sender.sendMessage(LibsMsg.UPDATE_REQUIRED.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checker.getUpdate().isReleaseBuild()) {
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") +
|
||||||
|
LibsDisguises.getInstance().getBuildNo());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String msg : checker.getUpdate().getChangelog()) {
|
||||||
|
sender.sendMessage(ChatColor.GOLD + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker();
|
UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker();
|
||||||
@ -39,20 +59,33 @@ public class LDUpdate implements LDCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean check = args[0].endsWith("?");
|
if (args[0].equalsIgnoreCase("changelog")) {
|
||||||
boolean force = args[0].endsWith("!");
|
doChangelog(sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!check && !force && checker.getUpdate() != null) {
|
boolean releaseBuilds = checker.isUsingReleaseBuilds();
|
||||||
if (checker.getUpdate().getVersion().equals(checker.getUpdate().isReleaseBuild() ?
|
|
||||||
LibsDisguises.getInstance().getDescription().getDescription() :
|
if (args.length > 1) {
|
||||||
LibsDisguises.getInstance().getBuildNumber())) {
|
if (args[1].equalsIgnoreCase("dev")) {
|
||||||
|
releaseBuilds = false;
|
||||||
|
} else if (args[1].equalsIgnoreCase("release")) {
|
||||||
|
releaseBuilds = true;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(LibsMsg.LIBS_UPDATE_UNKNOWN_BRANCH.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisguiseConfig.setUsingReleaseBuilds(releaseBuilds);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checker.getUpdate() != null && checker.getUpdate().isReleaseBuild() == releaseBuilds) {
|
||||||
|
if (checker.isServerLatestVersion()) {
|
||||||
sender.sendMessage(LibsMsg.UPDATE_ON_LATEST.get());
|
sender.sendMessage(LibsMsg.UPDATE_ON_LATEST.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checker.getLastDownload() != null && checker.getUpdate().getVersion()
|
if (checker.isOnLatestUpdate(true)) {
|
||||||
.equals(checker.isUsingReleaseBuilds() ? checker.getLastDownload().getVersion() :
|
|
||||||
checker.getLastDownload().getBuildNumber())) {
|
|
||||||
sender.sendMessage(LibsMsg.UPDATE_ALREADY_DOWNLOADED.get());
|
sender.sendMessage(LibsMsg.UPDATE_ALREADY_DOWNLOADED.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -63,7 +96,7 @@ public class LDUpdate implements LDCommand {
|
|||||||
public void run() {
|
public void run() {
|
||||||
LibsMsg updateResult = null;
|
LibsMsg updateResult = null;
|
||||||
|
|
||||||
if (check || checker.getUpdate() == null || force) {
|
if (checker.getUpdate() == null || args.length > 1 || checker.isOldUpdate()) {
|
||||||
updateResult = checker.doUpdateCheck();
|
updateResult = checker.doUpdateCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,12 +105,17 @@ public class LDUpdate implements LDCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checker.isUpdateReady()) {
|
if (checker.isOnLatestUpdate(true)) {
|
||||||
|
if (checker.getLastDownload() != null) {
|
||||||
|
sender.sendMessage(LibsMsg.UPDATE_ALREADY_DOWNLOADED.get());
|
||||||
|
} else {
|
||||||
sender.sendMessage(LibsMsg.UPDATE_ON_LATEST.get());
|
sender.sendMessage(LibsMsg.UPDATE_ON_LATEST.get());
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check) {
|
if (!args[0].endsWith("!")) {
|
||||||
if (updateResult != null) {
|
if (updateResult != null) {
|
||||||
sender.sendMessage(updateResult.get());
|
sender.sendMessage(updateResult.get());
|
||||||
} else {
|
} else {
|
||||||
|
@ -121,8 +121,9 @@ public enum LibsMsg {
|
|||||||
PLEASE_WAIT(ChatColor.GRAY + "Please wait..."),
|
PLEASE_WAIT(ChatColor.GRAY + "Please wait..."),
|
||||||
INVALID_CLONE(ChatColor.DARK_RED + "Unknown method '%s' - Valid methods are 'IgnoreEquipment' 'DoSneakSprint' " +
|
INVALID_CLONE(ChatColor.DARK_RED + "Unknown method '%s' - Valid methods are 'IgnoreEquipment' 'DoSneakSprint' " +
|
||||||
"'DoSneak' 'DoSprint'"),
|
"'DoSneak' 'DoSprint'"),
|
||||||
LIBS_COMMAND_WRONG_ARG(
|
LIBS_COMMAND_WRONG_ARG(ChatColor.RED + "[LibsDisguises] Invalid argument, use /libsdisguises help"),
|
||||||
ChatColor.RED + "[LibsDisguises] Did you mean 'reload', 'scoreboard', 'permtest', 'json' or 'metainfo'?"),
|
LIBS_UPDATE_UNKNOWN_BRANCH(
|
||||||
|
ChatColor.RED + "[LibsDisguises] Invalid argument, use 'dev' or 'release' to switch branches"),
|
||||||
LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"),
|
LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"),
|
||||||
LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"),
|
LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"),
|
||||||
LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise %s as a %s!"),
|
LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise %s as a %s!"),
|
||||||
@ -147,6 +148,7 @@ public enum LibsMsg {
|
|||||||
UPDATE_ALREADY_DOWNLOADED(ChatColor.RED + "That update has already been downloaded!"),
|
UPDATE_ALREADY_DOWNLOADED(ChatColor.RED + "That update has already been downloaded!"),
|
||||||
UPDATE_FAILED(ChatColor.RED + "LibsDisguises update failed! Check console for errors."),
|
UPDATE_FAILED(ChatColor.RED + "LibsDisguises update failed! Check console for errors."),
|
||||||
UPDATE_SUCCESS(ChatColor.DARK_GREEN + "LibsDisguises update success! Restart server to update!"),
|
UPDATE_SUCCESS(ChatColor.DARK_GREEN + "LibsDisguises update success! Restart server to update!"),
|
||||||
|
UPDATE_REQUIRED(ChatColor.RED + "LibsDisguises requies an update check before it can give you that!"),
|
||||||
UPDATE_INFO(ChatColor.DARK_GREEN + "Lib's Disguises v%s, build %s, built %s and size %skb"),
|
UPDATE_INFO(ChatColor.DARK_GREEN + "Lib's Disguises v%s, build %s, built %s and size %skb"),
|
||||||
UPDATE_IN_PROGRESS(ChatColor.DARK_GREEN + "LibsDisguises is now downloading an update..."),
|
UPDATE_IN_PROGRESS(ChatColor.DARK_GREEN + "LibsDisguises is now downloading an update..."),
|
||||||
NO_PERM_DISGUISE(ChatColor.RED + "You do not have permission for that disguise!"),
|
NO_PERM_DISGUISE(ChatColor.RED + "You do not have permission for that disguise!"),
|
||||||
@ -196,12 +198,13 @@ public enum LibsMsg {
|
|||||||
UNDISRADIUS(ChatColor.RED + "Successfully undisguised %s entities!"),
|
UNDISRADIUS(ChatColor.RED + "Successfully undisguised %s entities!"),
|
||||||
UPDATE_READY(ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED +
|
UPDATE_READY(ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED +
|
||||||
"There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED +
|
"There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED +
|
||||||
", the new version is " + ChatColor.RED + "v%s" + ChatColor.DARK_RED +
|
", the new version is " + ChatColor.RED + "v%s" + ChatColor.DARK_RED + "!"),
|
||||||
"! Use /libsdisguises update to automatically update!"),
|
|
||||||
UPDATE_READY_SNAPSHOT(ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED +
|
UPDATE_READY_SNAPSHOT(ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED +
|
||||||
"There is a new build of Lib's Disguises! You are using " + ChatColor.RED + "#%s" + ChatColor.DARK_RED +
|
"There is a new build of Lib's Disguises! You are using " + ChatColor.RED + "%s" + ChatColor.DARK_RED +
|
||||||
", the latest build is " + ChatColor.RED + "#%s" + ChatColor.DARK_RED + "!" + ChatColor.RED +
|
", the latest build is " + ChatColor.RED + "#%s" + ChatColor.DARK_RED + "!"),
|
||||||
"\nhttps://ci.md-5.net/job/LibsDisguises/lastSuccessfulBuild/ or use /libsdisguises update"),
|
UPDATE_HOW(ChatColor.DARK_AQUA + "Use " + ChatColor.AQUA + "/libsdisgusies changelog" + ChatColor.DARK_AQUA +
|
||||||
|
" to see what changed, use " + ChatColor.AQUA + "/libsdisguises update!" + ChatColor.DARK_AQUA +
|
||||||
|
" to download the update!"),
|
||||||
VIEW_SELF_ON(ChatColor.GREEN + "Toggled viewing own disguise on!"),
|
VIEW_SELF_ON(ChatColor.GREEN + "Toggled viewing own disguise on!"),
|
||||||
VIEW_SELF_OFF(ChatColor.GREEN + "Toggled viewing own disguise off!"),
|
VIEW_SELF_OFF(ChatColor.GREEN + "Toggled viewing own disguise off!"),
|
||||||
CLICK_TO_COPY(ChatColor.GREEN + "Click to Copy:"),
|
CLICK_TO_COPY(ChatColor.GREEN + "Click to Copy:"),
|
||||||
|
@ -50,6 +50,7 @@ public class LDGithub {
|
|||||||
|
|
||||||
public DisguiseUpdate getLatestRelease() {
|
public DisguiseUpdate getLatestRelease() {
|
||||||
try {
|
try {
|
||||||
|
DisguiseUtilities.getLogger().info("Now looking for update on Github..");
|
||||||
// We're connecting to md_5's jenkins REST api
|
// We're connecting to md_5's jenkins REST api
|
||||||
URL url = new URL("https://api.github.com/repos/libraryaddict/LibsDisguises/releases/latest");
|
URL url = new URL("https://api.github.com/repos/libraryaddict/LibsDisguises/releases/latest");
|
||||||
// Creating a connection
|
// Creating a connection
|
||||||
|
@ -3,9 +3,8 @@ package me.libraryaddict.disguise.utilities.updates;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.plugin.PluginInformation;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -14,8 +13,8 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -48,8 +47,9 @@ public class LDJenkins {
|
|||||||
*/
|
*/
|
||||||
private Map<String, Object> fetchLastSnapshotBuild() {
|
private Map<String, Object> fetchLastSnapshotBuild() {
|
||||||
try {
|
try {
|
||||||
|
DisguiseUtilities.getLogger().info("Now looking for update on Jenkins..");
|
||||||
// We're connecting to md_5's jenkins REST api
|
// We're connecting to md_5's jenkins REST api
|
||||||
URL url = new URL("https://ci.md-5.net/job/LibsDisguises/lastSuccessfulBuild/api/json");
|
URL url = new URL("https://ci.md-5.net/job/LibsDisguises/api/json?tree=builds[changeSet[items[msg]],id,result]");
|
||||||
// Creating a connection
|
// Creating a connection
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
con.setDefaultUseCaches(false);
|
con.setDefaultUseCaches(false);
|
||||||
@ -77,28 +77,50 @@ public class LDJenkins {
|
|||||||
public DisguiseUpdate getLatestSnapshot() {
|
public DisguiseUpdate getLatestSnapshot() {
|
||||||
Map<String, Object> lastBuild = fetchLastSnapshotBuild();
|
Map<String, Object> lastBuild = fetchLastSnapshotBuild();
|
||||||
|
|
||||||
if (lastBuild == null || !lastBuild.containsKey("id") || !lastBuild.containsKey("timestamp")) {
|
if (lastBuild == null || !lastBuild.containsKey("builds")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> changelog = new ArrayList<>();
|
ArrayList<String> changelog = new ArrayList<>();
|
||||||
|
String version = null;
|
||||||
|
|
||||||
if (lastBuild.get("changeSet") instanceof Map) {
|
for (Map map : (List<Map>) lastBuild.get("builds")) {
|
||||||
Object items = ((Map) lastBuild.get("changeSet")).get("items");
|
String result = (String) map.get("result");
|
||||||
|
|
||||||
if (items instanceof Map[]) {
|
if (!"SUCCESS".equalsIgnoreCase(result)) {
|
||||||
for (Map item : (Map[]) items) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changelog.isEmpty()) {
|
||||||
|
version = (String) map.get("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
Object items = ((Map) map.get("changeSet")).get("items");
|
||||||
|
boolean release = false;
|
||||||
|
|
||||||
|
if (items instanceof List) {
|
||||||
|
for (Map item : (List<Map>) items) {
|
||||||
String msg = (String) item.get("msg");
|
String msg = (String) item.get("msg");
|
||||||
|
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
changelog.add(msg);
|
changelog.add("#" + map.get("id") + ": " + ChatColor.YELLOW + msg);
|
||||||
}
|
|
||||||
|
release = release || msg.toLowerCase().matches("release.? .*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JenkinsUpdate((String) lastBuild.get("id"), changelog.toArray(new String[0]));
|
if (release) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changelog.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JenkinsUpdate(version, changelog.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.libs.org.apache.commons.io.FileUtils;
|
import org.bukkit.craftbukkit.libs.org.apache.commons.io.FileUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -42,10 +41,51 @@ public class UpdateChecker {
|
|||||||
this.resourceID = resourceID;
|
this.resourceID = resourceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isServerLatestVersion() {
|
||||||
|
return isOnLatestUpdate(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnLatestUpdate(boolean includeDownloaded) {
|
||||||
|
if (getUpdate() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isRelease =
|
||||||
|
includeDownloaded && getLastDownload() != null ? !getLastDownload().getVersion().contains("-SNAPSHOT") :
|
||||||
|
LibsDisguises.getInstance().isReleaseBuild();
|
||||||
|
|
||||||
|
if (getUpdate().isReleaseBuild() != isRelease) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String version;
|
||||||
|
|
||||||
|
if (getUpdate().isReleaseBuild()) {
|
||||||
|
if (lastDownload != null && includeDownloaded) {
|
||||||
|
version = lastDownload.getVersion();
|
||||||
|
} else {
|
||||||
|
version = LibsDisguises.getInstance().getDescription().getVersion();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (lastDownload != null && includeDownloaded) {
|
||||||
|
version = lastDownload.getBuildNumber();
|
||||||
|
} else {
|
||||||
|
version = LibsDisguises.getInstance().getBuildNo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getUpdate() != null && getUpdate().getVersion().equals(version);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDownloading() {
|
public boolean isDownloading() {
|
||||||
return downloading.get();
|
return downloading.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOldUpdate() {
|
||||||
|
return getUpdate() == null ||
|
||||||
|
getUpdate().getFetched().before(new Date(System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1)));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUsingReleaseBuilds() {
|
public boolean isUsingReleaseBuilds() {
|
||||||
DisguiseConfig.UpdatesBranch builds = DisguiseConfig.getUpdatesBranch();
|
DisguiseConfig.UpdatesBranch builds = DisguiseConfig.getUpdatesBranch();
|
||||||
|
|
||||||
@ -71,30 +111,6 @@ public class UpdateChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdateReady() {
|
|
||||||
if (getUpdate() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String version;
|
|
||||||
|
|
||||||
if (getUpdate().isReleaseBuild()) {
|
|
||||||
if (lastDownload != null) {
|
|
||||||
version = lastDownload.getVersion();
|
|
||||||
} else {
|
|
||||||
version = LibsDisguises.getInstance().getDescription().getVersion();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (lastDownload != null) {
|
|
||||||
version = lastDownload.getBuildNumber();
|
|
||||||
} else {
|
|
||||||
version = LibsDisguises.getInstance().getBuildNo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return getUpdate() != null && !getUpdate().getVersion().equals(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doAutoUpdateCheck() {
|
public void doAutoUpdateCheck() {
|
||||||
try {
|
try {
|
||||||
DisguiseUpdate oldUpdate = getUpdate();
|
DisguiseUpdate oldUpdate = getUpdate();
|
||||||
@ -103,7 +119,8 @@ public class UpdateChecker {
|
|||||||
|
|
||||||
doUpdateCheck();
|
doUpdateCheck();
|
||||||
|
|
||||||
if (!isUpdateReady() || (oldUpdate != null && oldUpdate.getVersion().equals(getUpdate().getVersion()))) {
|
if (isOnLatestUpdate(true) ||
|
||||||
|
(oldUpdate != null && oldUpdate.getVersion().equals(getUpdate().getVersion()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,11 +181,13 @@ public class UpdateChecker {
|
|||||||
if (getUpdate().isReleaseBuild()) {
|
if (getUpdate().isReleaseBuild()) {
|
||||||
String currentVersion = LibsDisguises.getInstance().getDescription().getVersion();
|
String currentVersion = LibsDisguises.getInstance().getDescription().getVersion();
|
||||||
|
|
||||||
if (!isNewerVersion(currentVersion, getUpdate().getVersion())) {
|
if (LibsDisguises.getInstance().isReleaseBuild() &&
|
||||||
|
!isNewerVersion(currentVersion, getUpdate().getVersion())) {
|
||||||
return LibsMsg.UPDATE_ON_LATEST;
|
return LibsMsg.UPDATE_ON_LATEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMessage = new String[]{LibsMsg.UPDATE_READY.get(currentVersion, getUpdate().getVersion())};
|
updateMessage = new String[]{LibsMsg.UPDATE_READY.get(currentVersion, getUpdate().getVersion()),
|
||||||
|
LibsMsg.UPDATE_HOW.get()};
|
||||||
} else {
|
} else {
|
||||||
if (!getUpdate().getVersion().matches("[0-9]+")) {
|
if (!getUpdate().getVersion().matches("[0-9]+")) {
|
||||||
return LibsMsg.UPDATE_FAILED;
|
return LibsMsg.UPDATE_FAILED;
|
||||||
@ -180,8 +199,11 @@ public class UpdateChecker {
|
|||||||
return LibsMsg.UPDATE_ON_LATEST;
|
return LibsMsg.UPDATE_ON_LATEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String build = LibsDisguises.getInstance().getBuildNo();
|
||||||
|
|
||||||
updateMessage = new String[]{
|
updateMessage = new String[]{
|
||||||
LibsMsg.UPDATE_READY_SNAPSHOT.get(LibsDisguises.getInstance().getBuildNo(), newBuild)};
|
LibsMsg.UPDATE_READY_SNAPSHOT.get((build.matches("[0-9]+") ? "#" : "") + build, newBuild),
|
||||||
|
LibsMsg.UPDATE_HOW.get()};
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user