Fix NPE when failed check update

Former-commit-id: da4873714b107eb409b86393763e1fdeb4950800 [formerly cd82b1280e14dafb384c35ff9bd79154006efafd]
Former-commit-id: 7e16e2d7b8147af70fe63ecdc4aaff90a71de78e
This commit is contained in:
Ghost_chu committed 2019-07-14 20:31:58 +08:00
1 parent f3db01eb1a
commit 93dc34980d
2 files changed
+21 -13

No files matched your search

@@ -9,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.*;
import org.maxgamer.quickshop.Command.CommandProcesser;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Util.UpdateInfomation;
import org.maxgamer.quickshop.Util.Updater;
public class SubCommand_Update implements CommandProcesser {
@@ -20,7 +21,13 @@ public class SubCommand_Update implements CommandProcesser {
@Override
public void run() {
sender.sendMessage(ChatColor.YELLOW + "Checking for updates...");
if (Updater.checkUpdate().getVersion().equals(plugin.getDescription().getVersion())) {
UpdateInfomation updateInfomation = Updater.checkUpdate();
String updateVersion = updateInfomation.getVersion();
if (updateVersion == null) {
sender.sendMessage(ChatColor.RED + "Failed check the update, connection issue?");
return;
}
if (updateVersion.equals(plugin.getDescription().getVersion())) {
sender.sendMessage(ChatColor.GREEN + "No updates can update now.");
return;
}
@@ -1,12 +1,13 @@
package org.maxgamer.quickshop.Util;
import lombok.*;
@AllArgsConstructor
@ToString
@Getter
@Setter
public class UpdateInfomation {
private String version;
private boolean isBeta;
}
package org.maxgamer.quickshop.Util;
import lombok.*;
import org.jetbrains.annotations.*;
@AllArgsConstructor
@ToString
@Getter
@Setter
public class UpdateInfomation {
@Nullable private String version;
private boolean isBeta;
}