BlockSpawnerSetCommand class

Пакет: com.hypixel.hytale.builtin.blockspawner.command

Файл: com/hypixel/hytale/builtin/blockspawner/command/BlockSpawnerSetCommand.java

extends: AbstractWorldCommand

Поля (15)

МодификаторыТипИмя
return
String[] var10
Ref var11
WorldChunk var12
Ref var13
Vector3i var4
var4
var4
RelativeIntPosition var5
Vector3i var6
Store var7
BlockSpawner var8
String var9
var9
var9

Методы (8)

МодификаторыВозвратСигнатура
abstract throw new GeneralCommandExceptionthrow new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_PROVIDE_POSITION)
abstract throw new GeneralCommandExceptionthrow new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD)
abstract throw new GeneralCommandExceptionthrow new GeneralCommandException(MESSAGE_GENERAL_BLOCK_TARGET_NOT_IN_RANGE)
if if(var6 == null)
if if(var12 == null)
if if(var8 == null)
if if(var9 == null)
abstract super super("set", "server.commands.blockspawner.set.desc")

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.blockspawner.command;

class="kw">import com.hypixel.hytale.builtin.blockspawner.BlockSpawnerTable;
class="kw">import com.hypixel.hytale.builtin.blockspawner.state.BlockSpawner;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
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.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.AssetArgumentType;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeIntPosition;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.SingleArgumentType;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
class="kw">import com.hypixel.hytale.server.core.command.system.exceptions.GeneralCommandException;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.core.util.TargetUtil;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3i;

class="kw">public class BlockSpawnerSetCommand class="kw">extends AbstractWorldCommand {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_GENERAL_BLOCK_TARGET_NOT_IN_RANGE = Message.translation("server.general.blockTargetNotInRange");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ERRORS_PROVIDE_POSITION = Message.translation("server.commands.errors.providePosition");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld");
   @Nonnull
   class="kw">private class="kw">static class="kw">final SingleArgumentType<BlockSpawnerTable> BLOCK_SPAWNER_ASSET_TYPE = new AssetArgumentType(
      "server.commands.parsing.argtype.asset.blockspawnertable.name", BlockSpawnerTable.class, "server.commands.parsing.argtype.asset.blockspawnertable.usage"
   );
   @Nonnull
   class="kw">private class="kw">final RequiredArg<BlockSpawnerTable> blockSpawnerIdArg = this.withRequiredArg(
      "blockSpawnerId", "server.commands.blockspawner.set.blockSpawnerId.desc", BLOCK_SPAWNER_ASSET_TYPE
   );
   @Nonnull
   class="kw">private class="kw">final OptionalArg<RelativeIntPosition> positionArg = this.withOptionalArg(
      "position", "server.commands.blockspawner.position.desc", ArgTypes.RELATIVE_BLOCK_POSITION
   );
   @Nonnull
   class="kw">private class="kw">final FlagArg ignoreChecksFlag = this.withFlagArg("ignoreChecks", "server.commands.blockspawner.arg.ignoreChecks");

   class="kw">public BlockSpawnerSetCommand() {
      super("set", "server.commands.blockspawner.set.desc");
   }

   @Override
   class="kw">protected void execute(@Nonnull CommandContext var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
      Vector3i var4;
      if (this.positionArg.provided(var1)) {
         RelativeIntPosition var5 = this.positionArg.get(var1);
         var4 = var5.getBlockPosition(var1, var3);
      } else {
         if (!var1.isPlayer()) {
            throw new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_PROVIDE_POSITION);
         }

         Ref var11 = var1.senderAsPlayerRef();
         if (var11 == null || !var11.isValid()) {
            throw new GeneralCommandException(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
         }

         Vector3i var6 = TargetUtil.getTargetBlock(var11, 10.0, var3);
         if (var6 == null) {
            throw new GeneralCommandException(MESSAGE_GENERAL_BLOCK_TARGET_NOT_IN_RANGE);
         }

         var4 = var6;
      }

      WorldChunk var12 = var2.getChunk(ChunkUtil.indexChunkFromBlock(var4.x, var4.z));
      if (var12 == null) {
         var1.sendMessage(Message.translation("server.general.containerNotFound").param("block", var4.toString()));
      } else {
         Ref var13 = var12.getBlockComponentEntity(var4.x, var4.y, var4.z);
         if (var13 != null && var13.isValid()) {
            Store var7 = var2.getChunkStore().getStore();
            BlockSpawner var8 = var7.getComponent(var13, BlockSpawner.getComponentType());
            if (var8 == null) {
               var1.sendMessage(Message.translation("server.general.containerNotFound").param("block", var4.toString()));
            } else {
               String var9;
               if (this.ignoreChecksFlag.get(var1)) {
                  String[] var10 = var1.getInput(this.blockSpawnerIdArg);
                  var9 = var10 != null && var10.length > 0 ? var10[0] : null;
                  if (var9 == null) {
                     var1.sendMessage(
                        Message.translation("errors.validation_failure").param("message", "blockSpawnerId is required when --ignoreChecks is set")
                     );
                     class="kw">return;
                  }
               } else {
                  var9 = this.blockSpawnerIdArg.get(var1).getId();
               }

               var8.setBlockSpawnerId(var9);
               var12.markNeedsSaving();
               var1.sendMessage(Message.translation("server.commands.blockspawner.blockSpawnerSet").param("id", var9));
            }
         } else {
            var1.sendMessage(Message.translation("server.general.containerNotFound").param("block", var4.toString()));
         }
      }
   }
}