From 3e9bd2768bb849881c38689454f97012434a65e1 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Fri, 16 Sep 2022 23:27:52 +0200 Subject: [PATCH] +Fixed player connect with teleport --- .../bungeecore/commands/BauCommand.java | 42 ++----------------- .../bungeecore/commands/TpCommand.java | 4 ++ src/de/steamwar/bungeecore/sql/BauLock.java | 39 +++++++++++++++++ 3 files changed, 47 insertions(+), 38 deletions(-) create mode 100644 src/de/steamwar/bungeecore/sql/BauLock.java diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 8e2fb9a..9691ebc 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -23,10 +23,7 @@ import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.network.NetworkSender; -import de.steamwar.bungeecore.sql.BauLockState; -import de.steamwar.bungeecore.sql.BauweltMember; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.UserConfig; +import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.util.Chat19; import de.steamwar.messages.ChatSender; import de.steamwar.network.packets.server.BaumemberUpdatePacket; @@ -88,10 +85,10 @@ public class BauCommand extends BasicCommand { return; } - setLocked(p, args[1].toUpperCase()); + BauLock.setLocked(p, args[1].toUpperCase()); break; case "unlock": - setLocked(p, "OPEN"); + BauLock.setLocked(p, "OPEN"); break; default: HelpCommand.sendBauHelp(ChatSender.of(p)); @@ -142,7 +139,7 @@ public class BauCommand extends BasicCommand { return; } - if(isLocked(worldOwner, SteamwarUser.get(p))) { + if(BauLock.isLocked(worldOwner, SteamwarUser.get(p))) { Message.send("BAU_LOCKED_NOALLOWED", p); return; } @@ -325,35 +322,4 @@ public class BauCommand extends BasicCommand { Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p)); } } - - private static final String BAU_LOCK_CONFIG_NAME = "baulockstate"; - private static void setLocked(ProxiedPlayer p, String arg) { - SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); - BauLockState state; - try { - state = BauLockState.valueOf(arg); - } catch (IllegalArgumentException e) { - Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer()); - return; - } - - UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name()); - Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer()); - } - - private static boolean isLocked(SteamwarUser owner, SteamwarUser target) { - if (owner.getId() == target.getId()) - return false; - - String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME); - switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) { - case NOBODY: - return true; - case TEAM: - return owner.getTeam() != target.getTeam(); - case OPEN: - default: - return false; - } - } } diff --git a/src/de/steamwar/bungeecore/commands/TpCommand.java b/src/de/steamwar/bungeecore/commands/TpCommand.java index 1ac1a22..96a0e87 100644 --- a/src/de/steamwar/bungeecore/commands/TpCommand.java +++ b/src/de/steamwar/bungeecore/commands/TpCommand.java @@ -96,6 +96,10 @@ public class TpCommand extends BasicCommand { sender.system("JOIN_PLAYER_BLOCK"); } } else if (bauserver.getOwner().equals(player.getUniqueId()) || BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) { + if (BauLock.isLocked(SteamwarUser.get(bauserver.getOwner()), sender.user())) { + Message.send("BAU_LOCKED_NOALLOWED", player); + return; + } SubserverSystem.sendPlayer(subserver, player); } else { SubserverSystem.sendDeniedMessage(player, bauserver.getOwner()); diff --git a/src/de/steamwar/bungeecore/sql/BauLock.java b/src/de/steamwar/bungeecore/sql/BauLock.java new file mode 100644 index 0000000..2527126 --- /dev/null +++ b/src/de/steamwar/bungeecore/sql/BauLock.java @@ -0,0 +1,39 @@ +package de.steamwar.bungeecore.sql; + +import de.steamwar.bungeecore.Message; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +public class BauLock { + + private static final String BAU_LOCK_CONFIG_NAME = "baulockstate"; + public static void setLocked(ProxiedPlayer p, String arg) { + SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); + BauLockState state; + try { + state = BauLockState.valueOf(arg); + } catch (IllegalArgumentException e) { + Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer()); + return; + } + + UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name()); + Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer()); + } + + public static boolean isLocked(SteamwarUser owner, SteamwarUser target) { + if (owner.getId() == target.getId()) + return false; + + String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME); + switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) { + case NOBODY: + return true; + case TEAM: + return owner.getTeam() != target.getTeam(); + case OPEN: + default: + return false; + } + } + +}