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:
Ursprung
386395725d
Commit
19dad58712
@ -81,11 +81,11 @@ public class BauCommand extends BasicCommand {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "lock":
|
case "lock":
|
||||||
setLocked(SteamwarUser.get(p), args);
|
setLocked(SteamwarUser.get(p), args[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "unlock":
|
case "unlock":
|
||||||
setLocked(SteamwarUser.get(p), new String[]{"", "OPEN"});
|
setLocked(SteamwarUser.get(p), "OPEN");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -127,9 +127,15 @@ public class BauCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SteamwarUser worldOwner = SteamwarUser.get(args[1]);
|
SteamwarUser worldOwner = SteamwarUser.get(args[1]);
|
||||||
SteamwarUser user = SteamwarUser.get(p);
|
SteamwarUser user = SteamwarUser.get(p);
|
||||||
|
|
||||||
|
if (worldOwner == null) {
|
||||||
|
Message.send("UNKNOWN_PLAYER", user.getPlayer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(isLocked(worldOwner, user)) {
|
if(isLocked(worldOwner, user)) {
|
||||||
Message.send("BAU_LOCKED_NOALLOWED", user.getPlayer());
|
Message.send("BAU_LOCKED_NOALLOWED", user.getPlayer());
|
||||||
return;
|
return;
|
||||||
@ -321,29 +327,22 @@ public class BauCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
private static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
||||||
if (owner == null) {
|
BauLockState activeLockState = UserConfig.getUserLockState(owner.getId());
|
||||||
Message.send("UNKNOWN_PLAYER", target.getPlayer());
|
if(activeLockState == null)
|
||||||
return true;
|
activeLockState = BauLockState.OPEN;
|
||||||
}
|
|
||||||
|
|
||||||
BauLockState activeLockState = BauLock.getUserLockState(owner.getId());
|
return activeLockState == BauLockState.NONE || (activeLockState == BauLockState.TEAM && !(Team.get(owner.getId()) == Team.get(target.getId())));
|
||||||
return (activeLockState == BauLockState.TEAM && !(Team.get(owner.getId()) == Team.get(target.getId()))) || activeLockState == BauLockState.ALL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setLocked(SteamwarUser owner, String[] args) {
|
private static void setLocked(SteamwarUser owner, String arg) {
|
||||||
|
if(arg == null || BauLockState.valueOf(arg) == null) {
|
||||||
BauLockState newState = BauLockState.OPEN;
|
Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer());
|
||||||
if(args[1] != null) {
|
return;
|
||||||
BauLockState.valueOf(args[1].toUpperCase());
|
|
||||||
newState = BauLockState.valueOf(args[1].toUpperCase());
|
|
||||||
}
|
}
|
||||||
|
UserConfig.updateUserConfig(owner.getId(), UserConfig.lockConfigName, arg.toUpperCase());
|
||||||
|
|
||||||
BauLock.updateUserConfig(owner.getId(), newState);
|
Message.send("BAU_LOCKED_" + arg, owner.getPlayer());
|
||||||
|
|
||||||
String messageKey = "BAU_LOCKED";
|
|
||||||
if(newState == BauLockState.OPEN)
|
|
||||||
messageKey = "BAU_UNLOCKED";
|
|
||||||
|
|
||||||
Message.send(messageKey, owner.getPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@ package de.steamwar.bungeecore.sql;
|
|||||||
|
|
||||||
public enum BauLockState {
|
public enum BauLockState {
|
||||||
|
|
||||||
ALL, // Locks the build server for all users
|
NONE, // 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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
38
src/de/steamwar/bungeecore/sql/UserConfig.java
Normale Datei
38
src/de/steamwar/bungeecore/sql/UserConfig.java
Normale Datei
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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_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 buildserver is currently locked.
|
BAU_LOCKED_NOALLOWED=&cThe buildserver is currently locked.
|
||||||
BAU_LOCKED=&eYou have locked your buildserver.
|
BAU_LOCKED_OPTIONS=§eBuildserver lock options: none, team, open.
|
||||||
BAU_UNLOCKED=&eYou have unlocked your buildserver.
|
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_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.
|
||||||
|
@ -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_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 Buildserver ist momentan gelocked.
|
BAU_LOCKED_NOALLOWED=&cDer Buildserver ist momentan gelocked.
|
||||||
BAU_LOCKED=&eDu hast dein Bau geschlossen.
|
BAU_LOCKED_OPTIONS=§eBuildserver lock optionen: none, team, open.
|
||||||
BAU_UNLOCKED=&eDu hast dein Bau wieder freigegeben.
|
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_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