From 2c58329ca266026d942ab028060859cc96f64a66 Mon Sep 17 00:00:00 2001 From: Chaos Date: Sat, 29 Jan 2022 15:23:15 +0100 Subject: [PATCH] Refactor BauServer.java --- .../steamwar/bausystem/config/BauServer.java | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java b/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java index 804705c9..bd4fdd2d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.config; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.providers.BauServerInfo; import de.steamwar.sql.SteamwarUser; import lombok.Getter; import org.bukkit.Bukkit; @@ -35,30 +36,19 @@ public class BauServer { public BauServer() { 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() { - //Lazy loading to improve startup time of the server in 1.15 - 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; + return SteamwarUser.get(getOwnerID()).getUUID(); } 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; } } \ No newline at end of file