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

This allows vanilla and third-party plugins to take over properly without the stuck-teleport or
something else to interfer with that.
This commit is contained in:
Christian Koop 2023-08-21 16:53:06 +02:00
parent 24dc591f75
commit 5711389549
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -76,7 +76,6 @@ public class PortalListeners implements Listener {
}
Island island = islandManager.getIslandAtLocation(player.getLocation());
if (island == null) {
return;
}
@ -96,6 +95,20 @@ public class PortalListeners implements Listener {
spawnEnvironment = IslandEnvironment.VISITOR;
}
IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld());
IslandWorld toWorld = IslandWorld.NORMAL;
if (block.getType() == XMaterial.NETHER_PORTAL.parseMaterial()) {
toWorld = fromWorld == IslandWorld.NETHER ? IslandWorld.NORMAL : IslandWorld.NETHER;
} else if (block.getType() == XMaterial.END_PORTAL.parseMaterial()) {
toWorld = fromWorld == IslandWorld.END ? IslandWorld.NORMAL : IslandWorld.END;
}
if (!configLoad.getBoolean("Island.World." + toWorld.getFriendlyName() + ".Enable")) {
// Skip any of our behavior if the target world is disabled (vanilla or third-party plugin might want to handle it)
return;
}
Tick tick;
if (!this.tickCounter.containsKey(player.getUniqueId())) {
tick = this.tickCounter.put(player.getUniqueId(), new Tick());
@ -123,29 +136,19 @@ public class PortalListeners implements Listener {
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation());
// Check permissions.
boolean perms = !this.plugin.getPermissionManager().processPermission(playerEnterPortalEvent,
player, island);
IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld());
IslandWorld toWorld = IslandWorld.NORMAL;
if (block.getType() == XMaterial.NETHER_PORTAL.parseMaterial()) {
toWorld = fromWorld == IslandWorld.NETHER ? IslandWorld.NORMAL : IslandWorld.NETHER;
} else if (block.getType() == XMaterial.END_PORTAL.parseMaterial()) {
toWorld = fromWorld == IslandWorld.END ? IslandWorld.NORMAL : IslandWorld.END;
}
boolean perms = !this.plugin.getPermissionManager().processPermission(playerEnterPortalEvent, player, island);
if (!perms) {
switch (toWorld) {
case END:
case NETHER:
if (configLoad.getBoolean("Island.World." + toWorld.getFriendlyName() + ".Enable") && island.isRegionUnlocked(player, toWorld)) {
if (island.isRegionUnlocked(player, toWorld)) {
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
}
break;
default:
IslandWorld toWorldF = toWorld;
final IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> PaperLib.teleportAsync(player, island.getLocation(toWorldF, spawnEnvironment)), 1L);
soundManager.playSound(player, XSound.ENTITY_ENDERMAN_TELEPORT);