Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ plugin_description=Essential commands for Hytale servers - TPA, homes, warps, sp
plugin_author=HytaleModding
plugin_website=https://github.com/HytaleModding
plugin_main_entrypoint=dev.hytalemodding.hyssentials.HyssentialsPlugin
server_version=2026.02.17-255364b8e
server_version=0.5.3
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected void setup() {

this.getEventRegistry().register(PlayerConnectEvent.class, this::onPlayerConnect);
this.getEventRegistry().register(PlayerDisconnectEvent.class, this::onPlayerDisconnect);
this.getEventRegistry().registerGlobal(AddPlayerToWorldEvent.class, this.joinMessageManager::onPlayerEnterWorld);
this.getEventRegistry().registerGlobal(AddPlayerToWorldEvent.class, this::onPlayerEnterWorld);
this.getEventRegistry().registerGlobal(DrainPlayerFromWorldEvent.class, this.joinMessageManager::onPlayerLeaveWorld);
}

Expand Down Expand Up @@ -194,6 +194,15 @@ private boolean playerHasAnyRank(@Nonnull PlayerRef player) {
return false;
}

private void onPlayerEnterWorld(@Nonnull AddPlayerToWorldEvent event) {
joinMessageManager.onPlayerEnterWorld(event);

PlayerRef player = event.getHolder().getComponent(PlayerRef.getComponentType());
if (player != null) {
rankManager.ensureGrantedPermissions(player.getUuid());
}
}

private void onPlayerDisconnect(@Nonnull PlayerDisconnectEvent event) {
joinMessageManager.onPlayerDisconnect(event);
vanishManager.onPlayerLeave(event.getPlayerRef().getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
}
MovementStates newStates = states.getMovementStates().clone();
newStates.flying = false;
states.setMovementStates(newStates);
states.setSentMovementStates(newStates);

if (!currentlyCanFly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
Expand Down Expand Up @@ -51,13 +51,13 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
return;
}
HeadRotation headRotation = store.getComponent(ref, HeadRotation.getComponentType());
Vector3f rotation = headRotation != null ? headRotation.getRotation() : new Vector3f(0, 0, 0);
Rotation3f rotation = headRotation != null ? headRotation.getRotation() : new Rotation3f(0, 0, 0);
Vector3d position = transform.getPosition();
int maxHomes = rankManager.getEffectiveMaxHomes(playerRef);
boolean success = homeManager.setHome(playerUuid, name, world, position, rotation, maxHomes);
if (success) {
context.sendMessage(ChatUtil.parse(Messages.SUCCESS_HOME_SET,
name, position.getX(), position.getY(), position.getZ(), world.getName()));
name, position.x(), position.y(), position.z(), world.getName()));
} else {
context.sendMessage(ChatUtil.parse(Messages.ERROR_MAX_HOMES_REACHED, maxHomes));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
Expand Down Expand Up @@ -42,23 +42,23 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
return;
}

Vector3d position = transformComponent.getPosition().clone();
Vector3d position = new Vector3d(transformComponent.getPosition());

HeadRotation headRotation = store.getComponent(ref, HeadRotation.getComponentType());
Vector3f rotation = headRotation != null ? headRotation.getRotation() : Vector3f.FORWARD;
Rotation3f rotation = headRotation != null ? headRotation.getRotation() : new Rotation3f(0, 0, 0);

Transform transform = new Transform(position, rotation);
WorldConfig worldConfig = world.getWorldConfig();
worldConfig.setSpawnProvider(new GlobalSpawnProvider(transform));
worldConfig.markChanged();

