TeleportOtherToPlayerCommand class
Пакет: com.hypixel.hytale.builtin.teleport.commands.teleport.variant
Файл: com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportOtherToPlayerCommand.java
extends: CommandBase
Поля (20)
| Модификаторы | Тип | Имя |
|---|---|---|
|
HeadRotation |
var10 |
|
Vector3d |
var11 |
|
TransformComponent |
var11 |
|
Teleport |
var11 |
|
Rotation3f |
var12 |
|
HeadRotation |
var12 |
|
Vector3d |
var13 |
|
Rotation3f |
var14 |
|
Transform |
var15 |
|
String |
var16 |
|
String |
var17 |
|
PlayerRef |
var2 |
|
Ref |
var3 |
|
PlayerRef |
var4 |
|
Ref |
var5 |
|
Store |
var6 |
|
World |
var7 |
|
Store |
var8 |
|
World |
var9 |
|
TransformComponent |
var9 |
Методы (1)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
|
super super("server.commands.teleport.otherToPlayer.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.math.vector.Transform;
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.CommandBase;
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 TeleportOtherToPlayerCommand 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">static class="kw">final Message MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD = Message.translation("server.commands.errors.targetNotInWorld");
@Nonnull
class="kw">private class="kw">final RequiredArg<PlayerRef> playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF);
@Nonnull
class="kw">private class="kw">final RequiredArg<PlayerRef> targetPlayerArg = this.withRequiredArg(
"targetPlayer", "server.commands.teleport.targetPlayer.desc", ArgTypes.PLAYER_REF
);
class="kw">public TeleportOtherToPlayerCommand() {
super("server.commands.teleport.otherToPlayer.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()) {
PlayerRef var4 = this.targetPlayerArg.get(var1);
Ref var5 = var4.getReference();
if (var5 != null && var5.isValid()) {
Store var6 = var3.getStore();
World var7 = var6.getExternalData().getWorld();
Store var8 = var5.getStore();
World var9 = var8.getExternalData().getWorld();
var7.execute(
() -> {
if (!var3.isValid()) {
var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
} else if (!var5.isValid()) {
var1.sendMessage(MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD);
} else {
TransformComponent var9 = var6.getComponent(var3, TransformComponent.getComponentType());
assert var9 != null;
HeadRotation var10 = var6.getComponent(var3, HeadRotation.getComponentType());
assert var10 != null;
Vector3d var11 = new Vector3d(var9.getPosition());
Rotation3f var12 = new Rotation3f(var10.getRotation());
var9.execute(
() -> {
TransformComponent var11 = var8.getComponent(var5, TransformComponent.getComponentType());
assert var11 != null;
HeadRotation var12 = var8.getComponent(var5, HeadRotation.getComponentType());
assert var12 != null;
Vector3d var13 = new Vector3d(var11.getPosition());
Rotation3f var14 = new Rotation3f(var12.getRotation());
Transform var15 = new Transform(var13, var14);
String var16 = var4.getUsername();
String var17 = var2.getUsername();
var7.execute(
() -> {
if (!var3.isValid()) {
var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
} else if (!var5.isValid()) {
var1.sendMessage(MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD);
} else {
Teleport var11 = Teleport.createForPlayer(var9, var15);
var6.addComponent(var3, Teleport.getComponentType(), var11);
var1.sendMessage(
Message.translation("server.commands.teleport.teleportedOtherToPlayer")
.param("targetName", var17)
.param("toName", var16)
);
var6.ensureAndGetComponent(var3, TeleportHistory.getComponentType())
.append(var7, var11, var12, "Teleport to " + var16 + " by " + var1.sender().getUsername());
}
}
);
}
);
}
}
);
} else {
var1.sendMessage(MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD);
}
} else {
var1.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD);
}
}
}