[Core] Fix listener to actually use guest gamemode flag (#2231)

* Fix gamemode flag being used as guest gamemode flag

* Remove redundant gamemode flag check
This commit is contained in:
Dico Karssiens 2019-01-12 17:50:46 +00:00 committed by dordsor21
parent 21f0d26c9d
commit 5eaea8a31b

View file

@ -87,28 +87,31 @@ public class PlotListener {
player.setFlight(flyFlag.get());
}
}
Optional<PlotGameMode> 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<PlotGameMode> 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<PlotGameMode> 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<Long> timeFlag = plot.getFlag(Flags.TIME);
if (timeFlag.isPresent()) {
try {