+Fix BauCommand.isLocked +Update BauLockState.NONE to BauLockState.NOBODY +Move Userconfig.getUserLockState to BauCommand
Dieser Commit ist enthalten in:
Ursprung
c2211bdedf
Commit
ef6435b176
@ -81,11 +81,11 @@ public class BauCommand extends BasicCommand {
|
||||
break;
|
||||
|
||||
case "lock":
|
||||
setLocked(SteamwarUser.get(p), args[1]);
|
||||
setLocked(SteamwarUser.get(p), args);
|
||||
break;
|
||||
|
||||
case "unlock":
|
||||
setLocked(SteamwarUser.get(p), "OPEN");
|
||||
setLocked(SteamwarUser.get(p), new String[]{"", "open"});
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -327,22 +327,28 @@ public class BauCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
private static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
||||
BauLockState activeLockState = UserConfig.getUserLockState(owner.getId());
|
||||
BauLockState activeLockState = getUserLockState(owner.getId());
|
||||
if(activeLockState == null)
|
||||
activeLockState = BauLockState.OPEN;
|
||||
|
||||
return activeLockState == BauLockState.NONE || (activeLockState == BauLockState.TEAM && !(Team.get(owner.getId()) == Team.get(target.getId())));
|
||||
return activeLockState == BauLockState.NOBODY || (activeLockState == BauLockState.TEAM && owner.getTeam() == target.getTeam());
|
||||
}
|
||||
|
||||
private static void setLocked(SteamwarUser owner, String arg) {
|
||||
if(arg == null || BauLockState.valueOf(arg) == null) {
|
||||
private static final String bauLockConfigName = "baulockstate";
|
||||
|
||||
private static void setLocked(SteamwarUser owner, String[] args) {
|
||||
if(args.length < 2 || BauLockState.valueOf(args[1]) == null) {
|
||||
Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer());
|
||||
return;
|
||||
}
|
||||
UserConfig.updateUserConfig(owner.getId(), UserConfig.lockConfigName, arg.toUpperCase());
|
||||
|
||||
Message.send("BAU_LOCKED_" + arg, owner.getPlayer());
|
||||
String lockState = args[1].toUpperCase();
|
||||
UserConfig.updateUserConfig(owner.getId(), bauLockConfigName, lockState);
|
||||
|
||||
Message.send("BAU_LOCKED_" + lockState, owner.getPlayer());
|
||||
}
|
||||
|
||||
|
||||
private static BauLockState getUserLockState(int userID) {
|
||||
return BauLockState.valueOf(UserConfig.getConfig(userID, bauLockConfigName));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package de.steamwar.bungeecore.sql;
|
||||
|
||||
public enum BauLockState {
|
||||
|
||||
NONE, // Locks the build server for all users
|
||||
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
|
||||
}
|
||||
|
@ -3,18 +3,11 @@ package de.steamwar.bungeecore.sql;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserConfig {
|
||||
|
||||
public static final String lockConfigName = "baulockstate";
|
||||
|
||||
private static final Statement insert = new Statement("INSERT INTO `UserConfig`(`User`, `Config`, `Value`) VALUES (?,?,?)");
|
||||
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 delete = new Statement("DELETE FROM `UserConfig` WHERE 'User' = ? AND 'Config' = ?");
|
||||
|
||||
public static BauLockState getUserLockState(int userID) {
|
||||
return BauLockState.valueOf(getConfig(userID, lockConfigName));
|
||||
}
|
||||
|
||||
public static String getConfig(int userID, String config) {
|
||||
return select.select(rs -> {
|
||||
if(rs.next())
|
||||
|
@ -202,7 +202,7 @@ 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=§eBuild server lock options: §cnone§8, §eteam§8, §aopen§8.
|
||||
BAU_LOCKED_NONE=§eYou have closed your buildserver to all players.
|
||||
BAU_LOCKED_NOBODY=§eYou have closed your buildserver to all players.
|
||||
BAU_LOCKED_TEAM=§eYou've closed your buildserver to all beside added team members.
|
||||
BAU_LOCKED_OPEN=§eYou have reopened your build for all added players.
|
||||
BAU_DELMEMBER_USAGE=§8/§7build delmember §8[§eplayer§8]
|
||||
|
@ -38,8 +38,8 @@ HELP_JOIN=§7Trete mit §8/§ejoin §8[§eSpieler§8] §7einem Kampf bei!
|
||||
HELP_JOIN_HOVER=§eSpieler beitreten
|
||||
HELP_LOCAL=§7Schreibe mit §8/§elocal §7nur auf dem lokalen Server!
|
||||
HELP_LOCAL_HOVER=§eLokaler Chat
|
||||
HELP_BAU_LOCK=§8/§ebuild lock §8- §7Schließe den Bauserver für bestimmte Spieler.
|
||||
HELP_BAU_LOCK_HOVER=§eSchließe deinen bau
|
||||
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
|
||||
|
||||
@ -184,10 +184,10 @@ 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 Buildserver ist momentan gelocked.
|
||||
BAU_LOCKED_OPTIONS=§eBauserver schließ optionen: §cnone§8, §eteam§8, §aopen§8.
|
||||
BAU_LOCKED_NONE=§eDu hast dein Bau für alle Spieler geschlossen.
|
||||
BAU_LOCKED_TEAM=§eDu hast dein Bau für alle außer hinzugefügte Teammitglieder geschlossen.
|
||||
BAU_LOCKED_NOALLOWED=&cDer Bauserver ist momentan gesperrt.
|
||||
BAU_LOCKED_OPTIONS=§eBauserver sperr optionen: §cnone§8, §eteam§8, §aopen§8.
|
||||
BAU_LOCKED_NOBODY=§eDu hast dein Bau für alle Spieler geschlossen.
|
||||
BAU_LOCKED_TEAM=§eDu hast dein 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_DELMEMBER_USAGE=§8/§7bau delmember §8[§eSpieler§8]
|
||||
BAU_DELMEMBER_SELFDEL=§cDu kannst dich nicht selbst entfernen!
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren