mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-27 11:37:47 +01:00
Get the session during the gamemode event lazily.
This commit is contained in:
parent
ec5bb32510
commit
a277e69e9c
@ -31,6 +31,7 @@
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.GameModeFlag;
|
||||
import com.sk89q.worldguard.util.command.CommandFilter;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -84,7 +85,9 @@ public void registerEvents() {
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
|
||||
GameModeFlag handler = plugin.getSessionManager().get(player).getHandler(GameModeFlag.class);
|
||||
Session session = plugin.getSessionManager().getIfPresent(player);
|
||||
if (session != null) {
|
||||
GameModeFlag handler = session.getHandler(GameModeFlag.class);
|
||||
if (handler != null && wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
|
||||
GameMode expected = handler.getSetGameMode();
|
||||
if (handler.getOriginalGameMode() != null && expected != null && expected != event.getNewGameMode()) {
|
||||
@ -93,6 +96,7 @@ public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
|
Loading…
Reference in New Issue
Block a user