From def099c3a33f4de3e9551fdddc09b2cf5c1f845d Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 8 Apr 2022 01:06:34 -0500 Subject: [PATCH] Band aid fix --- .../dev/plex/listener/impl/WorldListener.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/plex/listener/impl/WorldListener.java b/src/main/java/dev/plex/listener/impl/WorldListener.java index a5c223b..83a0930 100644 --- a/src/main/java/dev/plex/listener/impl/WorldListener.java +++ b/src/main/java/dev/plex/listener/impl/WorldListener.java @@ -1,6 +1,7 @@ package dev.plex.listener.impl; import dev.plex.Plex; +import dev.plex.cache.DataUtils; import dev.plex.cache.player.PlayerCache; import dev.plex.listener.PlexListener; import dev.plex.player.PlexPlayer; @@ -12,6 +13,7 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -19,11 +21,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import org.jetbrains.annotations.NotNull; public class WorldListener extends PlexListener { - @EventHandler public void onBlockPlace(BlockPlaceEvent e) { @@ -118,6 +121,18 @@ public class WorldListener extends PlexListener e.setCancelled(true); } + // TODO: Add an entry setting in the config.yml and allow checking for all worlds + @EventHandler + public void onWorldTeleport(PlayerTeleportEvent e) + { + final World adminworld = Bukkit.getWorld("adminworld"); + PlexPlayer plexPlayer = DataUtils.getPlayer(e.getPlayer().getUniqueId()); + if (e.getTo().getWorld().equals(adminworld) && !plexPlayer.isAdminActive()) + { + e.setCancelled(true); + } + } + private boolean checkLevel(PlexPlayer player, String[] requiredList) { PlexLog.debug("Checking world required levels " + Arrays.toString(requiredList));