NPCDebugCommand class

Пакет: com.hypixel.hytale.server.npc.commands

Файл: com/hypixel/hytale/server/npc/commands/NPCDebugCommand.java

extends: AbstractCommandCollection

Поля (17)

МодификаторыТипИмя
private final RequiredArg<String> flagsArg
private final RequiredArg<String> flagsArg
private final OptionalArg<String> presetArg
String var2
EnumSet var2
String var3
String var3
Message var4
String var5
EnumSet var6
EnumSet var6
String var6
String var6
String var6
String var7
EnumSet var7
EnumSet var7

Методы (26)

МодификаторыВозвратСигнатура
public ClearCommandpublic ClearCommand()
public DefaultsCommandpublic DefaultsCommand()
public PresetsCommandpublic PresetsCommand()
public SetCommandpublic SetCommand()
public ShowCommandpublic ShowCommand()
public ToggleCommandpublic ToggleCommand()
protected void executeprotected void execute(@Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5)
protected void executeprotected void execute(@Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5)
protected CompletableFuture<Void> executeprotected CompletableFuture<Void> execute(@Nonnull CommandContext var1)
protected void executeprotected void execute(@Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5)
protected void executeprotected void execute(@Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5)
protected void executeprotected void execute(@Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5)
for for(RoleDebugFlags var4 : var1x)
if if(var6 != null)
static void modifyFlagsvoid modifyFlags(@Nonnull CommandContext var0, @Nonnull NPCEntity var1, @Nonnull Ref<EntityStore> var2, @Nonnull EnumSet<RoleDebugFlags> var3, @Nonnull BiFunction<EnumSet<RoleDebugFlags>, EnumSet<RoleDebugFlags>, EnumSet<RoleDebugFlags>> var4, @Nonnull Store<EntityStore> var5)
static void printNewFlagsvoid printNewFlags(@Nonnull NPCEntity var0, @Nonnull CommandContext var1, @Nonnull EnumSet<RoleDebugFlags> var2)
abstract printNewFlags printNewFlags(var1, var0, var6)
static void safeSetRoleDebugFlagsvoid safeSetRoleDebugFlags(@Nonnull NPCEntity var0, @Nonnull Ref<EntityStore> var1, @Nonnull EnumSet<RoleDebugFlags> var2, @Nonnull Store<EntityStore> var3)
abstract safeSetRoleDebugFlags safeSetRoleDebugFlags(var1, var2, var6, var5)
abstract super super("debug", "server.commands.npc.debug.desc")
abstract super super("clear", "server.commands.npc.debug.clear.desc")
abstract super super("defaults", "server.commands.npc.debug.defaults.desc")
abstract super super("presets", "server.commands.npc.debug.presets.desc")
abstract super super("set", "server.commands.npc.debug.set.desc")
abstract super super("show", "server.commands.npc.debug.show.desc")
abstract super super("toggle", "server.commands.npc.debug.toggle.desc")

Исходный код

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

class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.Message;
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.arguments.system.OptionalArg;
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.AbstractCommandCollection;
class="kw">import com.hypixel.hytale.server.core.entity.nameplate.Nameplate;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.entities.NPCEntity;
class="kw">import com.hypixel.hytale.server.npc.role.RoleDebugFlags;
class="kw">import java.util.EnumSet;
class="kw">import java.util.concurrent.CompletableFuture;
class="kw">import java.util.function.BiFunction;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class NPCDebugCommand class="kw">extends AbstractCommandCollection {
   class="kw">public NPCDebugCommand() {
      super("debug", "server.commands.npc.debug.desc");
      this.addSubCommand(new NPCDebugCommand.ShowCommand());
      this.addSubCommand(new NPCDebugCommand.SetCommand());
      this.addSubCommand(new NPCDebugCommand.ToggleCommand());
      this.addSubCommand(new NPCDebugCommand.DefaultsCommand());
      this.addSubCommand(new NPCDebugCommand.ClearCommand());
      this.addSubCommand(new NPCDebugCommand.PresetsCommand());
   }

   class="kw">private class="kw">static void modifyFlags(
      @Nonnull CommandContext var0,
      @Nonnull NPCEntity var1,
      @Nonnull Ref<EntityStore> var2,
      @Nonnull EnumSet<RoleDebugFlags> var3,
      @Nonnull BiFunction<EnumSet<RoleDebugFlags>, EnumSet<RoleDebugFlags>, EnumSet<RoleDebugFlags>> var4,
      @Nonnull Store<EntityStore> var5
   ) {
      EnumSet var6 = var4.apply(var1.getRoleDebugFlags(), var3);
      if (var6 != null) {
         safeSetRoleDebugFlags(var1, var2, var6, var5);
         printNewFlags(var1, var0, var6);
      }
   }

   class="kw">private class="kw">static void safeSetRoleDebugFlags(
      @Nonnull NPCEntity var0, @Nonnull Ref<EntityStore> var1, @Nonnull EnumSet<RoleDebugFlags> var2, @Nonnull Store<EntityStore> var3
   ) {
      var3.tryRemoveComponent(var1, Nameplate.getComponentType());
      var0.setRoleDebugFlags(var2);
   }

   class="kw">private class="kw">static void printNewFlags(@Nonnull NPCEntity var0, @Nonnull CommandContext var1, @Nonnull EnumSet<RoleDebugFlags> var2) {
      String var3 = getListOfFlags(var2).toString();
      var1.sendMessage(
         Message.translation("server.commands.npc.debug.debugFlagsSet").param("role", var0.getRoleName()).param("flags", !var3.isEmpty() ? var3 : "<None>")
      );
   }

