WhereAmIOtherCommand class

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

Файл: com/hypixel/hytale/server/core/command/commands/player/WhereAmICommand.java

extends: CommandBase

Поля (8)

МодификаторыТипИмя
private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD
private final RequiredArg<PlayerRef> playerArg
PlayerRef var2
Ref var3
Store var4
Player var4
World var5
PlayerRef var5

Методы (3)

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

Исходный код

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

class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.Axis;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
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.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.AbstractPlayerCommand;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.permissions.HytalePermissions;
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.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 javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;

class="kw">public class WhereAmICommand class="kw">extends AbstractPlayerCommand {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_COMMANDS_WHERE_AM_I_CHUNK_NOT_LOADED = Message.translation("server.commands.whereami.chunkNotLoaded");

   class="kw">public WhereAmICommand() {
      super("whereami", "server.commands.whereami.desc");
      this.setPermissionGroups("hytale:Adventurer");
      this.requirePermission(HytalePermissions.fromCommand("whereami.self"));
      this.addUsageVariant(new WhereAmICommand.WhereAmIOtherCommand());
   }

   @Override
   class="kw">protected void execute(
      @Nonnull CommandContext var1, @Nonnull Store<EntityStore> var2, @Nonnull Ref<EntityStore> var3, @Nonnull PlayerRef var4, @Nonnull World var5
   ) {
      sendLocationInfo(var1, var2, var3, var5, null);
   }

   class="kw">private class="kw">static void sendLocationInfo(
      @Nonnull CommandContext var0, @Nonnull Store<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull World var3, @Nullable String var4
   ) {
      TransformComponent var5 = var1.getComponent(var2, TransformComponent.getComponentType());
      assert var5 != null;
      HeadRotation var6 = var1.getComponent(var2, HeadRotation.getComponentType());
      assert var6 != null;
      Vector3d var7 = var5.getPosition();
      Rotation3f var8 = var6.getRotation();
      Vector3i var9 = var6.getAxisDirection();
      Axis var10 = var6.getAxis();
      Vector3d var11 = var6.getDirection();
      int var12 = MathUtil.floor(var7.x()) >> 5;
      int var13 = MathUtil.floor(var7.y()) >> 5;
      int var14 = MathUtil.floor(var7.z()) >> 5;
      long var15 = ChunkUtil.indexChunk(var12, var14);
      ChunkStore var17 = var3.getChunkStore();
      Store var18 = var17.getStore();
      Ref var19 = var17.getChunkReference(var15);
      WorldChunk var20 = var19 != null && var19.isValid() ? var18.getComponent(var19, WorldChunk.getComponentType()) : null;
      String var21 = var4 != null ? "server.commands.whereami.header.other" : "server.commands.whereami.header";
      Message var22 = Message.translation(var21)
         .param("username", var4)
         .param("world", var3.getName())
         .param("chunkX", var12)
         .param("chunkY", var13)
         .param("chunkZ", var14)
         .param("posX", var7.x())
         .param("posY", var7.y())
         .param("posZ", var7.z())
         .param("yaw", var8.yaw())
         .param("pitch", var8.pitch())
         .param("roll", var8.roll())
         .param("direction", var11.toString())
         .param("axisDirection", var9.toString())
         .param("axis", var10.toString());
      if (var20 == null) {
         var22.insert(MESSAGE_COMMANDS_WHERE_AM_I_CHUNK_NOT_LOADED);
      } else {
         var22.insert(Message.translation("server.commands.whereami.needsSaving").param("needsSaving", Boolean.toString(var20.getNeedsSaving())));
      }

      var0.sendMessage(var22);
   }

   class="kw">private class="kw">static class WhereAmIOtherCommand class="kw">extends CommandBase {
      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">final RequiredArg<PlayerRef> playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF);

      WhereAmIOtherCommand() {
         super("server.commands.whereami.other.desc");
         this.setPermissionGroups("hytale:Adventurer");
         this.requirePermission(HytalePermissions.fromCommand("whereami.other"));
      }

      @Override
      class="kw">protected void executeSync(@Nonnull CommandContext var1) {
         PlayerRef var2 = this.playerArg.get(var1);
         Ref var3 = var2.getReference();
         if (var3 != null && var3.isValid()) {
            Store var4 = var3.getStore();
            World var5 = var4.getExternalData().getWorld();
            var5.execute(() -> {
               Player var4 = var4.getComponent(var3, Player.getComponentType());
               if (var4 == null) {
                  var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
               } else {
                  PlayerRef var5 = var4.getComponent(var3, PlayerRef.getComponentType());
                  assert var5 != null;
                  WhereAmICommand.sendLocationInfo(var1, var4, var3, var5, var5.getUsername());
               }
            });
         } else {
            var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
         }
      }
   }
}