SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Notify owner on lock blocking join' (#508) from buildLockNotification into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #508
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
Dieser Commit ist enthalten in:
Lixfel 2024-02-13 10:52:52 +01:00
Commit 74291bc143
5 geänderte Dateien mit 29 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -161,11 +161,7 @@ public class BauCommand extends SWCommand {
messageSender.send("BAU_TP_NOALLOWED"); messageSender.send("BAU_TP_NOALLOWED");
return false; return false;
} }
if(BauLock.isLocked(value, SteamwarUser.get(p.getUniqueId()))) { return !BauLock.checkNotifyLocked(value, p);
messageSender.send("BAU_LOCKED_NOALLOWED");
return false;
}
return true;
}; };
} }

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.tablist.TablistManager;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import de.steamwar.bungeecore.util.BauLock; import de.steamwar.bungeecore.util.BauLock;
import de.steamwar.bungeecore.util.Chat19; import de.steamwar.bungeecore.util.Chat19;
@ -122,8 +121,7 @@ public class TpCommand extends SWCommand {
sender.system("JOIN_PLAYER_BLOCK"); sender.system("JOIN_PLAYER_BLOCK");
return; return;
} }
} else if (BauLock.isLocked(SteamwarUser.get(bauserver.getOwner()), sender.user())) { } else if (BauLock.checkNotifyLocked(SteamwarUser.get(bauserver.getOwner()), player)) {
sender.system("BAU_LOCKED_NOALLOWED");
return; return;
} else if (!bauserver.getOwner().equals(player.getUniqueId()) && BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) == null) { } else if (!bauserver.getOwner().equals(player.getUniqueId()) && BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) == null) {
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner()); SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());

Datei anzeigen

@ -20,10 +20,12 @@
package de.steamwar.bungeecore.util; package de.steamwar.bungeecore.util;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.messages.ChatSender;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserConfig; import de.steamwar.sql.UserConfig;
import de.steamwar.sql.UserPerm; import de.steamwar.sql.UserPerm;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@UtilityClass @UtilityClass
@ -36,27 +38,44 @@ public class BauLock {
Message.send("BAU_LOCKED_" + state.name(), p); Message.send("BAU_LOCKED_" + state.name(), p);
} }
public static boolean isLocked(SteamwarUser owner, SteamwarUser target) { public static boolean checkNotifyLocked(SteamwarUser owner, ProxiedPlayer player) {
ChatSender sender = ChatSender.of(player);
SteamwarUser target = sender.user();
if (owner.getId() == target.getId()) if (owner.getId() == target.getId())
return false; return false;
boolean locked;
String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME); String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME);
switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) { switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) {
case NOBODY: case NOBODY:
return true; locked = true;
break;
case SERVERTEAM: case SERVERTEAM:
return !target.hasPerm(UserPerm.TEAM); locked = !target.hasPerm(UserPerm.TEAM);
break;
case TEAM_AND_SERVERTEAM: case TEAM_AND_SERVERTEAM:
if (target.hasPerm(UserPerm.TEAM)) { if (target.hasPerm(UserPerm.TEAM)) {
return false; return false;
} }
return owner.getTeam() != target.getTeam(); locked = owner.getTeam() != target.getTeam();
break;
case TEAM: case TEAM:
return owner.getTeam() != target.getTeam(); locked = owner.getTeam() != target.getTeam();
break;
case OPEN: case OPEN:
default: default:
return false; locked = false;
} }
if(locked) {
sender.system("BAU_LOCKED_NOALLOWED");
ProxiedPlayer ownerPlayer = ProxyServer.getInstance().getPlayer(owner.getUUID());
if(ownerPlayer != null)
ChatSender.of(ownerPlayer).system("BAU_LOCK_BLOCKED", player.getName());
}
return locked;
} }
} }

Datei anzeigen

@ -210,6 +210,7 @@ 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_LOCK_BLOCKED=§cYour build lock has prevented §e{0} §cfrom joining.
BAU_LOCKED_OPTIONS=§7Build server lock options§8: §cnobody§8, §eserverteam§8, §eteam_and_serverteam§8, §eteam§8, §aopen BAU_LOCKED_OPTIONS=§7Build server lock options§8: §cnobody§8, §eserverteam§8, §eteam_and_serverteam§8, §eteam§8, §aopen
BAU_LOCKED_NOBODY=§7You have locked your build server for all players. BAU_LOCKED_NOBODY=§7You have locked your build server for all players.
BAU_LOCKED_SERVERTEAM=§7You have locked your build server for all players except added server team members. BAU_LOCKED_SERVERTEAM=§7You have locked your build server for all players except added server team members.

Datei anzeigen

@ -193,6 +193,7 @@ 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_LOCK_BLOCKED=§cDeine Bausperre hat den Beitritt von §e{0} §cverhindert.
BAU_LOCKED_OPTIONS=§7Bauserver-Sperroptionen§8: §cnobody§8, §eserverteam§8, §eteam_and_serverteam§8, §eteam§8, §aopen BAU_LOCKED_OPTIONS=§7Bauserver-Sperroptionen§8: §cnobody§8, §eserverteam§8, §eteam_and_serverteam§8, §eteam§8, §aopen
BAU_LOCKED_NOBODY=§7Du hast deinen Bau für alle Spieler geschlossen. BAU_LOCKED_NOBODY=§7Du hast deinen Bau für alle Spieler geschlossen.
BAU_LOCKED_SERVERTEAM=§7Du hast deinen Bau für alle außer hinzugefügte Serverteammitglieder gesperrt. BAU_LOCKED_SERVERTEAM=§7Du hast deinen Bau für alle außer hinzugefügte Serverteammitglieder gesperrt.