mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 22:16:34 +00:00
New API methods, refactor position object to use static creators
This commit is contained in:
1 parent
42adc13425
commit
6b8c515b61
42 files changed
+587
-232
No files matched your search
@@ -172,4 +172,14 @@ public class Locales {
|
||||
.setSpaceBeforeFooter(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents where a locale should be displayed
|
||||
*/
|
||||
public enum DisplaySlot {
|
||||
CHAT,
|
||||
ACTION_BAR,
|
||||
SUBTITLE,
|
||||
TITLE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.william278.huskhomes.config;
|
||||
|
||||
import net.william278.annotaml.YamlFile;
|
||||
import net.william278.annotaml.YamlKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Represents a server on a proxied network
|
||||
*/
|
||||
@YamlFile(header = """
|
||||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ Server ID cache. Must match ┃
|
||||
┃ server name in proxy config. ┃
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛""")
|
||||
public class Server {
|
||||
|
||||
/**
|
||||
* Default server identifier
|
||||
*/
|
||||
@NotNull
|
||||
public static String getDefaultServerName() {
|
||||
try {
|
||||
final Path serverDirectory = Path.of(System.getProperty("user.dir"));
|
||||
return serverDirectory.getFileName().toString().trim();
|
||||
} catch (Exception e) {
|
||||
return "server";
|
||||
}
|
||||
}
|
||||
|
||||
@YamlKey("server_name")
|
||||
private String name = getDefaultServerName();
|
||||
|
||||
public Server(@NotNull String name) {
|
||||
this.setName(name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Server() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@NotNull Object other) {
|
||||
// If the name of this server matches another, the servers are the same.
|
||||
if (other instanceof Server server) {
|
||||
return server.getName().equalsIgnoreCase(this.getName());
|
||||
}
|
||||
return super.equals(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy-defined name of this server
|
||||
*/
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class Settings {
|
||||
private int maxPublicHomes = 10;
|
||||
|
||||
@YamlKey("general.stack_permission_limits")
|
||||
private boolean stackPermissionLimits = true;
|
||||
private boolean stackPermissionLimits = false;
|
||||
|
||||
@YamlKey("general.permission_restrict_warps")
|
||||
private boolean permissionRestrictWarps = false;
|
||||
@@ -112,7 +112,7 @@ public class Settings {
|
||||
private int teleportWarmupTime = 5;
|
||||
|
||||
@YamlKey("general.teleport_warmup_display")
|
||||
private MessageDisplayType teleportWarmupDisplay = MessageDisplayType.ACTION_BAR;
|
||||
private Locales.DisplaySlot teleportWarmupDisplay = Locales.DisplaySlot.ACTION_BAR;
|
||||
|
||||
@YamlKey("general.teleport_request_expiry_time")
|
||||
private int teleportRequestExpiryTime = 60;
|
||||
@@ -351,7 +351,7 @@ public class Settings {
|
||||
return teleportWarmupTime;
|
||||
}
|
||||
|
||||
public MessageDisplayType getTeleportWarmupDisplay() {
|
||||
public Locales.DisplaySlot getTeleportWarmupDisplay() {
|
||||
return teleportWarmupDisplay;
|
||||
}
|
||||
|
||||
@@ -503,16 +503,6 @@ public class Settings {
|
||||
return brigadierTabCompletion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents where a chat message should display
|
||||
*/
|
||||
public enum MessageDisplayType {
|
||||
MESSAGE,
|
||||
ACTION_BAR,
|
||||
SUBTITLE,
|
||||
TITLE
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the sound effect to play when an action happens
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Spawn {
|
||||
*/
|
||||
@NotNull
|
||||
public Position getPosition(@NotNull String server) {
|
||||
return new Position(x, y, z, yaw, pitch, new World(worldName, UUID.fromString(worldUuid)), server);
|
||||
return Position.at(x, y, z, yaw, pitch, World.from(worldName, UUID.fromString(worldUuid)), server);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user