   @Nonnull
   class="kw">private class="kw">static StringBuilder getListOfFlags(@Nonnull EnumSet<RoleDebugFlags> var0) {
      class="kw">return RoleDebugFlags.getListOfFlags(var0, new StringBuilder());
   }

   class="kw">public class="kw">static class ClearCommand class="kw">extends NPCMultiSelectCommandBase {
      class="kw">public ClearCommand() {
         super("clear", "server.commands.npc.debug.clear.desc");
      }

      @Override
      class="kw">protected void execute(
         @Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5
      ) {
         NPCDebugCommand.safeSetRoleDebugFlags(var2, var5, EnumSet.noneOf(RoleDebugFlags.class), var4);
      }
   }

   class="kw">public class="kw">static class DefaultsCommand class="kw">extends NPCMultiSelectCommandBase {
      class="kw">public DefaultsCommand() {
         super("defaults", "server.commands.npc.debug.defaults.desc");
      }

      @Override
      class="kw">protected void execute(
         @Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5
      ) {
         NPCDebugCommand.safeSetRoleDebugFlags(var2, var5, RoleDebugFlags.getPreset("class="kw">default"), var4);
      }
   }

   class="kw">public class="kw">static class PresetsCommand class="kw">extends AbstractCommand {
      @Nonnull
      class="kw">private class="kw">final OptionalArg<String> presetArg = this.withOptionalArg("preset", "server.commands.npc.debug.presets.preset.desc", ArgTypes.STRING);

      class="kw">public PresetsCommand() {
         super("presets", "server.commands.npc.debug.presets.desc");
      }

      @Nullable
      @Override
      class="kw">protected CompletableFuture<Void> execute(@Nonnull CommandContext var1) {
         if (this.presetArg.provided(var1)) {
            String var5 = this.presetArg.get(var1);
            if (!var5.isEmpty() && RoleDebugFlags.havePreset(var5)) {
               EnumSet var6 = RoleDebugFlags.getPreset(var5);
               String var7 = NPCDebugCommand.getListOfFlags(var6).toString();
               var1.sendMessage(
                  Message.translation("server.commands.npc.debug.preset.info").param("preset", var5).param("flags", !var7.isEmpty() ? var7 : "<None>")
               );
               class="kw">return null;
            } else {
               var1.sendMessage(Message.translation("server.commands.errors.npc.unknown_debug_preset").param("preset", var5));
               class="kw">return null;
            }
         } else {
            String var2 = RoleDebugFlags.getListOfAllFlags(new StringBuilder()).toString();
            String var3 = RoleDebugFlags.getListOfAllPresets(new StringBuilder()).toString();
            Message var4 = Message.translation("server.commands.npc.debug.presets.info").param("flags", var2).param("presets", var3);
            var1.sendMessage(var4);
            class="kw">return null;
         }
      }
   }

   class="kw">public class="kw">static class SetCommand class="kw">extends NPCMultiSelectCommandBase {
      @Nonnull
      class="kw">private class="kw">final RequiredArg<String> flagsArg = this.withRequiredArg("flags", "server.commands.npc.debug.flags.desc", ArgTypes.STRING);

      class="kw">public SetCommand() {
         super("set", "server.commands.npc.debug.set.desc");
      }

      @Override
      class="kw">protected void execute(
         @Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5
      ) {
         String var6 = this.flagsArg.get(var1);
         EnumSet var7 = RoleDebugFlags.getFlags(var6.split(",", 0));
         NPCDebugCommand.modifyFlags(var1, var2, var5, var7, (var0, var1x) -> var1x, var4);
      }
   }

   class="kw">public class="kw">static class ShowCommand class="kw">extends NPCMultiSelectCommandBase {
      class="kw">public ShowCommand() {
         super("show", "server.commands.npc.debug.show.desc");
      }

      @Override
      class="kw">protected void execute(
         @Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5
      ) {
         String var6 = NPCDebugCommand.getListOfFlags(var2.getRoleDebugFlags()).toString();
         var1.sendMessage(
            Message.translation("server.commands.npc.debug.currentFlags").param("role", var2.getRoleName()).param("flags", !var6.isEmpty() ? var6 : "<None>")
         );
      }
   }

   class="kw">public class="kw">static class ToggleCommand class="kw">extends NPCMultiSelectCommandBase {
      @Nonnull
      class="kw">private class="kw">final RequiredArg<String> flagsArg = this.withRequiredArg("flags", "server.commands.npc.debug.flags.desc", ArgTypes.STRING);

      class="kw">public ToggleCommand() {
         super("toggle", "server.commands.npc.debug.toggle.desc");
      }

      @Override
      class="kw">protected void execute(
         @Nonnull CommandContext var1, @Nonnull NPCEntity var2, @Nonnull World var3, @Nonnull Store<EntityStore> var4, @Nonnull Ref<EntityStore> var5
      ) {
         String var6 = this.flagsArg.get(var1);
         EnumSet var7 = RoleDebugFlags.getFlags(var6.split(",", 0));
         NPCDebugCommand.modifyFlags(var1, var2, var5, var7, (var0, var1x) -> {
            if (var1x.isEmpty()) {
               class="kw">return null;
            }

            EnumSet var2 = var0.clone();

            for (RoleDebugFlags var4 : var1x) {
               if (var2.contains(var4)) {
                  var2.remove(var4);
               } else {
                  var2.add(var4);
               }
            }

            class="kw">return var2;
         }, var4);
      }
   }
}