From 5eaea8a31bfb27c1684cf0994da30ea799a5e4e1 Mon Sep 17 00:00:00 2001 From: Dico Karssiens Date: Sat, 12 Jan 2019 17:50:46 +0000 Subject: [PATCH] [Core] Fix listener to actually use guest gamemode flag (#2231) * Fix gamemode flag being used as guest gamemode flag * Remove redundant gamemode flag check --- .../plotsquared/listener/PlotListener.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index c6a687125..486dbe22c 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -87,28 +87,31 @@ public class PlotListener { player.setFlight(flyFlag.get()); } } - Optional gamemodeFlag = plot.getFlag(Flags.GAMEMODE); - if (gamemodeFlag.isPresent()) { - if (player.getGameMode() != gamemodeFlag.get()) { - if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { - player.setGameMode(gamemodeFlag.get()); - } else { - MainUtil.sendMessage(player, - StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.get())); - } - } - } + Optional guestGamemodeFlag = plot.getFlag(Flags.GUEST_GAMEMODE); - if (gamemodeFlag.isPresent()) { - if (player.getGameMode() != gamemodeFlag.get() && !plot.isAdded(player.getUUID())) { + if (guestGamemodeFlag.isPresent() && !plot.isAdded(player.getUUID())) { + if (player.getGameMode() != guestGamemodeFlag.get()) { if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { - player.setGameMode(gamemodeFlag.get()); + player.setGameMode(guestGamemodeFlag.get()); } else { MainUtil.sendMessage(player, - StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.get())); + StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", guestGamemodeFlag.get())); + } + } + } else { + Optional gamemodeFlag = plot.getFlag(Flags.GAMEMODE); + if (gamemodeFlag.isPresent()) { + if (player.getGameMode() != gamemodeFlag.get()) { + if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { + player.setGameMode(gamemodeFlag.get()); + } else { + MainUtil.sendMessage(player, + StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.get())); + } } } } + Optional timeFlag = plot.getFlag(Flags.TIME); if (timeFlag.isPresent()) { try {