geforkt von SteamWar/BungeeCore
Merge remote-tracking branch 'origin/BauLock' into BauLock
# Conflicts: # src/de/steamwar/bungeecore/commands/BauCommand.java
Dieser Commit ist enthalten in:
Commit
e5ba1ad633
@ -23,13 +23,15 @@ import de.steamwar.bungeecore.*;
|
|||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
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.bungeecore.util.Chat19;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ public class BauCommand extends BasicCommand {
|
|||||||
togglewe(p, args);
|
togglewe(p, args);
|
||||||
break;
|
break;
|
||||||
case "toggleworld":
|
case "toggleworld":
|
||||||
toggleWorld(p, args);
|
toggleworld(p, args);
|
||||||
break;
|
break;
|
||||||
case "delmember":
|
case "delmember":
|
||||||
delmember(p, args);
|
delmember(p, args);
|
||||||
@ -80,20 +82,17 @@ public class BauCommand extends BasicCommand {
|
|||||||
case "test":
|
case "test":
|
||||||
testarena(p, args);
|
testarena(p, args);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "lock":
|
case "lock":
|
||||||
if(!(args.length < 2)) {
|
if(args.length < 2) {
|
||||||
Message.send("BAU_LOCKED_OPTIONS", p);
|
Message.send("BAU_LOCKED_OPTIONS", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocked(SteamwarUser.get(p), args[1]);
|
setLocked(p, args[1].toUpperCase());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "unlock":
|
case "unlock":
|
||||||
setLocked(SteamwarUser.get(p), "open");
|
setLocked(p, "OPEN");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HelpCommand.sendBauHelp(ChatSender.of(p));
|
HelpCommand.sendBauHelp(ChatSender.of(p));
|
||||||
}
|
}
|
||||||
@ -134,15 +133,17 @@ public class BauCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser worldOwner = SteamwarUser.get(args[1]);
|
SteamwarUser worldOwner = SteamwarUser.get(args[1]);
|
||||||
SteamwarUser user = SteamwarUser.get(p);
|
|
||||||
|
|
||||||
if (worldOwner == null) {
|
if (worldOwner == null) {
|
||||||
Message.send("UNKNOWN_PLAYER", user.getPlayer());
|
Message.send("UNKNOWN_PLAYER", p);
|
||||||
|
return;
|
||||||
|
}else if (!p.getUniqueId().equals(worldOwner.getUuid()) && BauweltMember.getBauMember(worldOwner.getUuid(), p.getUniqueId()) == null){
|
||||||
|
SubserverSystem.sendDeniedMessage(p, worldOwner.getUuid());
|
||||||
|
Message.send("BAU_TP_NOALLOWED", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isLocked(worldOwner, user)) {
|
if(isLocked(worldOwner, SteamwarUser.get(p))) {
|
||||||
Message.send("BAU_LOCKED_NOALLOWED", user.getPlayer());
|
Message.send("BAU_LOCKED_NOALLOWED", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ public class BauCommand extends BasicCommand {
|
|||||||
isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT");
|
isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void toggleWorld(ProxiedPlayer p, String[] args){
|
private static void toggleworld(ProxiedPlayer p, String[] args){
|
||||||
BauweltMember target = toggle(p, args, "toggleworld");
|
BauweltMember target = toggle(p, args, "toggleworld");
|
||||||
if(target == null)
|
if(target == null)
|
||||||
return;
|
return;
|
||||||
@ -325,34 +326,34 @@ public class BauCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
private static final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
||||||
BauLockState activeLockState = getUserLockState(owner.getId());
|
private static void setLocked(ProxiedPlayer p, String arg) {
|
||||||
if(activeLockState == null)
|
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
||||||
activeLockState = BauLockState.OPEN;
|
BauLockState state;
|
||||||
|
try {
|
||||||
if((!target.getUuid().equals(owner.getUuid()) && BauweltMember.getBauMember(owner.getId(), target.getId()) == null) && !(activeLockState == BauLockState.NOBODY)) {
|
state = BauLockState.valueOf(arg);
|
||||||
SubserverSystem.sendDeniedMessage(target.getPlayer(), owner.getUuid());
|
} catch (IllegalStateException e) {
|
||||||
Message.send("BAU_TP_NOALLOWED", target.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
return activeLockState == BauLockState.NOBODY || (activeLockState == BauLockState.TEAM && owner.getTeam() == target.getTeam());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String bauLockConfigName = "baulockstate";
|
|
||||||
|
|
||||||
private static void setLocked(SteamwarUser owner, String arg) {
|
|
||||||
if(BauLockState.valueOf(arg) == null) {
|
|
||||||
Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer());
|
Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String lockState = arg.toUpperCase();
|
UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
||||||
UserConfig.updateUserConfig(owner.getId(), bauLockConfigName, lockState);
|
Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer());
|
||||||
|
|
||||||
Message.send("BAU_LOCKED_" + lockState, owner.getPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BauLockState getUserLockState(int userID) {
|
private static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
||||||
return BauLockState.valueOf(UserConfig.getConfig(userID, bauLockConfigName));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
public enum BauLockState {
|
public enum BauLockState {
|
||||||
|
@ -268,6 +268,7 @@ public class SteamwarUser {
|
|||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ProxiedPlayer getPlayer() {
|
public ProxiedPlayer getPlayer() {
|
||||||
return ProxyServer.getInstance().getPlayer(uuid);
|
return ProxyServer.getInstance().getPlayer(uuid);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,31 @@
|
|||||||
|
/*
|
||||||
|
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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class UserConfig {
|
public class UserConfig {
|
||||||
private static final Statement insert = new Statement("INSERT INTO `UserConfig`(`User`, `Config`, `Value`) VALUES (?,?,?)");
|
private UserConfig() {}
|
||||||
private static final Statement update = new Statement("UPDATE `UserConfig` SET `Value`= ? WHERE 'User' = ? AND 'Config' = ?");
|
|
||||||
private static final Statement select = new Statement("SELECT `Value` FROM `UserConfig` WHERE 'User' = ? AND 'Config' = ?");
|
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 delete = new Statement("DELETE FROM `UserConfig` WHERE 'User' = ? AND 'Config' = ?");
|
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) {
|
public static String getConfig(int userID, String config) {
|
||||||
return select.select(rs -> {
|
return select.select(rs -> {
|
||||||
@ -17,15 +36,11 @@ public class UserConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateUserConfig(int userID, String config, String value) {
|
public static void updateUserConfig(int userID, String config, String value) {
|
||||||
|
if(value == null) {
|
||||||
if (getConfig(userID, config) == null) {
|
delete.update(userID, config);
|
||||||
insert.update(userID, config, value);
|
return;
|
||||||
} else {
|
|
||||||
update.update(value, config, config);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void removePlayerEntry(int userID, String config) {
|
insert.update(userID, config, value);
|
||||||
delete.update(userID, config);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,10 +101,10 @@ HELP_BAU_DELETE=§8/§ebuild delete §8- §7Reset your entire build server
|
|||||||
HELP_BAU_DELETE_HOVER=§eReset build server
|
HELP_BAU_DELETE_HOVER=§eReset build server
|
||||||
HELP_BAU_TESTARENA=§8/§ebuild testarena §8- §7Start a test arena
|
HELP_BAU_TESTARENA=§8/§ebuild testarena §8- §7Start a test arena
|
||||||
HELP_BAU_TESTARENA_HOVER=§eStart test arena
|
HELP_BAU_TESTARENA_HOVER=§eStart test arena
|
||||||
HELP_BAU_LOCK=§8/§ebuild lock §8- §7Locks the buildserver for customized group of players.
|
HELP_BAU_LOCK=§8/§ebuild lock §8- §7Locks the build server for a specified group of players
|
||||||
HELP_BAU_LOCK_HOVER=§eLock the build
|
HELP_BAU_LOCK_HOVER=§eLock your build server
|
||||||
HELP_BAU_UNLOCK=§8/§ebuild unlock §8- §7Unlocks the buildserver for all added user.
|
HELP_BAU_UNLOCK=§8/§ebuild unlock §8- §7Unlocks the buildserver for added users
|
||||||
HELP_BAU_UNLOCK_HOVER=§eUnlock the build
|
HELP_BAU_UNLOCK_HOVER=§eUnlock your build server
|
||||||
|
|
||||||
#Usage description of various commands
|
#Usage description of various commands
|
||||||
USAGE_ALERT=§8/§7alert §8[§emessage§8]
|
USAGE_ALERT=§8/§7alert §8[§emessage§8]
|
||||||
@ -202,11 +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_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_USAGE=§8/§7build tp §8[§eplayer§8]
|
||||||
BAU_TP_NOALLOWED=§cYou are not allowed to teleport to this player's world.
|
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_NOALLOWED=§cThe build server is currently locked.
|
||||||
BAU_LOCKED_OPTIONS=§eBuild server lock options: §cnone§8, §eteam§8, §aopen§8.
|
BAU_LOCKED_OPTIONS=§7Build server lock options§8: §cnone§8, §eteam§8, §aopen
|
||||||
BAU_LOCKED_NOBODY=§eYou have closed your buildserver to all players.
|
BAU_LOCKED_NOBODY=§7You have locked your build server for all players.
|
||||||
BAU_LOCKED_TEAM=§eYou've closed your buildserver to all beside added team members.
|
BAU_LOCKED_TEAM=§7You've locked your build server for all players except added team members.
|
||||||
BAU_LOCKED_OPEN=§eYou have reopened your build for all added players.
|
BAU_LOCKED_OPEN=§7You have opened your build server for all added players.
|
||||||
BAU_DELMEMBER_USAGE=§8/§7build delmember §8[§eplayer§8]
|
BAU_DELMEMBER_USAGE=§8/§7build delmember §8[§eplayer§8]
|
||||||
BAU_DELMEMBER_SELFDEL=§cYou cannot remove yourself!
|
BAU_DELMEMBER_SELFDEL=§cYou cannot remove yourself!
|
||||||
BAU_DELMEMBER_DELETED=§cPlayer was removed.
|
BAU_DELMEMBER_DELETED=§cPlayer was removed.
|
||||||
|
@ -40,10 +40,6 @@ HELP_JOIN=§7Trete mit §8/§ejoin §8[§eSpieler§8] §7einem Kampf bei!
|
|||||||
HELP_JOIN_HOVER=§eSpieler beitreten
|
HELP_JOIN_HOVER=§eSpieler beitreten
|
||||||
HELP_LOCAL=§7Schreibe mit §8/§elocal §7nur auf dem lokalen Server!
|
HELP_LOCAL=§7Schreibe mit §8/§elocal §7nur auf dem lokalen Server!
|
||||||
HELP_LOCAL_HOVER=§eLokaler Chat
|
HELP_LOCAL_HOVER=§eLokaler Chat
|
||||||
HELP_BAU_LOCK=§8/§ebuild lock §8- §7Sperre dein Bauserver für bestimmte Spieler.
|
|
||||||
HELP_BAU_LOCK_HOVER=§eSperre deinen bau
|
|
||||||
HELP_BAU_UNLOCK=§8/§ebuild unlock §8- §7SÖffne den Bauserver für alle vertrauten Spieler.
|
|
||||||
HELP_BAU_UNLOCK_HOVER=§eÖffne deinen bau
|
|
||||||
|
|
||||||
HELP_TNT=§8/§7tnt §8- §7(de)aktiviert Explosionsschaden
|
HELP_TNT=§8/§7tnt §8- §7(de)aktiviert Explosionsschaden
|
||||||
HELP_FIRE=§8/§7fire §8- §7(de)aktiviert Feuerschaden
|
HELP_FIRE=§8/§7fire §8- §7(de)aktiviert Feuerschaden
|
||||||
@ -91,6 +87,10 @@ HELP_BAU_DELETE=§8/§ebau delete §8- §7Setzt deine Bauwelt zurück
|
|||||||
HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen
|
HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen
|
||||||
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
|
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
|
||||||
HELP_BAU_TESTARENA_HOVER=§eTestarena starten
|
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 description of various commands
|
||||||
USAGE_ALERT=§8/§7alert §8[§eNachricht§8]
|
USAGE_ALERT=§8/§7alert §8[§eNachricht§8]
|
||||||
@ -186,11 +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_ADDMEMBER_ADDED_TARGET=§aDu wurdest zu der Welt von §e{0} §ahinzugefügt.
|
||||||
BAU_TP_USAGE=§8/§7bau tp §8[§eSpieler§8]
|
BAU_TP_USAGE=§8/§7bau tp §8[§eSpieler§8]
|
||||||
BAU_TP_NOALLOWED=§cDu darfst dich nicht auf diese Welt teleportieren.
|
BAU_TP_NOALLOWED=§cDu darfst dich nicht auf diese Welt teleportieren.
|
||||||
BAU_LOCKED_NOALLOWED=&cDer Bauserver ist momentan gesperrt.
|
BAU_LOCKED_NOALLOWED=§cDer Bauserver ist momentan gesperrt.
|
||||||
BAU_LOCKED_OPTIONS=§eBauserver sperr optionen: §cnone§8, §eteam§8, §aopen§8.
|
BAU_LOCKED_OPTIONS=§7Bauserver-Sperroptionen§8: §cnone§8, §eteam§8, §aopen
|
||||||
BAU_LOCKED_NOBODY=§eDu hast dein Bau für alle Spieler geschlossen.
|
BAU_LOCKED_NOBODY=§7Du hast deinen Bau für alle Spieler geschlossen.
|
||||||
BAU_LOCKED_TEAM=§eDu hast dein Bau für alle außer hinzugefügte Teammitglieder gesperrt.
|
BAU_LOCKED_TEAM=§7Du hast deinen Bau für alle außer hinzugefügte Teammitglieder gesperrt.
|
||||||
BAU_LOCKED_OPEN=§eDu hast dein Bau für alle hinzugefügten Spieler wieder geöffnet.
|
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_USAGE=§8/§7bau delmember §8[§eSpieler§8]
|
||||||
BAU_DELMEMBER_SELFDEL=§cDu kannst dich nicht selbst entfernen!
|
BAU_DELMEMBER_SELFDEL=§cDu kannst dich nicht selbst entfernen!
|
||||||
BAU_DELMEMBER_DELETED=§cDer Spieler wurde entfernt.
|
BAU_DELMEMBER_DELETED=§cDer Spieler wurde entfernt.
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren