From 6bc57c255fbe26cbd94650d955f8777455faa3e2 Mon Sep 17 00:00:00 2001 From: Vatuu <21113232+Vatuu@users.noreply.github.com> Date: Sat, 16 Jul 2022 02:52:06 +0200 Subject: [PATCH 1/4] Revert "Added convenience command." This reverts commit 6b32eb3441a9d5c13c282a0bbeadcd60c94d85b9. --- .../java/com/volmit/iris/core/commands/CommandIris.java | 8 +------- src/main/resources/plugin.yml | 2 +- 2 files changed, 2 insertions(+), 8 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 c332e34cc..382bef832 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -45,7 +45,7 @@ import java.io.File; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -@Decree(name = "iris", aliases = {"ir", "irs", "i"}, description = "Basic Command") +@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command") public class CommandIris implements DecreeExecutor { private CommandStudio studio; private CommandPregen pregen; @@ -107,12 +107,6 @@ public class CommandIris implements DecreeExecutor { sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight())); } - @Decree(description = "QOL command to open a overworld studio world.") - public void so() { - sender().sendMessage(C.GREEN + "Opening studio for the \"Overworld\" pack (seed: 1337)"); - Iris.service(StudioSVC.class).open(sender(), 1337, "overworld"); - } - @Decree(description = "Set aura spins") public void aura( @Param(description = "The h color value", defaultValue = "-20") diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 807e2a6fe..f00299923 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -19,7 +19,7 @@ libraries: - bsf:bsf:2.4.0 commands: iris: - aliases: [ ir, irs, i ] + aliases: [ ir, irs ] api-version: ${apiversion} hotload-dependencies: false softdepend: [ "Oraxen", "ItemsAdder", "IrisFeller", "WorldEdit", "PlaceholderAPI"] \ No newline at end of file From 3d7c5b050af5f0ededa3bd02e002cbee149561d5 Mon Sep 17 00:00:00 2001 From: Vatuu <21113232+Vatuu@users.noreply.github.com> Date: Sat, 16 Jul 2022 02:52:06 +0200 Subject: [PATCH 2/4] Revert "Revert "Added convenience command."" This reverts commit 6bc57c255fbe26cbd94650d955f8777455faa3e2. --- .../java/com/volmit/iris/core/commands/CommandIris.java | 8 +++++++- src/main/resources/plugin.yml | 2 +- 2 files changed, 8 insertions(+), 2 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 382bef832..c332e34cc 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -45,7 +45,7 @@ import java.io.File; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command") +@Decree(name = "iris", aliases = {"ir", "irs", "i"}, description = "Basic Command") public class CommandIris implements DecreeExecutor { private CommandStudio studio; private CommandPregen pregen; @@ -107,6 +107,12 @@ public class CommandIris implements DecreeExecutor { sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight())); } + @Decree(description = "QOL command to open a overworld studio world.") + public void so() { + sender().sendMessage(C.GREEN + "Opening studio for the \"Overworld\" pack (seed: 1337)"); + Iris.service(StudioSVC.class).open(sender(), 1337, "overworld"); + } + @Decree(description = "Set aura spins") public void aura( @Param(description = "The h color value", defaultValue = "-20") diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f00299923..807e2a6fe 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -19,7 +19,7 @@ libraries: - bsf:bsf:2.4.0 commands: iris: - aliases: [ ir, irs ] + aliases: [ ir, irs, i ] api-version: ${apiversion} hotload-dependencies: false softdepend: [ "Oraxen", "ItemsAdder", "IrisFeller", "WorldEdit", "PlaceholderAPI"] \ No newline at end of file From e0f0aaf76757de3ff4748f6dc80f9d781acd8c17 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 16 Jul 2022 12:36:28 +0200 Subject: [PATCH 3/4] Add remove command --- .../iris/core/commands/CommandIris.java | 33 +++++++++++++++++++ .../volmit/iris/core/tools/IrisCreator.java | 14 ++++++++ .../volmit/iris/core/tools/IrisToolbelt.java | 6 +++- 3 files changed, 52 insertions(+), 1 deletion(-) 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 c332e34cc..dbc0d22aa 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -38,10 +38,12 @@ import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.jobs.QueueJob; +import org.bukkit.Bukkit; 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; @@ -96,6 +98,37 @@ public class CommandIris implements DecreeExecutor { sender().sendMessage(C.GREEN + "Successfully created your world!"); } + @Decree(description = "Remove an Iris world", aliases = {"del", "rm"}) + 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 && 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/tools/IrisCreator.java b/src/main/java/com/volmit/iris/core/tools/IrisCreator.java index f6d2244f2..d4e418514 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisCreator.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisCreator.java @@ -231,4 +231,18 @@ public class IrisCreator { } } } + + public static boolean removeFromBukkitYml(String name) throws IOException { + YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML); + ConfigurationSection section = yml.getConfigurationSection("worlds"); + if (section == null) { + return false; + } + section.set(name, null); + if (section.getValues(false).keySet().stream().noneMatch(k -> section.get(k) != null)) { + yml.set("worlds", null); + } + yml.save(BUKKIT_YML); + return true; + } } diff --git a/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java b/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java index ece0c942d..c2da5a844 100644 --- a/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java +++ b/src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java @@ -36,6 +36,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import java.io.File; +import java.io.IOException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -221,7 +222,6 @@ public class IrisToolbelt { new VolmitSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world. " + m); j.teleport(i.getSpawnLocation()); } - return true; } } @@ -248,4 +248,8 @@ public class IrisToolbelt { if(e == null) {return;} e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of); } + + public static boolean removeWorld(World world) throws IOException { + return IrisCreator.removeFromBukkitYml(world.getName()); + } } From 6a37ab7af23e56e6899546273024b229e8186445 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 16 Jul 2022 12:39:42 +0200 Subject: [PATCH 4/4] sync world unload --- src/main/java/com/volmit/iris/core/commands/CommandIris.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 dbc0d22aa..0e66dad1e 100644 --- a/src/main/java/com/volmit/iris/core/commands/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/commands/CommandIris.java @@ -98,7 +98,7 @@ public class CommandIris implements DecreeExecutor { sender().sendMessage(C.GREEN + "Successfully created your world!"); } - @Decree(description = "Remove an Iris world", aliases = {"del", "rm"}) + @Decree(description = "Remove an Iris world", aliases = {"del", "rm"}, sync = true) public void remove( @Param(description = "The world to remove") World world,