AuthLoginDeviceCommand class

Пакет: com.hypixel.hytale.server.core.command.commands.server.auth

Файл: com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginDeviceCommand.java

extends: CommandBase

Поля (4)

МодификаторыТипИмя
break
break
ServerAuthManager var2
SessionServiceClient.GameProfile[] var3

Методы (6)

МодификаторыВозвратСигнатура
private AuthFlowprivate AuthFlow()
if if(var3 != null)
if if(var3 != null)
public void onFlowInfopublic void onFlowInfo(String var1, String var2, String var3, int var4)
abstract super super("device", "server.commands.auth.login.device.desc")
switch switch(var2x)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.command.commands.server.auth;

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.auth.SessionServiceClient;
class="kw">import com.hypixel.hytale.server.core.auth.oauth.OAuthDeviceFlow;
class="kw">import com.hypixel.hytale.server.core.command.system.AbstractCommand;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
class="kw">import java.awt.Color;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;

class="kw">public class AuthLoginDeviceCommand class="kw">extends CommandBase {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_SINGLEPLAYER = Message.translation("server.commands.auth.login.singleplayer").color(Color.RED);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_ALREADY_AUTHENTICATED = Message.translation("server.commands.auth.login.alreadyAuthenticated").color(Color.YELLOW);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_STARTING = Message.translation("server.commands.auth.login.device.starting").color(Color.YELLOW);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_SUCCESS = Message.translation("server.commands.auth.login.device.success").color(Color.GREEN);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_FAILED = Message.translation("server.commands.auth.login.device.failed").color(Color.RED);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_PENDING = Message.translation("server.commands.auth.login.pending").color(Color.YELLOW);

   class="kw">public AuthLoginDeviceCommand() {
      super("device", "server.commands.auth.login.device.desc");
   }

   @Override
   class="kw">protected void executeSync(@Nonnull CommandContext var1) {
      ServerAuthManager var2 = ServerAuthManager.getInstance();
      if (var2.isSingleplayer()) {
         var1.sendMessage(MESSAGE_SINGLEPLAYER);
      } else if (var2.hasSessionToken() && var2.hasIdentityToken()) {
         var1.sendMessage(MESSAGE_ALREADY_AUTHENTICATED);
      } else {
         var1.sendMessage(MESSAGE_STARTING);
         var2.startFlowAsync(new AuthLoginDeviceCommand.AuthFlow()).thenAccept(var2x -> {
            class="kw">switch (var2x) {
               case SUCCESS:
                  var1.sendMessage(MESSAGE_SUCCESS);
                  AuthLoginBrowserCommand.sendPersistenceFeedback(var1);
                  break;
               case PENDING_PROFILE_SELECTION:
                  var1.sendMessage(MESSAGE_PENDING);
                  SessionServiceClient.GameProfile[] var3 = var2.getPendingProfiles();
                  if (var3 != null) {
                     AuthSelectCommand.sendProfileList(var1, var3);
                  }
                  break;
               case FAILED:
                  var1.sendMessage(MESSAGE_FAILED);
            }
         });
      }
   }

   class="kw">private class="kw">static class AuthFlow class="kw">extends OAuthDeviceFlow {
      class="kw">private AuthFlow() {
      }

      @Override
      class="kw">public void onFlowInfo(String var1, String var2, String var3, int var4) {
         AbstractCommand.LOGGER.at(Level.INFO).log("===================================================================");
         AbstractCommand.LOGGER.at(Level.INFO).log("DEVICE AUTHORIZATION");
         AbstractCommand.LOGGER.at(Level.INFO).log("===================================================================");
         AbstractCommand.LOGGER.at(Level.INFO).log("Visit: %s", var2);
         AbstractCommand.LOGGER.at(Level.INFO).log("Enter code: %s", var1);
         if (var3 != null) {
            AbstractCommand.LOGGER.at(Level.INFO).log("Or visit: %s", var3);
         }

         AbstractCommand.LOGGER.at(Level.INFO).log("===================================================================");
         AbstractCommand.LOGGER.at(Level.INFO).log("Waiting for authorization (expires in %d seconds)...", var4);
      }
   }
}