EntityCloneCommand class

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

Файл: com/hypixel/hytale/server/core/command/commands/world/entity/EntityCloneCommand.java

extends: AbstractWorldCommand

Поля (5)

МодификаторыТипИмя
Holder var3
Ref var4
CommandSender var5
int var6
Holder var8

Методы (4)

МодификаторыВозвратСигнатура
static void cloneEntityvoid cloneEntity(@Nonnull CommandSender var0, @Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2)
for for(int var7 = 0; var7 < var6; var7++)
if if(var6 == 1)
abstract super super("clone", "server.commands.entity.clone.desc")

Исходный код

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

class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.Holder;
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.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandSender;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
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.AbstractWorldCommand;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
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 java.util.UUID;
class="kw">import javax.annotation.Nonnull;

class="kw">public class EntityCloneCommand class="kw">extends AbstractWorldCommand {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_GENERAL_NO_ENTITY_IN_VIEW = Message.translation("server.general.noEntityInView");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ENTITY_CLONE_CLONED = Message.translation("server.commands.entity.clone.cloned");
   @Nonnull
   class="kw">private class="kw">final EntityWrappedArg entityArg = this.withOptionalArg("entity", "server.commands.entity.clone.entity.desc", ArgTypes.ENTITY_ID);
   @Nonnull
   class="kw">private class="kw">final DefaultArg<Integer> countArg = this.withDefaultArg(
         "count", "server.commands.entity.clone.count.desc", ArgTypes.INTEGER, 1, "server.commands.entity.clone.count.class="kw">default"
      )
      .addValidator(Validators.greaterThan(0));

   class="kw">public EntityCloneCommand() {
      super("clone", "server.commands.entity.clone.desc");
   }

   @Override
   class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
      Ref var4 = this.entityArg.get(var3, var1);
      if (var4 != null && var4.isValid()) {
         CommandSender var5 = var1.sender();
         int var6 = this.countArg.get(var1);

         for (int var7 = 0; var7 < var6; var7++) {
            Holder var8 = var3.copyEntity(var4);
            var8.replaceComponent(UUIDComponent.getComponentType(), new UUIDComponent(UUID.randomUUID()));
            var3.addEntity(var8, AddReason.SPAWN);
         }

         if (var6 == 1) {
            var5.sendMessage(MESSAGE_COMMANDS_ENTITY_CLONE_CLONED);
         } else {
            var5.sendMessage(Message.translation("server.commands.entity.clone.cloned.multiple").param("count", var6));
         }
      } else {
         var1.sendMessage(MESSAGE_GENERAL_NO_ENTITY_IN_VIEW);
      }
   }

   class="kw">public class="kw">static void cloneEntity(@Nonnull CommandSender var0, @Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) {
      Holder var3 = var2.copyEntity(var1);
      if (var3.getComponent(UUIDComponent.getComponentType()) != null) {
         var3.replaceComponent(UUIDComponent.getComponentType(), new UUIDComponent(UUID.randomUUID()));
      }

      var2.addEntity(var3, AddReason.SPAWN);
   }
}