From 5d1e8df1138352c2486e98e62812557b1f859c72 Mon Sep 17 00:00:00 2001 From: Chaos Date: Sat, 29 Jan 2022 15:30:37 +0100 Subject: [PATCH] Refactor to BauServerInfo --- .../src/de/steamwar/bausystem/BauSystem.java | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/BauSystem_Core/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Core/src/de/steamwar/bausystem/BauSystem.java index acfc2c4..d1a355f 100644 --- a/BauSystem_Core/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Core/src/de/steamwar/bausystem/BauSystem.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.commands.*; import de.steamwar.bausystem.world.*; import de.steamwar.bausystem.world.regions.Region; import de.steamwar.core.Core; +import de.steamwar.providers.BauServerInfo; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; @@ -47,7 +48,7 @@ import java.util.logging.Level; public class BauSystem extends JavaPlugin implements Listener { private static BauSystem plugin; - private static UUID owner; + private static Integer owner; public static final String PREFIX = "§eBauSystem§8» §7"; private BukkitTask autoShutdown; @@ -56,12 +57,6 @@ public class BauSystem extends JavaPlugin implements Listener { public void onEnable() { plugin = this; - try { - owner = UUID.fromString(Bukkit.getWorlds().get(0).getName()); - } catch (IllegalArgumentException e) { - owner = null; - } - Mapper.init(); new CommandTrace(); @@ -125,20 +120,15 @@ public class BauSystem extends JavaPlugin implements Listener { } public static 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 static 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; } @EventHandler