From eaae2f4009a116d8e3cc030db9e068deb8862ba5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 17 Jan 2025 13:28:57 +0100 Subject: [PATCH] Adapt to new server, unlock old versions again --- .../de/steamwar/providers/BauServerInfo.java | 9 +----- VelocityCore/deployarena.py | 4 +-- .../steamwar/velocitycore/ServerStarter.java | 28 +++++++++++++------ .../steamwar/velocitycore/ServerVersion.java | 4 +-- .../velocitycore/commands/BauCommand.java | 2 +- .../commands/BuilderCloudCommand.java | 2 +- steamwarci.yml | 1 - 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/providers/BauServerInfo.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/providers/BauServerInfo.java index b7de60b1..ddc7839e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/providers/BauServerInfo.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/providers/BauServerInfo.java @@ -19,22 +19,15 @@ package de.steamwar.providers; -import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; -import java.util.UUID; - public class BauServerInfo { private static Integer bauOwner = null; static { try { bauOwner = Integer.parseInt(Bukkit.getWorlds().get(0).getName()); - } catch (NumberFormatException e) { - try { - bauOwner = SteamwarUser.get(UUID.fromString(Bukkit.getWorlds().get(0).getName())).getId(); - } catch (IllegalArgumentException ignored) {} - } + } catch (NumberFormatException ignored) {} } public static Integer getOwnerId() { diff --git a/VelocityCore/deployarena.py b/VelocityCore/deployarena.py index d058b8e4..2195e264 100755 --- a/VelocityCore/deployarena.py +++ b/VelocityCore/deployarena.py @@ -37,11 +37,11 @@ if __name__ == "__main__": with open(configfile, 'r') as file: gamemode = yaml.load(file) - builderworld = path.expanduser(f'~/builder{version}/{worldname}') + builderworld = path.expanduser(f'/worlds/builder{version}/{worldname}') arenaworld = f'/servers/{gamemode["Server"]["Folder"]}/arenas/{worldname}' if path.exists(arenaworld): - backupworld = path.expanduser(f'~/backup/arenas/{datetime.datetime.now()}-{worldname}-{version}.tar.xz') + backupworld = path.expanduser(f'/mnt/storage/backup/arenas/{datetime.datetime.now()}-{worldname}-{version}.tar.xz') with tarfile.open(backupworld, 'w:xz') as tar: tar.add(arenaworld, arcname=worldname) diff --git a/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java b/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java index ce3b5240..67567ae9 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ServerStarter.java @@ -46,13 +46,17 @@ public class ServerStarter { private static final Portrange ARENA_PORTS = VelocityCore.MAIN_SERVER ? new Portrange(3000, 3100) : (VelocityCore.get().getConfig().isEventmode() ? new Portrange(4000, 5000) : BAU_PORTS); public static final String SERVER_PATH = "/servers/"; - private static final String USER_HOME = System.getProperty("user.home") + "/"; - private static final String EVENT_PATH = USER_HOME + "event/"; - public static final String TEMP_WORLD_PATH = USER_HOME + "arenaserver/"; - public static final String TUTORIAL_PATH = "/worlds/tutorials/"; - public static final String WORLDS_BASE_PATH = "/worlds/userworlds"; - public static final String BUILDER_BASE_PATH = "/worlds/builder"; + private static final String TMP_DATA = System.getProperty("user.home") + "/"; + private static final String EVENT_PATH = TMP_DATA + "event/"; + public static final String TEMP_WORLD_PATH = TMP_DATA + "arenaserver/"; + + private static final String WORLDS_FOLDER = "/worlds"; + public static final String TUTORIAL_PATH = WORLDS_FOLDER + "/tutorials/"; + public static final String WORLDS_BASE_PATH = WORLDS_FOLDER + "/userworlds"; + public static final String BUILDER_BASE_PATH = WORLDS_FOLDER + "/builder"; + + private static final String WORLDS_STORAGE_BASE_PATH = "/mnt/storage/worlds/userworlds"; private File directory = null; private String worldDir = null; @@ -149,15 +153,21 @@ public class ServerStarter { this.version = version; directory = version.getServerDirectory("Bau"); worldDir = version.getWorldFolder(WORLDS_BASE_PATH); - worldName = version != ServerVersion.SPIGOT_12 ? String.valueOf(SteamwarUser.get(owner).getId()) : owner.toString(); + worldName = String.valueOf(SteamwarUser.get(owner).getId()); checkpoint = true; build(owner); worldSetup = () -> { File world = new File(worldDir, worldName); - if (!world.exists()) - copyWorld(node, new File(directory, "Bauwelt").getPath(), world.getPath()); + if (!world.exists()) { + File storage = new File(version.getWorldFolder(WORLDS_STORAGE_BASE_PATH), worldName); + + if(storage.exists()) + node.execute("mv", storage.getPath(), world.getPath()); + else + copyWorld(node, new File(directory, "Bauwelt").getPath(), world.getPath()); + } }; // Send players to existing server diff --git a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java index 093933bc..cc7c9d38 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java +++ b/VelocityCore/src/de/steamwar/velocitycore/ServerVersion.java @@ -65,7 +65,7 @@ public enum ServerVersion { chatMap.put("mwg", ServerVersion.PAPER_20); chatMap.put("miniwargear", ServerVersion.PAPER_20); - /*chatMap.put("19", ServerVersion.PAPER_19); + chatMap.put("19", ServerVersion.PAPER_19); chatMap.put("1.19", ServerVersion.PAPER_19); chatMap.put("1.19.2", ServerVersion.PAPER_19); @@ -75,7 +75,7 @@ public enum ServerVersion { chatMap.put("12", ServerVersion.SPIGOT_12); chatMap.put("1.12", ServerVersion.SPIGOT_12); - chatMap.put("1.12.2", ServerVersion.SPIGOT_12);*/ + chatMap.put("1.12.2", ServerVersion.SPIGOT_12); } public static ServerVersion get(String chat) { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java index 150df3fd..710bb1be 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BauCommand.java @@ -214,7 +214,7 @@ public class BauCommand extends SWCommand { public void delete(PlayerChatter sender, @OptionalValue(value = "", onlyUINIG = true) ServerVersion version) { SWInventory inventory = new SWInventory(sender, 9, new Message("BAU_DELETE_GUI_NAME")); inventory.addItem(0, new SWItem(new Message("BAU_DELETE_GUI_DELETE"), 10), click -> { - String world = version.getWorldFolder(ServerStarter.WORLDS_BASE_PATH) + (version != ServerVersion.SPIGOT_12 ? sender.user().getId() : sender.user().getUUID().toString()); + String world = version.getWorldFolder(ServerStarter.WORLDS_BASE_PATH) + sender.user().getId(); VelocityCore.schedule(() -> { Bauserver subserver = Bauserver.get(sender.user().getUUID()); diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java index 4c5c115d..51c0f1bf 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/BuilderCloudCommand.java @@ -90,7 +90,7 @@ public class BuilderCloudCommand extends SWCommand { } VelocityCore.schedule(() -> { - VelocityCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map); + VelocityCore.local.execute("deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map); ArenaMode.init(); sender.system("BUILDERCLOUD_DEPLOY_FINISHED"); }).schedule(); diff --git a/steamwarci.yml b/steamwarci.yml index 1e2f6eed..0fa07cde 100644 --- a/steamwarci.yml +++ b/steamwarci.yml @@ -1,5 +1,4 @@ build: - - "printenv" - "./gradlew build --no-daemon"