context.sendMessage(ChatUtil.parse(Messages.SUCCESS_SPAWN_SET,
DECIMAL.format(position.getX()),
DECIMAL.format(position.getY()),
DECIMAL.format(position.getZ()),
DECIMAL.format(rotation.getX()),
DECIMAL.format(rotation.getY()),
DECIMAL.format(rotation.getZ())
DECIMAL.format(position.x()),
DECIMAL.format(position.y()),
DECIMAL.format(position.z()),
DECIMAL.format(rotation.x()),
DECIMAL.format(rotation.y()),
DECIMAL.format(rotation.z())
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.universe.PlayerRef;
Expand Down Expand Up @@ -61,8 +61,8 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
ISpawnProvider spawnProvider = world.getWorldConfig().getSpawnProvider();
Transform spawn = spawnProvider.getSpawnPoint(world, playerUuid);
Vector3d position = spawn.getPosition();
Vector3f rotation = spawn.getRotation();
LocationData spawnLocation = new LocationData(world.getName(), position.getX(), position.getY(), position.getZ(), rotation.getPitch(), rotation.getYaw());
Rotation3f rotation = spawn.getRotation();
LocationData spawnLocation = new LocationData(world.getName(), position.x(), position.y(), position.z(), rotation.pitch(), rotation.yaw());

int warmupSeconds = bypassCooldown ? 0 : settings.getWarmupSeconds();
warmupManager.startWarmup(playerRef, store, ref, world, spawnLocation, warmupSeconds, CooldownManager.SPAWN, "spawn", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.NameMatching;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
Expand Down Expand Up @@ -61,8 +61,8 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
TransformComponent myTransform = store.getComponent(ref, TransformComponent.getComponentType());
HeadRotation myHeadRot = store.getComponent(ref, HeadRotation.getComponentType());
if (myTransform != null) {
Vector3d myPos = myTransform.getPosition().clone();
Vector3f myRot = myHeadRot != null ? myHeadRot.getRotation().clone() : new Vector3f(0, 0, 0);
Vector3d myPos = new Vector3d(myTransform.getPosition());
Rotation3f myRot = myHeadRot != null ? myHeadRot.getRotation().clone() : new Rotation3f(0, 0, 0);
backManager.saveLocation(playerRef.getUuid(), LocationData.from(world.getName(), myPos, myRot));
}
targetWorld.execute(() -> {
Expand All @@ -72,9 +72,9 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
context.sendMessage(ChatUtil.parse(Messages.ERROR_CANNOT_GET_TARGET_POSITION));
return;
}
Vector3d targetPos = targetTransform.getPosition().clone();
Vector3f targetBodyRot = targetTransform.getRotation().clone();
Vector3f targetHeadRotation = targetHeadRot != null ? targetHeadRot.getRotation().clone() : new Vector3f(0, 0, 0);
Vector3d targetPos = new Vector3d(targetTransform.getPosition());
Rotation3f targetBodyRot = targetTransform.getRotation().clone();
Rotation3f targetHeadRotation = targetHeadRot != null ? targetHeadRot.getRotation().clone() : new Rotation3f(0, 0, 0);
world.execute(() -> {
// Use proper body and head rotation like vanilla Hytale
Teleport teleport = new Teleport(targetWorld, targetPos, targetBodyRot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.NameMatching;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
Expand Down Expand Up @@ -60,16 +60,15 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
context.sendMessage(ChatUtil.parse(Messages.ERROR_CANNOT_GET_POSITION));
return;
}
Vector3d myPos = myTransform.getPosition().clone();
Vector3f myRot = myHeadRot != null ? myHeadRot.getRotation().clone() : new Vector3f(0, 0, 0);
// Get body rotation for the teleport
Vector3f myBodyRot = myTransform.getRotation().clone();
Vector3d myPos = new Vector3d(myTransform.getPosition());
Rotation3f myRot = myHeadRot != null ? myHeadRot.getRotation().clone() : new Rotation3f(0, 0, 0);
Rotation3f myBodyRot = myTransform.getRotation().clone();
targetWorld.execute(() -> {
TransformComponent targetTransform = targetStore.getComponent(targetRef, TransformComponent.getComponentType());
HeadRotation targetHeadRot = targetStore.getComponent(targetRef, HeadRotation.getComponentType());
if (targetTransform != null) {
Vector3d targetPos = targetTransform.getPosition().clone();
Vector3f targetRot = targetHeadRot != null ? targetHeadRot.getRotation().clone() : new Vector3f(0, 0, 0);
Vector3d targetPos = new Vector3d(targetTransform.getPosition());
Rotation3f targetRot = targetHeadRot != null ? targetHeadRot.getRotation().clone() : new Rotation3f(0, 0, 0);
backManager.saveLocation(targetPlayer.getUuid(), LocationData.from(targetWorld.getName(), targetPos, targetRot));
}
// Use proper body and head rotation like vanilla Hytale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
Expand Down Expand Up @@ -71,12 +71,12 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
context.sendMessage(ChatUtil.parse(Messages.ERROR_CANNOT_GET_POSITION));
return;
}
Vector3d targetPos = targetTransform.getPosition().clone();
Vector3f targetRot = targetHeadRot != null ? targetHeadRot.getRotation().clone() : new Vector3f(0, 0, 0);
Vector3d targetPos = new Vector3d(targetTransform.getPosition());
Rotation3f targetRot = targetHeadRot != null ? targetHeadRot.getRotation().clone() : new Rotation3f(0, 0, 0);
if (world != senderWorld) {

}
LocationData destination = new LocationData(world.getName(), targetPos.getX(), targetPos.getY(), targetPos.getZ(), targetRot.getPitch(), targetRot.getYaw());
LocationData destination = new LocationData(world.getName(), targetPos.x(), targetPos.y(), targetPos.z(), targetRot.pitch(), targetRot.yaw());

TpaSettings senderSettings = rankManager.getEffectiveTpaSettings(senderPlayer);
warmupManager.startWarmup(senderPlayer, senderStore, senderRef, senderWorld, destination, senderSettings.getWarmupSeconds(), CooldownManager.TPA, playerRef.getUsername(), null);
Expand All @@ -88,9 +88,9 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
context.sendMessage(ChatUtil.parse(Messages.ERROR_CANNOT_GET_TARGET_POSITION));
return;
}
Vector3d senderPos = senderTransform.getPosition().clone();
Vector3f senderRot = senderHeadRot != null ? senderHeadRot.getRotation().clone() : new Vector3f(0, 0, 0);
LocationData destination = new LocationData(senderWorld.getName(), senderPos.getX(), senderPos.getY(), senderPos.getZ(), senderRot.getPitch(), senderRot.getYaw());
Vector3d senderPos = new Vector3d(senderTransform.getPosition());
Rotation3f senderRot = senderHeadRot != null ? senderHeadRot.getRotation().clone() : new Rotation3f(0, 0, 0);
LocationData destination = new LocationData(senderWorld.getName(), senderPos.x(), senderPos.y(), senderPos.z(), senderRot.pitch(), senderRot.yaw());

warmupManager.startWarmup(playerRef, store, ref, world, destination, settings.getWarmupSeconds(), CooldownManager.TPA, senderPlayer.getUsername(), null);
senderPlayer.sendMessage(ChatUtil.parse(Messages.SUCCESS_TPA_ACCEPTED_NOTIFY, playerRef.getUsername()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
Expand Down Expand Up @@ -48,10 +48,10 @@ protected void execute(@Nonnull CommandContext context, @Nonnull Store<EntitySto
return;
}
HeadRotation headRotation = store.getComponent(ref, HeadRotation.getComponentType());
Vector3f rotation = headRotation != null ? headRotation.getRotation() : new Vector3f(0, 0, 0);
Rotation3f rotation = headRotation != null ? headRotation.getRotation() : new Rotation3f(0, 0, 0);
Vector3d position = transform.getPosition();
warpManager.setWarp(name, world, position, rotation);
context.sendMessage(ChatUtil.parse(Messages.SUCCESS_WARP_SET,
name, position.getX(), position.getY(), position.getZ(), world.getName()));
name, position.x(), position.y(), position.z(), world.getName()));
}
}
34 changes: 12 additions & 22 deletions src/main/java/dev/hytalemodding/hyssentials/data/LocationData.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.hytalemodding.hyssentials.data;

import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import javax.annotation.Nonnull;

public record LocationData(
Expand All @@ -16,32 +16,22 @@ public Vector3d toPosition() {
return new Vector3d(x, y + 1.0, z);
}

/**
* Returns body rotation for the Teleport component.
* Body rotation only uses yaw (horizontal facing direction), pitch is 0.
* Vector3f constructor is (pitch, yaw, roll).
*/
public Vector3f toBodyRotation() {
return new Vector3f(0.0f, yaw, 0.0f);
public Rotation3f toBodyRotation() {
return new Rotation3f(0.0f, yaw, 0.0f);
}

/**
* Returns head rotation for the Teleport.setHeadRotation() call.
* Head rotation uses both pitch (vertical look) and yaw (horizontal look).
* Vector3f constructor is (pitch, yaw, roll).
*/
public Vector3f toHeadRotation() {
return new Vector3f(pitch, yaw, 0.0f);
public Rotation3f toHeadRotation() {
return new Rotation3f(pitch, yaw, 0.0f);
}

public static LocationData from(String worldName, Vector3d position, Vector3f rotation) {
public static LocationData from(String worldName, Vector3d position, Rotation3f rotation) {
return new LocationData(
worldName,
position.getX(),
position.getY(),
position.getZ(),
rotation.getPitch(),
rotation.getYaw()
position.x(),
position.y(),
position.z(),
rotation.pitch(),
rotation.yaw()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void build(@Nonnull Ref<EntityStore> ref, @Nonnull UICommandBuilder cmd,
private void buildPlayerList(UICommandBuilder cmd, UIEventBuilder events, Store<EntityStore> store) {
cmd.clear("#PlayerList");

List<PlayerRef> allPlayers = Universe.get().getPlayers();
Collection<PlayerRef> allPlayers = Universe.get().getPlayers();
visiblePlayers.clear();

for (PlayerRef player : allPlayers) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.hytalemodding.hyssentials.manager;

import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import org.joml.Vector3d;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import dev.hytalemodding.hyssentials.data.LocationData;
Expand All @@ -25,7 +25,7 @@ public HomeManager(@Nonnull DataManager dataManager, @Nonnull RankManager rankMa
}

public boolean setHome(@Nonnull UUID playerUuid, @Nonnull String name, @Nonnull World world,
@Nonnull Vector3d position, @Nonnull Vector3f rotation, int effectiveMaxHomes) {
@Nonnull Vector3d position, @Nonnull Rotation3f rotation, int effectiveMaxHomes) {
Map<String, LocationData> homes = playerHomes.computeIfAbsent(playerUuid, k -> new ConcurrentHashMap<>());
String lowerName = name.toLowerCase();
if (!homes.containsKey(lowerName) && homes.size() >= effectiveMaxHomes) {
Expand Down
Loading