SelectProfileVariant class

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

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

extends: CommandBase

Поля (7)

МодификаторыТипИмя
private final RequiredArg<String> profileArg
ServerAuthManager var2
String var3
boolean var4
var4
var4
int var5

Методы (3)

МодификаторыВозвратСигнатура
protected void executeSyncprotected void executeSync(@Nonnull CommandContext var1)
if if(var4)
abstract super super("server.commands.auth.select.variant.desc")

Исходный код

Показать/скрыть
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.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
class="kw">import java.awt.Color;
class="kw">import javax.annotation.Nonnull;

class="kw">public class AuthSelectCommand class="kw">extends CommandBase {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_NO_PENDING = Message.translation("server.commands.auth.select.noPending").color(Color.YELLOW);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_SUCCESS = Message.translation("server.commands.auth.select.success").color(Color.GREEN);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_FAILED = Message.translation("server.commands.auth.select.failed").color(Color.RED);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_AVAILABLE_PROFILES = Message.translation("server.commands.auth.select.availableProfiles").color(Color.YELLOW);
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_USAGE = Message.translation("server.commands.auth.select.usage").color(Color.GRAY);

   class="kw">public AuthSelectCommand() {
      super("select", "server.commands.auth.select.desc");
      this.addUsageVariant(new AuthSelectCommand.SelectProfileVariant());
   }

   @Override
   class="kw">protected void executeSync(@Nonnull CommandContext var1) {
      ServerAuthManager var2 = ServerAuthManager.getInstance();
      if (!var2.hasPendingProfiles()) {
         var1.sendMessage(MESSAGE_NO_PENDING);
      } else {
         SessionServiceClient.GameProfile[] var3 = var2.getPendingProfiles();
         if (var3 != null) {
            var1.sendMessage(MESSAGE_AVAILABLE_PROFILES);
            sendProfileList(var1, var3);
            var1.sendMessage(MESSAGE_USAGE);
         }
      }
   }

   class="kw">static void sendProfileList(@Nonnull CommandContext var0, @Nonnull SessionServiceClient.GameProfile[] var1) {
      for (int var2 = 0; var2 < var1.length; var2++) {
         var0.sendMessage(
            Message.translation("server.commands.auth.select.profileItem")
               .param("index", var2 + 1)
               .param("username", var1[var2].username)
               .param("uuid", var1[var2].uuid.toString())
         );
      }
   }

   class="kw">private class="kw">static class SelectProfileVariant class="kw">extends CommandBase {
      @Nonnull
      class="kw">private class="kw">final RequiredArg<String> profileArg = this.withRequiredArg("profile", "server.commands.auth.select.profile.desc", ArgTypes.STRING);

      SelectProfileVariant() {
         super("server.commands.auth.select.variant.desc");
      }

      @Override
      class="kw">protected void executeSync(@Nonnull CommandContext var1) {
         ServerAuthManager var2 = ServerAuthManager.getInstance();
         if (!var2.hasPendingProfiles()) {
            var1.sendMessage(AuthSelectCommand.MESSAGE_NO_PENDING);
         } else {
            String var3 = this.profileArg.get(var1);

            boolean var4;
            try {
               int var5 = Integer.parseInt(var3);
               var4 = var2.selectPendingProfile(var5);
            } catch (NumberFormatException var6) {
               var4 = var2.selectPendingProfileByUsername(var3);
            }

            if (var4) {
               var1.sendMessage(AuthSelectCommand.MESSAGE_SUCCESS);
            } else {
               var1.sendMessage(AuthSelectCommand.MESSAGE_FAILED);
            }
         }
      }
   }
}