TeleportPlayerToCoordinatesCommand class

Пакет: com.hypixel.hytale.builtin.teleport.commands.teleport.variant

Файл: com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportPlayerToCoordinatesCommand.java

extends: CommandBase

Поля (24)

МодификаторыТипИмя
Coord var10
Coord var11
Coord var12
double var13
double var15
double var17
float var19
PlayerRef var2
float var20
float var21
Teleport var22
Player var23
boolean var24
float var25
float var26
float var27
Ref var3
Store var4
World var5
TransformComponent var5
HeadRotation var6
Vector3d var7
Rotation3f var8
Rotation3f var9

Методы (3)

МодификаторыВозвратСигнатура
if if(var23 != null)
if if(var24)
abstract super super("server.commands.teleport.toCoordinates.desc")

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.teleport.components.TeleportHistory;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
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.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.Coord;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeFloat;
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.modules.entity.teleport.Teleport;
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.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;

class="kw">public class TeleportPlayerToCoordinatesCommand class="kw">extends CommandBase {
   @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">final RequiredArg<PlayerRef> playerArg = this.withRequiredArg("player", "server.commands.teleport.targetPlayer.desc", ArgTypes.PLAYER_REF);
   @Nonnull
   class="kw">private class="kw">final RequiredArg<Coord> xArg = this.withRequiredArg("x", "server.commands.teleport.x.desc", ArgTypes.RELATIVE_DOUBLE_COORD)
      .withSuggestionOverride(ArgTypes.RELATIVE_POSITION);
   @Nonnull
   class="kw">private class="kw">final RequiredArg<Coord> yArg = this.withRequiredArg("y", "server.commands.teleport.y.desc", ArgTypes.RELATIVE_DOUBLE_COORD);
   @Nonnull
   class="kw">private class="kw">final RequiredArg<Coord> zArg = this.withRequiredArg("z", "server.commands.teleport.z.desc", ArgTypes.RELATIVE_DOUBLE_COORD);
   @Nonnull
   class="kw">private class="kw">final OptionalArg<RelativeFloat> yawArg = this.withOptionalArg("yaw", "server.commands.teleport.yaw.desc", ArgTypes.RELATIVE_FLOAT);
   @Nonnull
   class="kw">private class="kw">final OptionalArg<RelativeFloat> pitchArg = this.withOptionalArg("pitch", "server.commands.teleport.pitch.desc", ArgTypes.RELATIVE_FLOAT);
   @Nonnull
   class="kw">private class="kw">final OptionalArg<RelativeFloat> rollArg = this.withOptionalArg("roll", "server.commands.teleport.roll.desc", ArgTypes.RELATIVE_FLOAT);

   class="kw">public TeleportPlayerToCoordinatesCommand() {
      super("server.commands.teleport.toCoordinates.desc");
      this.requirePermission(HytalePermissions.fromCommand("teleport.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(
            () -> {
               TransformComponent var5 = var4.getComponent(var3, TransformComponent.getComponentType());
               assert var5 != null;
               HeadRotation var6 = var4.getComponent(var3, HeadRotation.getComponentType());
               assert var6 != null;
               Vector3d var7 = new Vector3d(var5.getPosition());
               Rotation3f var8 = new Rotation3f(var6.getRotation());
               Rotation3f var9 = new Rotation3f(var5.getRotation());
               Coord var10 = this.xArg.get(var1);
               Coord var11 = this.yArg.get(var1);
               Coord var12 = this.zArg.get(var1);
               double var13 = var10.resolveXZ(var7.x());
               double var15 = var12.resolveXZ(var7.z());
               double var17 = var11.resolveYAtWorldCoords(var7.y(), var5, var13, var15);
               float var19 = this.yawArg.provided(var1)
                  ? this.yawArg.get(var1).resolve(var8.yaw() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0)
                  : Float.NaN;
               float var20 = this.pitchArg.provided(var1)
                  ? this.pitchArg.get(var1).resolve(var8.pitch() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0)
                  : Float.NaN;
               float var21 = this.rollArg.provided(var1)
                  ? this.rollArg.get(var1).resolve(var8.roll() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0)
                  : Float.NaN;
               Teleport var22 = Teleport.createExact(
                  new Vector3d(var13, var17, var15), new Rotation3f(var9.pitch(), var19, var9.roll()), new Rotation3f(var20, var19, var21)
               );
               var4.addComponent(var3, Teleport.getComponentType(), var22);
               Player var23 = var4.getComponent(var3, Player.getComponentType());
               if (var23 != null) {
                  var4.ensureAndGetComponent(var3, TeleportHistory.getComponentType())
                     .append(var5, var7, var8, String.format("Teleport to (%s, %s, %s)", var13, var17, var15));
               }

               boolean var24 = this.yawArg.provided(var1) || this.pitchArg.provided(var1) || this.rollArg.provided(var1);
               if (var24) {
                  float var25 = Float.isNaN(var19) ? var8.yaw() * (180.0F / (float)Math.PI) : var19 * (180.0F / (float)Math.PI);
                  float var26 = Float.isNaN(var20) ? var8.pitch() * (180.0F / (float)Math.PI) : var20 * (180.0F / (float)Math.PI);
                  float var27 = Float.isNaN(var21) ? var8.roll() * (180.0F / (float)Math.PI) : var21 * (180.0F / (float)Math.PI);
                  var1.sendMessage(
                     Message.translation("server.commands.teleport.teleportedToCoordinatesWithLook")
                        .param("x", var13)
                        .param("y", var17)
                        .param("z", var15)
                        .param("yaw", var25)
                        .param("pitch", var26)
                        .param("roll", var27)
                  );
               } else {
                  var1.sendMessage(
                     Message.translation("server.commands.teleport.teleportedToCoordinates").param("x", var13).param("y", var17).param("z", var15)
                  );
               }
            }
         );
      } else {
         var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
      }
   }
}