mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Add /setspawn and /spawn
This commit is contained in:
1 parent
560d701113
commit
8adbc49a61
10 files changed
+198
-17
No files matched your search
@@ -0,0 +1,63 @@
|
||||
package net.william278.huskhomes.config;
|
||||
|
||||
import net.william278.annotaml.YamlFile;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.position.Server;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Used to store the server spawn location
|
||||
*/
|
||||
@YamlFile(header = """
|
||||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ Server /spawn location. ┃
|
||||
┃ Edit in-game with /setspawn. ┃
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛""")
|
||||
public class Spawn {
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public String worldName;
|
||||
public String worldUuid;
|
||||
|
||||
/**
|
||||
* Returns the {@link Position} of the spawn
|
||||
*
|
||||
* @return The {@link Position} of the spawn
|
||||
*/
|
||||
public Optional<Position> getLocation(@NotNull Server server) {
|
||||
try {
|
||||
return Optional.of(new Position(x, y, z, yaw, pitch,
|
||||
new World(worldName, UUID.fromString(worldUuid)), server));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link Location} of the spawn
|
||||
*
|
||||
* @param location The {@link Location} of the spawn
|
||||
*/
|
||||
public Spawn(@NotNull Location location) {
|
||||
this.x = location.x;
|
||||
this.y = location.y;
|
||||
this.z = location.z;
|
||||
this.yaw = location.yaw;
|
||||
this.pitch = location.pitch;
|
||||
this.worldName = location.world.name;
|
||||
this.worldUuid = location.world.uuid.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Spawn() {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user