SetNameRespawnPointPage.java
package com.hypixel.hytale.builtin.beds.respawn;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.InteractionType;
import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType;
import com.hypixel.hytale.protocol.packets.interface_.Page;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerRespawnPointData;
import com.hypixel.hytale.server.core.ui.builder.EventData;
import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder;
import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.meta.state.RespawnBlock;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class SetNameRespawnPointPage extends RespawnPointPage {
private final Vector3i respawnBlockPosition;
private final RespawnBlock respawnBlock;
public SetNameRespawnPointPage {
(playerRef, interactionType);
.respawnBlockPosition = respawnBlockPosition;
.respawnBlock = respawnBlock;
}
{
commandBuilder.append();
(Player)store.getComponent(ref, Player.getComponentType());
playerComponent != ;
(PlayerRef)store.getComponent(ref, PlayerRef.getComponentType());
playerRefComponent != ;
((EntityStore)store.getExternalData()).getWorld();
PlayerRespawnPointData[] respawnPoints = playerComponent.getPlayerConfigData().getPerWorldData(world.getName()).getRespawnPoints();
;
(respawnPoints != ) {
(PlayerRespawnPointData respawnPoint : respawnPoints) {
(respawnPoint.getBlockPosition().equals(.respawnBlockPosition)) {
respawnPointName = respawnPoint.getName();
;
}
}
}
(respawnPointName == ) {
commandBuilder.set(, Message.translation().param(, playerRefComponent.getUsername()));
} {
commandBuilder.set(, respawnPointName);
}
eventBuilder.addEventBinding(CustomUIEventBindingType.Activating, , EventData.of(, ));
eventBuilder.addEventBinding(CustomUIEventBindingType.Activating, , EventData.of(, ));
}
{
data.getRespawnPointName();
(respawnPointName != ) {
.setRespawnPointForPlayer(ref, store, .respawnBlockPosition, .respawnBlock, respawnPointName, []);
} (.equals(data.getAction())) {
(Player)store.getComponent(ref, Player.getComponentType());
playerComponent.getPageManager().setPage(ref, store, Page.None);
}
}
}