mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-26 20:26:34 +01:00
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:
parent
24dc591f75
commit
5711389549
@ -76,7 +76,6 @@ public class PortalListeners implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||||
|
|
||||||
if (island == null) {
|
if (island == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -96,6 +95,20 @@ public class PortalListeners implements Listener {
|
|||||||
spawnEnvironment = IslandEnvironment.VISITOR;
|
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;
|
Tick tick;
|
||||||
if (!this.tickCounter.containsKey(player.getUniqueId())) {
|
if (!this.tickCounter.containsKey(player.getUniqueId())) {
|
||||||
tick = this.tickCounter.put(player.getUniqueId(), new Tick());
|
tick = this.tickCounter.put(player.getUniqueId(), new Tick());
|
||||||
@ -123,29 +136,19 @@ public class PortalListeners implements Listener {
|
|||||||
|
|
||||||
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation());
|
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation());
|
||||||
// Check permissions.
|
// Check permissions.
|
||||||
boolean perms = !this.plugin.getPermissionManager().processPermission(playerEnterPortalEvent,
|
boolean perms = !this.plugin.getPermissionManager().processPermission(playerEnterPortalEvent, player, island);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!perms) {
|
if (!perms) {
|
||||||
switch (toWorld) {
|
switch (toWorld) {
|
||||||
case END:
|
case END:
|
||||||
case NETHER:
|
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);
|
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
IslandWorld toWorldF = toWorld;
|
final IslandWorld toWorldF = toWorld;
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> PaperLib.teleportAsync(player, island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> PaperLib.teleportAsync(player, island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||||
soundManager.playSound(player, XSound.ENTITY_ENDERMAN_TELEPORT);
|
soundManager.playSound(player, XSound.ENTITY_ENDERMAN_TELEPORT);
|
||||||
|
Loading…
Reference in New Issue
Block a user