New API methods, refactor position object to use static creators

This commit is contained in:
William278 committed 2023-03-22 19:55:59 +00:00
1 parent 42adc13425
commit 6b8c515b61
42 files changed
+587 -232

No files matched your search

@@ -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;
}
}