Don't handle PortalTeleportEvent when target world is disabled in config

Related to 5711389549
This commit is contained in:
Christian Koop 2023-08-21 18:18:22 +02:00
parent 5711389549
commit b2b3b3d976
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
2 changed files with 38 additions and 17 deletions

View File

@ -20,23 +20,6 @@ public enum IslandWorld {
return this.friendlyName;
}
public static List<IslandWorld> getIslandWorlds() {
List<IslandWorld> islandWorlds = new ArrayList<>(3);
WorldManager worldManager = SkyBlock.getPlugin(SkyBlock.class).getWorldManager();
if (worldManager.getWorld(NORMAL) != null) {
islandWorlds.add(NORMAL);
}
if (worldManager.getWorld(NETHER) != null) {
islandWorlds.add(NETHER);
}
if (worldManager.getWorld(END) != null) {
islandWorlds.add(END);
}
return islandWorlds;
}
public Environment getUncheckedEnvironment() {
switch (this) {
case NORMAL:
@ -64,4 +47,34 @@ public enum IslandWorld {
return null;
}
public static List<IslandWorld> getIslandWorlds() {
List<IslandWorld> islandWorlds = new ArrayList<>(3);
WorldManager worldManager = SkyBlock.getPlugin(SkyBlock.class).getWorldManager();
if (worldManager.getWorld(NORMAL) != null) {
islandWorlds.add(NORMAL);
}
if (worldManager.getWorld(NETHER) != null) {
islandWorlds.add(NETHER);
}
if (worldManager.getWorld(END) != null) {
islandWorlds.add(END);
}
return islandWorlds;
}
public static IslandWorld getByEnvironment(Environment environment) {
switch (environment) {
case NORMAL:
return IslandWorld.NORMAL;
case NETHER:
return IslandWorld.NETHER;
case THE_END:
return IslandWorld.END;
default:
return null;
}
}
}

View File

@ -194,6 +194,14 @@ public class TeleportListeners implements Listener {
return;
}
IslandWorld toIslandWorld = IslandWorld.getByEnvironment(to.getWorld().getEnvironment());
FileConfiguration configLoad = this.plugin.getConfiguration();
if (toIslandWorld == null || !configLoad.getBoolean("Island.World." + toIslandWorld.getFriendlyName() + ".Enable")) {
// Skip any of our behavior if the target world is disabled (vanilla or third-party plugin might want to handle it)
return;
}
if (worldManager.getIslandWorld(e.getFrom().getWorld()) != null) {
e.setCancelled(true);
}