HubPortalInteraction class
Пакет: com.hypixel.hytale.builtin.creativehub.interactions
Файл: com/hypixel/hytale/builtin/creativehub/interactions/HubPortalInteraction.java
extends: SimpleInstantInteraction
Поля (40)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
return |
|
Universe |
var10 |
|
UUID |
var10 |
|
World |
var11 |
|
|
var11 |
|
CreativeHubEntityConfig |
var11 |
|
CompletableFuture |
var12 |
|
|
var12 |
|
|
var12 |
|
|
var12 |
|
|
var12 |
|
World |
var2 |
|
WorldConfig |
var3 |
|
WorldConfig |
var3 |
|
PlayerWorldData |
var3 |
|
CommandBuffer |
var4 |
|
WorldConfig |
var4 |
|
Map |
var4 |
|
ISpawnProvider |
var4 |
|
Ref |
var5 |
|
PlayerWorldData |
var5 |
|
TransformComponent |
var5 |
|
CreativeHubEntityConfig |
var6 |
|
Transform |
var6 |
|
|
var6 |
|
|
var6 |
|
Transform |
var6 |
|
World |
var6 |
|
Player |
var7 |
|
UUIDComponent |
var7 |
|
PlayerRef |
var7 |
|
CreativeHubWorldConfig |
var7 |
|
Archetype |
var8 |
|
ISpawnProvider |
var8 |
|
Map |
var8 |
|
World |
var8 |
|
World |
var9 |
|
Teleport |
var9 |
|
UUIDComponent |
var9 |
|
World |
var9 |
Методы (17)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
static |
void |
applyParentWorldSettingsvoid applyParentWorldSettings(@Nonnull World var0, @Nullable CreativeHubEntityConfig var1) |
abstract |
|
applyParentWorldSettings applyParentWorldSettings(var2x, var6) |
|
|
if if(var11 != null) |
|
|
if if(this.instanceTemplate != null) |
|
|
if if(var2 != null) |
|
|
if if(var2 != null) |
|
|
if if(var5 == null) |
|
|
if if(var7 == null) |
|
|
if if(var9 == null) |
|
|
if if(var5x != null) |
|
|
if if(var4x == null) |
|
|
if if(var6 != null) |
|
|
if if(var9 != null) |
static |
void |
teleportToLoadedWorldvoid teleportToLoadedWorld(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, @Nonnull World var2, @Nonnull Player var3) |
abstract |
|
teleportToLoadedWorld teleportToLoadedWorld(var5, var4, var11, var7) |
static |
void |
teleportToLoadingWorldvoid teleportToLoadingWorld(@Nonnull Ref<EntityStore> var0,
@Nonnull ComponentAccessor<EntityStore> var1,
@Nonnull CompletableFuture<World> var2,
@Nonnull World var3,
@Nonnull Player var4) |
abstract |
|
teleportToLoadingWorld teleportToLoadingWorld(var5, var4, var12, var9, var7) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.creativehub.interactions;
class="kw">import com.hypixel.hytale.builtin.creativehub.CreativeHubPlugin;
class="kw">import com.hypixel.hytale.builtin.creativehub.config.CreativeHubEntityConfig;
class="kw">import com.hypixel.hytale.builtin.creativehub.config.CreativeHubWorldConfig;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.component.Archetype;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.math.vector.Transform;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.protocol.WaitForDataFrom;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.teleport.PendingTeleport;
class="kw">import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.Universe;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.WorldConfig;
class="kw">import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.Map;
class="kw">import java.util.UUID;
class="kw">import java.util.concurrent.CompletableFuture;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class HubPortalInteraction class="kw">extends SimpleInstantInteraction {
@Nonnull
class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
class="kw">private class="kw">static class="kw">final String LEGACY_DEFAULT_WORLD_NAME = "default_world";
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<HubPortalInteraction> CODEC = BuilderCodec.builder(
HubPortalInteraction.class, HubPortalInteraction::new, SimpleInstantInteraction.CODEC
)
.documentation("Teleports the **Player** to a permanent world, creating it if required.")
.<String>appendInherited(
new KeyedCodec<>("WorldName", Codec.STRING),
(var0, var1) -> var0.worldName = var1,
var0 -> var0.worldName,
(var0, var1) -> var0.worldName = var1.worldName
)
.documentation("The name of the permanent world to teleport to.")
.addValidator(Validators.nonNull())
.add()
.<String>appendInherited(
new KeyedCodec<>("WorldGenType", Codec.STRING),
(var0, var1) -> var0.worldGenType = var1,
var0 -> var0.worldGenType,
(var0, var1) -> var0.worldGenType = var1.worldGenType
)
.documentation("The world generator type to use when creating the world (e.g., 'Flat', 'Hytale'). Mutually exclusive with InstanceTemplate.")
.add()
.<String>appendInherited(
new KeyedCodec<>("InstanceTemplate", Codec.STRING),
(var0, var1) -> var0.instanceTemplate = var1,
var0 -> var0.instanceTemplate,
(var0, var1) -> var0.instanceTemplate = var1.instanceTemplate
)
.documentation("Instance asset to use as template for creating the permanent world. Mutually exclusive with WorldGenType.")
.add()
.build();
class="kw">private String worldName;
class="kw">private String worldGenType;
@Nullable
class="kw">private String instanceTemplate;
class="kw">public HubPortalInteraction() {
}
@Nonnull
@Override
class="kw">public WaitForDataFrom getWaitForDataFrom() {
class="kw">return WaitForDataFrom.Server;
}
@Override
class="kw">protected void firstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
CommandBuffer var4 = var2.getCommandBuffer();
assert var4 != null;
Ref var5 = var2.getEntity();
CreativeHubEntityConfig var6 = var4.getComponent(var5, CreativeHubEntityConfig.getComponentType());
Player var7 = var4.getComponent(var5, Player.getComponentType());
if (var7 != null && !var7.isWaitingForClientReady()) {
Archetype var8 = var4.getArchetype(var5);
if (!var8.contains(Teleport.getComponentType()) && !var8.contains(PendingTeleport.getComponentType())) {
World var9 = var4.getExternalData().getWorld();
Universe var10 = Universe.get();
World var11 = var10.getWorld(this.worldName);
if (var11 == null && this.worldName.equals("class="kw">default")) {
var11 = var10.getWorld("default_world");
}
if (var11 != null) {
teleportToLoadedWorld(var5, var4, var11, var7);
} else {
CompletableFuture var12;
if (this.instanceTemplate != null) {
var12 = CreativeHubPlugin.get().spawnPermanentWorldFromTemplate(this.instanceTemplate, this.worldName, var1x -> {
if (var6 != null && var6.getParentHubWorldUuid() != null) {
World var2 = Universe.get().getWorld(var6.getParentHubWorldUuid());
if (var2 != null) {
WorldConfig var3 = var2.getWorldConfig();
var1x.setSpawningNPC(var3.isSpawningNPC());
var1x.setGameTimePaused(var3.isGameTimePaused());
var1x.setBlockSpawnersResolved(var3.isBlockSpawnersResolved());
}
}
});
} else if (var10.isWorldLoadable(this.worldName)) {
var12 = var10.loadWorld(this.worldName);
} else if (this.worldName.equals("class="kw">default") && var10.isWorldLoadable("default_world")) {
var12 = var10.loadWorld("default_world");
} else {
var12 = var10.addWorld(this.worldName, this.worldGenType, null);
var12.thenAccept(var2x -> {
if (var2x.getWorldConfig().getDisplayName() == null) {
var2x.getWorldConfig().setDisplayName(WorldConfig.formatDisplayName(this.worldName));
}
applyParentWorldSettings(var2x, var6);
});
}
teleportToLoadingWorld(var5, var4, var12, var9, var7);
}
}
}
}
class="kw">private class="kw">static void applyParentWorldSettings(@Nonnull World var0, @Nullable CreativeHubEntityConfig var1) {
if (var1 != null && var1.getParentHubWorldUuid() != null) {
World var2 = Universe.get().getWorld(var1.getParentHubWorldUuid());
if (var2 != null) {
WorldConfig var3 = var2.getWorldConfig();
WorldConfig var4 = var0.getWorldConfig();
var4.setSpawningNPC(var3.isSpawningNPC());
var4.setGameTimePaused(var3.isGameTimePaused());
var4.setBlockSpawnersResolved(var3.isBlockSpawnersResolved());
}
}
}
class="kw">private class="kw">static void teleportToLoadedWorld(
@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, @Nonnull World var2, @Nonnull Player var3
) {
Map var4 = var3.getPlayerConfigData().getPerWorldData();
PlayerWorldData var5 = var4.get(var2.getName());
Transform var6;
if (var5 != null && var5.getLastPosition() != null) {
var6 = var5.getLastPosition();
} else {
UUIDComponent var7 = var1.getComponent(var0, UUIDComponent.getComponentType());
assert var7 != null;
ISpawnProvider var8 = var2.getWorldConfig().getSpawnProvider();
var6 = var8 != null ? var8.getSpawnPoint(var2, var7.getUuid()) : new Transform();
}
Teleport var9 = Teleport.createForPlayer(var2, var6);
var1.addComponent(var0, Teleport.getComponentType(), var9);
}
class="kw">private class="kw">static void teleportToLoadingWorld(
@Nonnull Ref<EntityStore> var0,
@Nonnull ComponentAccessor<EntityStore> var1,
@Nonnull CompletableFuture<World> var2,
@Nonnull World var3,
@Nonnull Player var4
) {
TransformComponent var5 = var1.getComponent(var0, TransformComponent.getComponentType());
if (var5 == null) {
LOGGER.at(Level.SEVERE).log("Cannot teleport player %s to permanent world - missing TransformComponent", var0);
} else {
Transform var6 = new Transform(var5.getTransform());
PlayerRef var7 = var1.getComponent(var0, PlayerRef.getComponentType());
if (var7 == null) {
LOGGER.at(Level.SEVERE).log("Cannot teleport player %s to permanent world - missing PlayerRef component", var0);
} else {
Map var8 = var4.getPlayerConfigData().getPerWorldData();
UUIDComponent var9 = var1.getComponent(var0, UUIDComponent.getComponentType());
if (var9 == null) {
LOGGER.at(Level.SEVERE).log("Cannot teleport player %s to permanent world - missing UUIDComponent", var0);
} else {
UUID var10 = var9.getUuid();
CreativeHubEntityConfig var11 = var1.getComponent(var0, CreativeHubEntityConfig.getComponentType());
Universe.transferPlayerAsync(var7, var3, var2, var2x -> {
PlayerWorldData var3 = var8.get(var2x.getName());
if (var3 != null && var3.getLastPosition() != null) {
class="kw">return var3.getLastPosition();
}
ISpawnProvider var4 = var2x.getWorldConfig().getSpawnProvider();
class="kw">return var4 != null ? var4.getSpawnPoint(var2x, var10) : null;
}).whenComplete((var4x, var5x) -> {
if (var5x != null) {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(var5x)).log("Failed to teleport %s to permanent world", var7.getUsername());
}
if (var4x == null) {
if (var3.isAlive()) {
var3.addPlayer(var7, var6, Boolean.TRUE, Boolean.FALSE);
} else {
if (var11 != null && var11.getParentHubWorldUuid() != null) {
World var6 = Universe.get().getWorld(var11.getParentHubWorldUuid());
if (var6 != null) {
CreativeHubWorldConfig var7 = CreativeHubWorldConfig.get(var6.getWorldConfig());
if (var7 != null && var7.getStartupInstance() != null) {
World var8 = CreativeHubPlugin.get().getOrSpawnHubInstance(var6, var7, new Transform());
var8.addPlayer(var7, null, Boolean.TRUE, Boolean.FALSE);
class="kw">return;
}
}
}
World var9 = Universe.get().getDefaultWorld();
if (var9 != null) {
var9.addPlayer(var7, null, Boolean.TRUE, Boolean.FALSE);
} else {
LOGGER.at(Level.SEVERE).log("No fallback world available for %s, disconnecting", var7.getUsername());
var7.getPacketHandler().disconnect(Message.translation("server.general.disconnect.teleportNoWorld"));
}
}
}
});
}
}
}
}
}