UpdateCheckCommand class
Пакет: com.hypixel.hytale.server.core.update.command
Файл: com/hypixel/hytale/server/core/update/command/UpdateCheckCommand.java
extends: AbstractAsyncCommand
Поля (5)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
Message |
MSG_CHECKING |
|
ServerAuthManager |
var2 |
|
UpdateModule |
var2 |
|
UpdateService |
var3 |
|
String |
var3 |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(var1x == null) |
|
|
if if(var2 != null) |
abstract |
|
super super("check", "server.commands.update.check.desc") |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.update.command;
class="kw">import com.hypixel.hytale.common.util.java.ManifestUtil;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.auth.ServerAuthManager;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand;
class="kw">import com.hypixel.hytale.server.core.update.UpdateModule;
class="kw">import com.hypixel.hytale.server.core.update.UpdateService;
class="kw">import java.util.concurrent.CompletableFuture;
class="kw">import javax.annotation.Nonnull;
class="kw">public class UpdateCheckCommand class="kw">extends AbstractAsyncCommand {
class="kw">private class="kw">static class="kw">final Message MSG_CHECKING = Message.translation("server.commands.update.checking");
class="kw">private class="kw">static class="kw">final Message MSG_NOT_AUTHENTICATED = Message.translation("server.commands.update.not_authenticated");
class="kw">private class="kw">static class="kw">final Message MSG_CHECK_FAILED = Message.translation("server.commands.update.check_failed");
class="kw">public UpdateCheckCommand() {
super("check", "server.commands.update.check.desc");
}
@Nonnull
@Override
class="kw">protected CompletableFuture<Void> executeAsync(@Nonnull CommandContext var1) {
ServerAuthManager var2 = ServerAuthManager.getInstance();
if (!var2.hasSessionToken()) {
var1.sendMessage(MSG_NOT_AUTHENTICATED);
class="kw">return CompletableFuture.completedFuture(null);
} else {
var1.sendMessage(MSG_CHECKING);
UpdateService var3 = new UpdateService();
class="kw">return var3.checkForUpdate(UpdateService.getEffectivePatchline())
.thenAccept(
var1x -> {
if (var1x == null) {
var1.sendMessage(MSG_CHECK_FAILED);
} else {
UpdateModule var2 = UpdateModule.get();
if (var2 != null) {
var2.setLatestKnownVersion(var1x);
}
String var3 = ManifestUtil.getImplementationVersion();
if (var3 != null && var3.equals(var1x.version)) {
var1.sendMessage(Message.translation("server.commands.update.already_latest").param("version", var3));
} else {
var1.sendMessage(
Message.translation("server.commands.update.update_available")
.param("current", var3 != null ? Message.raw(var3) : Message.translation("server.commands.update.unknown"))
.param("latest", var1x.version)
);
}
}
}
);
}
}
}