From d3662918c29e0fbd5c34e5163a6736d9b7e4be08 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Wed, 28 Oct 2020 18:44:31 +0100 Subject: [PATCH] Don't TP players when plugin is unloading --- .../main/java/de/erethon/dungeonsxl/DungeonsXL.java | 11 ++++++++++- .../de/erethon/dungeonsxl/command/StatusCommand.java | 2 +- .../de/erethon/dungeonsxl/world/DInstanceWorld.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java b/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java index a6197ac3..b3bfb952 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java +++ b/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java @@ -243,12 +243,12 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI { if (!loaded) { return; } + loaded = false; saveData(); deleteAllInstances(); HandlerList.unregisterAll(this); getServer().getScheduler().cancelTasks(this); DPermission.unregister(); - loaded = false; } public void initFolders() { @@ -560,6 +560,15 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI { return groupAdapters; } + /** + * Returns true if the plugin is not currently in the process of enabling or disabling or entirely disabled, otherwise false. + * + * @return true if the plugin is not currently in the process of enabling or disabling or entirely disabled, otherwise false + */ + public boolean isLoaded() { + return loaded; + } + /** * Returns true if the plugin is currently loading a world, false if not. *

diff --git a/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java b/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java index b62c932e..c4a6c341 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java +++ b/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java @@ -38,7 +38,7 @@ public class StatusCommand extends DCommand { public static final String TRUE = ChatColor.GREEN + "\u2714"; public static final String FALSE = ChatColor.DARK_RED + "\u2718"; - public static final String LATEST_IXL = "0.6.2"; + public static final String LATEST_IXL = "0.6.3"; public StatusCommand(DungeonsXL plugin) { super(plugin); diff --git a/core/src/main/java/de/erethon/dungeonsxl/world/DInstanceWorld.java b/core/src/main/java/de/erethon/dungeonsxl/world/DInstanceWorld.java index 8a6a17a6..07f7b7d7 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/world/DInstanceWorld.java +++ b/core/src/main/java/de/erethon/dungeonsxl/world/DInstanceWorld.java @@ -169,7 +169,7 @@ public abstract class DInstanceWorld implements InstanceWorld { public void kickAllPlayers() { getPlayers().forEach(p -> p.leave()); // Players who shouldn't be in the dungeon but still are for some reason - if (world != null) { + if (plugin.isLoaded() && world != null) { getWorld().getPlayers().forEach(p -> p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation())); } }