diff --git a/CommonCore b/CommonCore index 9df92595..1dea7199 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit 9df92595b2f344585bd3e1639cedc761680b7761 +Subproject commit 1dea71993d897354d3f52a705f6e0e1e0c8ec580 diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index dfc0a5b3..be8fdec3 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -23,8 +23,10 @@ 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.util.Chat19; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -171,6 +173,10 @@ public class BauCommand extends SWCommand { messageSender.send("BAU_TP_NOALLOWED"); return false; } + if(isLocked(value, SteamwarUser.get(p))) { + messageSender.send("BAU_LOCKED_NOALLOWED"); + return false; + } return true; }; } @@ -288,6 +294,16 @@ public class BauCommand extends SWCommand { }); } + @Register(value = "lock", description = "BAU_LOCKED_OPTIONS") + public void lock(ProxiedPlayer p, BauLockState bauLockState) { + setLocked(p, bauLockState); + } + + @Register("unlock") + public void unlock(ProxiedPlayer p) { + setLocked(p, BauLockState.OPEN); + } + private static BauweltMember member(ProxiedPlayer p, SteamwarUser member){ if (member == null) { Message.send("UNKNOWN_PLAYER", p); @@ -315,4 +331,27 @@ public class BauCommand extends SWCommand { 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, BauLockState state) { + SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); + 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; + } + } }