From 820275498830e109f63f00024370ff20e08fa7d4 Mon Sep 17 00:00:00 2001 From: RePixelatedMC Date: Fri, 6 Oct 2023 10:30:24 +0200 Subject: [PATCH] remove world to worldmanager --- .../iris/core/commands/CommandIris.java | 34 ------------------ .../core/commands/CommandWorldManager.java | 35 ++++++++++++++++++- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/commands/CommandIris.java b/src/main/java/com/volmit/iris/core/commands/CommandIris.java index e2bc3e07d..507e58365 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -44,7 +44,6 @@ import org.bukkit.Chunk; import org.bukkit.World; import java.io.File; -import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -108,39 +107,6 @@ public class CommandIris implements DecreeExecutor { sender().sendMessage(C.GREEN + "Successfully created your world!"); } - @Decree(description = "Remove an Iris world", aliases = {"del", "rm"}, sync = true) - public void remove( - @Param(description = "The world to remove") - World world, - @Param(description = "Whether to also remove the folder (if set to false, just does not load the world)", defaultValue = "true") - boolean delete - ) { - if (!IrisToolbelt.isIrisWorld(world)) { - sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList())); - return; - } - sender().sendMessage(C.GREEN + "Removing world: " + world.getName()); - try { - if (IrisToolbelt.removeWorld(world)) { - sender().sendMessage(C.GREEN + "Successfully removed " + world.getName() + " from bukkit.yml"); - } else { - sender().sendMessage(C.YELLOW + "Looks like the world was already removed from bukkit.yml"); - } - } catch (IOException e) { - sender().sendMessage(C.RED + "Failed to save bukkit.yml because of " + e.getMessage()); - e.printStackTrace(); - } - IrisToolbelt.evacuate(world, "Deleting world"); - Bukkit.unloadWorld(world, false); - if (delete) { - if (world.getWorldFolder().delete()) { - sender().sendMessage(C.GREEN + "Successfully removed world folder"); - } else { - sender().sendMessage(C.RED + "Failed to remove world folder"); - } - } - } - @Decree(description = "Print version information") public void version() { sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); diff --git a/src/main/java/com/volmit/iris/core/commands/CommandWorldManager.java b/src/main/java/com/volmit/iris/core/commands/CommandWorldManager.java index 3ed2bbadc..735669c89 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandWorldManager.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandWorldManager.java @@ -74,7 +74,7 @@ public class CommandWorldManager implements DecreeExecutor { } } - @Decree(description = "Load an Iris World", origin = DecreeOrigin.PLAYER, sync = true) + @Decree(description = "Load an Iris World", origin = DecreeOrigin.PLAYER, sync = true, aliases = "import") public void loadworld( @Param(description = "The name of the world to load") String world @@ -144,6 +144,39 @@ public class CommandWorldManager implements DecreeExecutor { IrisToolbelt.evacuate(world); } + @Decree(description = "Remove an Iris world", aliases = {"del", "rm"}, sync = true) + public void remove( + @Param(description = "The world to remove") + World world, + @Param(description = "Whether to also remove the folder (if set to false, just does not load the world)", defaultValue = "true") + boolean delete + ) { + if (!IrisToolbelt.isIrisWorld(world)) { + sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList())); + return; + } + sender().sendMessage(C.GREEN + "Removing world: " + world.getName()); + try { + if (IrisToolbelt.removeWorld(world)) { + sender().sendMessage(C.GREEN + "Successfully removed " + world.getName() + " from bukkit.yml"); + } else { + sender().sendMessage(C.YELLOW + "Looks like the world was already removed from bukkit.yml"); + } + } catch (IOException e) { + sender().sendMessage(C.RED + "Failed to save bukkit.yml because of " + e.getMessage()); + e.printStackTrace(); + } + IrisToolbelt.evacuate(world, "Deleting world"); + Bukkit.unloadWorld(world, false); + if (delete) { + if (world.getWorldFolder().delete()) { + sender().sendMessage(C.GREEN + "Successfully removed world folder"); + } else { + sender().sendMessage(C.RED + "Failed to remove world folder"); + } + } + } + public static boolean doesWorldExist(String worldName) { File worldContainer = Bukkit.getWorldContainer(); File worldDirectory = new File(worldContainer, worldName);