SteamWar/BungeeCore
Archiviert
13
2

Replace BauLock to UserConfig
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Update BauLockState.ALL to BauLockState.NONE
Add "BAU_LOCKED_OPTIONS" in BungeeCore_de.properties
Add "BAU_LOCKED_OPTIONS" in BungeeCore.properties
Dieser Commit ist enthalten in:
MoBrot 2022-08-13 21:18:54 +02:00
Ursprung 386395725d
Commit 19dad58712
6 geänderte Dateien mit 69 neuen und 66 gelöschten Zeilen

Datei anzeigen

@ -81,11 +81,11 @@ public class BauCommand extends BasicCommand {
break;
case "lock":
setLocked(SteamwarUser.get(p), args);
setLocked(SteamwarUser.get(p), args[1]);
break;
case "unlock":
setLocked(SteamwarUser.get(p), new String[]{"", "OPEN"});
setLocked(SteamwarUser.get(p), "OPEN");
break;
default:
@ -127,9 +127,15 @@ public class BauCommand extends BasicCommand {
return;
}
SteamwarUser worldOwner = SteamwarUser.get(args[1]);
SteamwarUser user = SteamwarUser.get(p);
if (worldOwner == null) {
Message.send("UNKNOWN_PLAYER", user.getPlayer());
return;
}
if(isLocked(worldOwner, user)) {
Message.send("BAU_LOCKED_NOALLOWED", user.getPlayer());
return;
@ -321,29 +327,22 @@ public class BauCommand extends BasicCommand {
}
private static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
if (owner == null) {
Message.send("UNKNOWN_PLAYER", target.getPlayer());
return true;
}
BauLockState activeLockState = UserConfig.getUserLockState(owner.getId());
if(activeLockState == null)
activeLockState = BauLockState.OPEN;
BauLockState activeLockState = BauLock.getUserLockState(owner.getId());
return (activeLockState == BauLockState.TEAM && !(Team.get(owner.getId()) == Team.get(target.getId()))) || activeLockState == BauLockState.ALL;
return activeLockState == BauLockState.NONE || (activeLockState == BauLockState.TEAM && !(Team.get(owner.getId()) == Team.get(target.getId())));
}
private static void setLocked(SteamwarUser owner, String[] args) {
BauLockState newState = BauLockState.OPEN;
if(args[1] != null) {
BauLockState.valueOf(args[1].toUpperCase());
newState = BauLockState.valueOf(args[1].toUpperCase());
private static void setLocked(SteamwarUser owner, String arg) {
if(arg == null || BauLockState.valueOf(arg) == null) {
Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer());
return;
}
UserConfig.updateUserConfig(owner.getId(), UserConfig.lockConfigName, arg.toUpperCase());
BauLock.updateUserConfig(owner.getId(), newState);
String messageKey = "BAU_LOCKED";
if(newState == BauLockState.OPEN)
messageKey = "BAU_UNLOCKED";
Message.send(messageKey, owner.getPlayer());
Message.send("BAU_LOCKED_" + arg, owner.getPlayer());
}
}

Datei anzeigen

@ -1,38 +0,0 @@
package de.steamwar.bungeecore.sql;
public class BauLock {
private static final String configName = "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 selectAll = new Statement("SELECT * FROM `UserConfig` WHERE 'User' = ? AND Config' = ?");
public static BauLockState getUserLockState(int userID) {
select.select(rs -> {
if(rs.next())
return BauLockState.valueOf(rs.getString("Value"));
return BauLockState.OPEN;
}, userID, configName);
return BauLockState.OPEN;
}
public static void updateUserConfig(int userID, BauLockState state) {
if(!exists(userID)) {
insert.update(userID, configName, String.valueOf(state));
}else
update.update(String.valueOf(state), userID, configName);
}
private static boolean exists(int userID) {
selectAll.select(rs -> {
if(rs.next())
return rs.getString(1) != null;
return null;
}, userID, configName);
return false;
}
}

Datei anzeigen

@ -2,7 +2,7 @@ package de.steamwar.bungeecore.sql;
public enum BauLockState {
ALL, // Locks the build server for all users
OPEN, //locks the build server for every user
TEAM //opens the build server only for every added user which is in the same team as the buildOwner
NONE, // 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
}

Datei anzeigen

@ -0,0 +1,38 @@
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())
return rs.getString("Value");
return null;
}, userID, config);
}
public static void updateUserConfig(int userID, String config, String value) {
if (getConfig(userID, config) == null) {
insert.update(userID, config, value);
} else {
update.update(value, config, config);
}
}
public static void removePlayerEntry(int userID, String config) {
delete.update(userID, config);
}
}

Datei anzeigen

@ -197,8 +197,10 @@ 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 buildserver is currently locked.
BAU_LOCKED=&eYou have locked your buildserver.
BAU_UNLOCKED=&eYou have unlocked your buildserver.
BAU_LOCKED_OPTIONS=§eBuildserver lock options: none, team, open.
BAU_LOCKED_NONE=§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]
BAU_DELMEMBER_SELFDEL=§cYou cannot remove yourself!
BAU_DELMEMBER_DELETED=§cPlayer was removed.

Datei anzeigen

@ -181,8 +181,10 @@ 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=&eDu hast dein Bau geschlossen.
BAU_UNLOCKED=&eDu hast dein Bau wieder freigegeben.
BAU_LOCKED_OPTIONS=§eBuildserver lock optionen: none, team, open.
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_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!
BAU_DELMEMBER_DELETED=§cDer Spieler wurde entfernt.