NPCMessageCommand class

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

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

extends: AbstractPlayerCommand

Поля (6)

МодификаторыТипИмя
Ref var10
BeaconSupport var11
String var6
double var7
BeaconSupport var7
Pair var9

Методы (3)

МодификаторыВозвратСигнатура
if if(var9 != null)
if if(var11 != null)
abstract super super("message", "server.commands.npc.message.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.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
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.arguments.types.EntityWrappedArg;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
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.components.messaging.BeaconSupport;
class="kw">import com.hypixel.hytale.server.npc.entities.NPCEntity;
class="kw">import it.unimi.dsi.fastutil.Pair;
class="kw">import javax.annotation.Nonnull;

class="kw">public class NPCMessageCommand class="kw">extends AbstractPlayerCommand {
   @Nonnull
   class="kw">private class="kw">final RequiredArg<String> messageArg = this.withRequiredArg("message", "server.commands.npc.message.message.desc", ArgTypes.STRING);
   @Nonnull
   class="kw">private class="kw">final OptionalArg<Double> expirationTimeArg = this.withOptionalArg("expiration", "server.commands.npc.message.expiration", ArgTypes.DOUBLE);
   @Nonnull
   class="kw">private class="kw">final FlagArg allArg = this.withFlagArg("all", "server.commands.npc.message.all");
   @Nonnull
   class="kw">private class="kw">final EntityWrappedArg entityArg = this.withOptionalArg("entity", "server.commands.entity.entity.desc", ArgTypes.ENTITY_ID);

   class="kw">public NPCMessageCommand() {
      super("message", "server.commands.npc.message.desc");
   }

   @Override
   class="kw">protected void execute(
      @Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
   ) {
      String var6 = this.messageArg.get(var1);
      double var7 = this.expirationTimeArg.provided(var1) ? this.expirationTimeArg.get(var1) : 1.0;
      if (this.allArg.get(var1)) {
         var2.forEachEntityParallel(BeaconSupport.getComponentType(), (var4x, var5x, var6x) -> {
            BeaconSupport var7 = var5x.getComponent(var4x, BeaconSupport.getComponentType());
            assert var7 != null;
            var7.postMessage(var6, var3, var7);
         });
      } else {
         Pair var9 = NPCCommandUtils.getTargetNpc(var1, this.entityArg, var2);
         if (var9 != null) {
            Ref var10 = (Ref<EntityStore>)var9.first();
            BeaconSupport var11 = var2.getComponent(var10, BeaconSupport.getComponentType());
            if (var11 != null) {
               var11.postMessage(var6, var3, var7);
            }
         }
      }
   }
}