diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java
index 069b086..8e2fb9a 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.messages.ChatSender;
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
@@ -80,6 +82,17 @@ public class BauCommand extends BasicCommand {
case "test":
testarena(p, args);
break;
+ case "lock":
+ if(args.length < 2) {
+ Message.send("BAU_LOCKED_OPTIONS", p);
+ return;
+ }
+
+ setLocked(p, args[1].toUpperCase());
+ break;
+ case "unlock":
+ setLocked(p, "OPEN");
+ break;
default:
HelpCommand.sendBauHelp(ChatSender.of(p));
}
@@ -129,6 +142,11 @@ public class BauCommand extends BasicCommand {
return;
}
+ if(isLocked(worldOwner, SteamwarUser.get(p))) {
+ Message.send("BAU_LOCKED_NOALLOWED", p);
+ return;
+ }
+
versionSelector(p, args, 2,
() -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start(),
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
@@ -307,4 +325,35 @@ 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/HelpCommand.java b/src/de/steamwar/bungeecore/commands/HelpCommand.java
index e2a66f8..d3fb3fe 100644
--- a/src/de/steamwar/bungeecore/commands/HelpCommand.java
+++ b/src/de/steamwar/bungeecore/commands/HelpCommand.java
@@ -101,7 +101,9 @@ public class HelpCommand extends BasicCommand {
"HELP_BAU_TOGGLEWE", "/build togglewe ",
"HELP_BAU_TOGGLEWORLD", "/build toggleworld ",
"HELP_BAU_DELETE", "/build delete ",
- "HELP_BAU_TESTARENA", "/build testarena ");
+ "HELP_BAU_TESTARENA", "/build testarena ",
+ "HELP_BAU_LOCK", "/build lock ",
+ "HELP_BAU_UNLOCK", "/build unlock");
}
private static void printPage(ChatSender sender, ClickEvent.Action action, String... args) {
diff --git a/src/de/steamwar/bungeecore/sql/BauLockState.java b/src/de/steamwar/bungeecore/sql/BauLockState.java
new file mode 100644
index 0000000..5d75fc3
--- /dev/null
+++ b/src/de/steamwar/bungeecore/sql/BauLockState.java
@@ -0,0 +1,27 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2022 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+package de.steamwar.bungeecore.sql;
+
+public enum BauLockState {
+
+ NOBODY, // Locks the build server for all users
+ TEAM, //opens the build server only for every added user which is in the same team as the buildOwner
+ OPEN //unlocks the build server for all users
+}
diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java
index 4e16de5..150ccf4 100644
--- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java
+++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java
@@ -268,6 +268,7 @@ public class SteamwarUser {
return team;
}
+ @Deprecated
public ProxiedPlayer getPlayer() {
return ProxyServer.getInstance().getPlayer(uuid);
}
diff --git a/src/de/steamwar/bungeecore/sql/UserConfig.java b/src/de/steamwar/bungeecore/sql/UserConfig.java
new file mode 100644
index 0000000..10f4dda
--- /dev/null
+++ b/src/de/steamwar/bungeecore/sql/UserConfig.java
@@ -0,0 +1,46 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2022 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+
+package de.steamwar.bungeecore.sql;
+
+public class UserConfig {
+ private UserConfig() {}
+
+ private static final Statement insert = new Statement("INSERT INTO UserConfig (User, Config, Value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)");
+ private static final Statement select = new Statement("SELECT Value FROM UserConfig WHERE User = ? AND Config = ?");
+ private static final Statement delete = new Statement("DELETE FROM UserConfig WHERE User = ? AND Config = ?");
+
+ public static String getConfig(int userID, String config) {
+ return select.select(rs -> {
+ if(rs.next())
+ return rs.getString("Value");
+ return null;
+ }, userID, config);
+ }
+
+ public static void updateUserConfig(int userID, String config, String value) {
+ if(value == null) {
+ delete.update(userID, config);
+ return;
+ }
+
+ insert.update(userID, config, value);
+ }
+}
diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties
index 7b1c74d..878ede1 100644
--- a/src/de/steamwar/messages/BungeeCore.properties
+++ b/src/de/steamwar/messages/BungeeCore.properties
@@ -101,6 +101,10 @@ HELP_BAU_DELETE=§8/§ebuild delete §8- §7Reset your entire build server
HELP_BAU_DELETE_HOVER=§eReset build server
HELP_BAU_TESTARENA=§8/§ebuild testarena §8- §7Start a test arena
HELP_BAU_TESTARENA_HOVER=§eStart test arena
+HELP_BAU_LOCK=§8/§ebuild lock §8- §7Locks the build server for a specified group of players
+HELP_BAU_LOCK_HOVER=§eLock your build server
+HELP_BAU_UNLOCK=§8/§ebuild unlock §8- §7Unlocks the buildserver for added users
+HELP_BAU_UNLOCK_HOVER=§eUnlock your build server
#Usage description of various commands
USAGE_ALERT=§8/§7alert §8[§emessage§8]
@@ -198,6 +202,11 @@ BAU_ADDMEMBER_ADDED=§aThe player was added to your world.
BAU_ADDMEMBER_ADDED_TARGET=§aYou have been added to the world of §e{0}§a.
BAU_TP_USAGE=§8/§7build tp §8[§eplayer§8]
BAU_TP_NOALLOWED=§cYou are not allowed to teleport to this player's world.
+BAU_LOCKED_NOALLOWED=§cThe build server is currently locked.
+BAU_LOCKED_OPTIONS=§7Build server lock options§8: §cnobody§8, §eteam§8, §aopen
+BAU_LOCKED_NOBODY=§7You have locked your build server for all players.
+BAU_LOCKED_TEAM=§7You've locked your build server for all players except added team members.
+BAU_LOCKED_OPEN=§7You have opened your build server for all added players.
BAU_DELMEMBER_USAGE=§8/§7build delmember §8[§eplayer§8]
BAU_DELMEMBER_SELFDEL=§cYou cannot remove yourself!
BAU_DELMEMBER_DELETED=§cPlayer was removed.
diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties
index fc4e57e..24f0a3d 100644
--- a/src/de/steamwar/messages/BungeeCore_de.properties
+++ b/src/de/steamwar/messages/BungeeCore_de.properties
@@ -87,6 +87,10 @@ HELP_BAU_DELETE=§8/§ebau delete §8- §7Setzt deine Bauwelt zurück
HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
HELP_BAU_TESTARENA_HOVER=§eTestarena starten
+HELP_BAU_LOCK=§8/§ebau lock §8- §7Sperre deinen Bauserver für bestimmte Spielergruppen
+HELP_BAU_LOCK_HOVER=§eSperre deinen Bau
+HELP_BAU_UNLOCK=§8/§ebau unlock §8- §7Öffne deinen Bauserver für alle hinzugefügten Spieler
+HELP_BAU_UNLOCK_HOVER=§eÖffne deinen Bau
#Usage description of various commands
USAGE_ALERT=§8/§7alert §8[§eNachricht§8]
@@ -182,6 +186,11 @@ BAU_ADDMEMBER_ADDED=§aDer Spieler wurde zu deiner Welt hinzugefügt.
BAU_ADDMEMBER_ADDED_TARGET=§aDu wurdest zu der Welt von §e{0} §ahinzugefügt.
BAU_TP_USAGE=§8/§7bau tp §8[§eSpieler§8]
BAU_TP_NOALLOWED=§cDu darfst dich nicht auf diese Welt teleportieren.
+BAU_LOCKED_NOALLOWED=§cDer Bauserver ist momentan gesperrt.
+BAU_LOCKED_OPTIONS=§7Bauserver-Sperroptionen§8: §cnobody§8, §eteam§8, §aopen
+BAU_LOCKED_NOBODY=§7Du hast deinen Bau für alle Spieler geschlossen.
+BAU_LOCKED_TEAM=§7Du hast deinen Bau für alle außer hinzugefügte Teammitglieder gesperrt.
+BAU_LOCKED_OPEN=§7Du hast deinen Bau für alle hinzugefügten Spieler geöffnet.
BAU_DELMEMBER_USAGE=§8/§7bau delmember §8[§eSpieler§8]
BAU_DELMEMBER_SELFDEL=§cDu kannst dich nicht selbst entfernen!
BAU_DELMEMBER_DELETED=§cDer Spieler wurde entfernt.