Refactor #getServer() to be pre-cached from a CachedServer yaml file, no longer require fetcher, add #fetchServer(requester)

This commit is contained in:
William committed 2022-08-31 11:55:47 +01:00
1 parent 800bffbbf2
commit 74cb268426
11 files changed
+105 -45

No files matched your search

@@ -0,0 +1,32 @@
package net.william278.huskhomes.config;
import net.william278.annotaml.YamlFile;
import net.william278.huskhomes.position.Server;
import org.jetbrains.annotations.NotNull;
@YamlFile(header = """
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Server ID cache. Must match ┃
┃ server name in proxy config. ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛""")
public class CachedServer {
/**
* Name of the server (must match proxy config ID)
*/
public String serverName;
public CachedServer(@NotNull String serverName) {
this.serverName = serverName;
}
@SuppressWarnings("unused")
public CachedServer() {
}
@NotNull
public Server getServer() {
return new Server(serverName);
}
}
@@ -15,10 +15,10 @@ import java.util.UUID;
*/
@YamlFile(header = """
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Server /spawn location ┃
┃ Server /spawn location cache ┃
┃ Edit in-game using /setspawn ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛""")
public class Spawn {
public class CachedSpawn {
public double x;
public double y;
@@ -47,7 +47,7 @@ public class Spawn {
*
* @param location The {@link Location} of the spawn
*/
public Spawn(@NotNull Location location) {
public CachedSpawn(@NotNull Location location) {
this.x = location.x;
this.y = location.y;
this.z = location.z;
@@ -58,6 +58,6 @@ public class Spawn {
}
@SuppressWarnings("unused")
public Spawn() {
public CachedSpawn() {
}
}