mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Simplify server logic
This commit is contained in:
1 parent
eb4652d6ff
commit
c1b499f7b2
2 files changed
+20
-7
No files matched your search
@@ -4,6 +4,8 @@ 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
|
||||
*/
|
||||
@@ -17,19 +19,27 @@ public class Server {
|
||||
/**
|
||||
* Default (unknown) server identifier
|
||||
*/
|
||||
public static final Server DEFAULT = new Server();
|
||||
public static Server getDefault() {
|
||||
final Server server = new Server();
|
||||
try {
|
||||
final Path serverDirectory = Path.of(System.getProperty("user.dir"));
|
||||
server.name = serverDirectory.getFileName().toString().trim();
|
||||
} catch (Exception e) {
|
||||
server.name = "server";
|
||||
}
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy-defined name of this server
|
||||
*/
|
||||
@YamlKey("server_name")
|
||||
public String name = "server";
|
||||
public String name = getDefault().name;
|
||||
|
||||
public Server(@NotNull String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Server() {
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user