SteamWar/BauSystem2.0
Archiviert
12
0

Refactor BauServer.java
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaos 2022-01-29 15:23:15 +01:00
Ursprung 92c4d7a7e2
Commit 2c58329ca2

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.config;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.providers.BauServerInfo;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -35,30 +36,19 @@ public class BauServer {
public BauServer() { public BauServer() {
instance = this; instance = this;
try {
owner = UUID.fromString(Bukkit.getWorlds().get(0).getName());
} catch (IllegalArgumentException e) {
owner = null;
}
} }
private UUID owner; private Integer owner;
public UUID getOwner() { public UUID getOwner() {
//Lazy loading to improve startup time of the server in 1.15 return SteamwarUser.get(getOwnerID()).getUUID();
if (owner == null) {
try {
owner = SteamwarUser.get(Integer.parseInt(Bukkit.getWorlds().get(0).getName())).getUUID();
} catch (NumberFormatException e) {
Bukkit.shutdown();
throw new SecurityException("owner is not a UserID", e);
}
}
return owner;
} }
public int getOwnerID() { public int getOwnerID() {
return SteamwarUser.get(getOwner()).getId(); //Lazy loading to improve startup time of the server in 1.15
if (owner == null) {
owner = BauServerInfo.getOwnerId();
}
return owner;
} }
} }