SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Update BauMemberPermission' (#505) from PermissionUpdate into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #505
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2024-02-17 08:32:16 +01:00
Commit b3efb223af
5 geänderte Dateien mit 50 neuen und 50 gelöschten Zeilen

@ -1 +1 @@
Subproject commit e664c6cf4e3e9a056918cf15030c247e7bc6fe19 Subproject commit e7952685d279b9e59a668e31c9466cd426521a14

Datei anzeigen

@ -1,10 +1,7 @@
package de.steamwar.bungeecore; package de.steamwar.bungeecore;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import de.steamwar.sql.EventFight; import de.steamwar.sql.*;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.Tutorial;
import lombok.Getter; import lombok.Getter;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -140,7 +137,17 @@ public class ServerStarter {
SubserverSystem.sendPlayer(subserver, p); SubserverSystem.sendPlayer(subserver, p);
return false; return false;
} }
return true; boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> {
if (player.getUniqueId().equals(owner)) return true;
BauweltMember bauweltMember = BauweltMember.getBauMember(owner, player.getUniqueId());
return bauweltMember.isSupervisor();
});
if (!atLeastOneSupervisor) {
for (ProxiedPlayer p : playersToSend) {
ChatSender.of(p).system("BAU_START_NOT_ALLOWED");
}
}
return atLeastOneSupervisor;
}; };
return this; return this;
@ -193,7 +200,7 @@ public class ServerStarter {
// Send players to existing server // Send players to existing server
startCondition = () -> { startCondition = () -> {
Builderserver subserver = Builderserver.get(worldName); Builderserver subserver = Builderserver.get(worldName);
if(subserver != null) { if (subserver != null) {
for(ProxiedPlayer p : playersToSend) for(ProxiedPlayer p : playersToSend)
SubserverSystem.sendPlayer(subserver, p); SubserverSystem.sendPlayer(subserver, p);
return false; return false;

Datei anzeigen

@ -170,52 +170,52 @@ public class BauCommand extends SWCommand {
Chat19.chat(p, "/bauinfo"); Chat19.chat(p, "/bauinfo");
} }
@Register("togglewe") @Register("setspectator")
public void togglewe(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { public void setSpectator(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
if (user == null) { if (user == null) {
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "togglewe"); Message.send("BAU_MEMBER_SET_USAGE", p, "setspectator");
return; return;
} }
BauweltMember target = member(p, user); BauweltMember target = member(p, user);
if (target == null) if (target == null)
return; return;
target.setWorldEdit(!target.isWorldEdit()); target.setBuild(false);
target.setSupervisor(false);
clearMembercache(p); clearMembercache(p);
isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT"); sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SPECTATOR");
} }
@Register("toggleworld") @Register("setbuild")
public void toggleworld(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { public void setBuild(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
if (user == null) { if (user == null) {
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleworld"); Message.send("BAU_MEMBER_SET_USAGE", p, "setbuild");
return; return;
} }
BauweltMember target = member(p, user); BauweltMember target = member(p, user);
if (target == null) if (target == null)
return; return;
target.setWorld(!target.isWorld()); target.setBuild(true);
target.setSupervisor(false);
clearMembercache(p); clearMembercache(p);
isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD"); sendPermissionUpdate(p, target, "BAU_MEMBER_SET_BUILDER");
} }
@Register("toggleall") @Register("setsupervisor")
public void toggleall(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { public void setSupervisor(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
if (user == null) { if (user == null) {
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleall"); Message.send("BAU_MEMBER_SET_USAGE", p, "setsupervisor");
return; return;
} }
BauweltMember target = member(p, user); BauweltMember target = member(p, user);
if (target == null) if (target == null)
return; return;
boolean state = !target.isWorldEdit() || !target.isWorld(); target.setBuild(true);
target.setWorldEdit(state); target.setSupervisor(true);
target.setWorld(state);
clearMembercache(p); clearMembercache(p);
isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT"); sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SUPERVISOR");
isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD");
} }
private static void clearMembercache(ProxiedPlayer p){ private static void clearMembercache(ProxiedPlayer p){
@ -331,17 +331,10 @@ public class BauCommand extends SWCommand {
return target; return target;
} }
private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){ private static void sendPermissionUpdate(ProxiedPlayer p, BauweltMember target, String what){
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID()); ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
if(player != null)
if(permission){ Message.send("BAU_MEMBER_SET_TARGET", player, p.getName(), Message.parse(what, player));
if(player != null) Message.send("BAU_MEMBER_SET", p, Message.parse(what, p));
Message.send("BAU_MEMBER_TOGGLE_TARGET", player, p.getName(), Message.parse(what, player));
Message.send("BAU_MEMBER_TOGGLE", p, Message.parse(what, p));
}else{
if(player != null)
Message.send("BAU_MEMBER_TOGGLE_TARGET_OFF", player, p.getName(), Message.parse(what, player));
Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p));
}
} }
} }

Datei anzeigen

@ -227,13 +227,13 @@ BAU_DELETE_GUI_CANCEL=§cCancel
BAU_DELETE_GUI_DELETE=§aDelete BAU_DELETE_GUI_DELETE=§aDelete
BAU_START_ALREADY=§cThis server is already starting. BAU_START_ALREADY=§cThis server is already starting.
BAU_MEMBER_NOMEMBER=§cThis player is no member of your world! BAU_MEMBER_NOMEMBER=§cThis player is no member of your world!
BAU_MEMBER_TOGGLE_USAGE=§8/§7build {0} §8[§eplayer§8] BAU_MEMBER_SET_USAGE=§8/§7build {0} §8[§eplayer§8]
BAU_MEMBER_TOGGLE_TARGET=§aYou are now allowed to §a{1}§e on the world of §e{0}. BAU_MEMBER_SET_TARGET=§7You are now a §e{1}§7 on the world of §e{0}§7.
BAU_MEMBER_TOGGLE=§aThe player is now allowed to {0}. BAU_MEMBER_SET=§7The player is now a §e{0}§7.
BAU_MEMBER_TOGGLE_TARGET_OFF=§cYou are no longer allowed to §a{1}§e on the world of §e{0}. BAU_MEMBER_SET_SPECTATOR = spectator
BAU_MEMBER_TOGGLE_OFF=§cThe player no longer can {0}. BAU_MEMBER_SET_BUILDER = builder
BAU_MEMBER_TOGGLE_WORLD_EDIT = use WorldEdit BAU_MEMBER_SET_SUPERVISOR = supervisor
BAU_MEMBER_TOGGLE_WORLD = change Settings BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server.
#ChallengeCommand #ChallengeCommand
CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8] CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8]

Datei anzeigen

@ -210,13 +210,13 @@ BAU_DELETE_GUI_CANCEL=§cAbbrechen
BAU_DELETE_GUI_DELETE=§aLöschen BAU_DELETE_GUI_DELETE=§aLöschen
BAU_START_ALREADY=§cDer Server startet bereits. BAU_START_ALREADY=§cDer Server startet bereits.
BAU_MEMBER_NOMEMBER=§cDer Spieler ist kein Mitglied deiner Welt! BAU_MEMBER_NOMEMBER=§cDer Spieler ist kein Mitglied deiner Welt!
BAU_MEMBER_TOGGLE_USAGE=§8/§7bau {0} §8[§eSpieler§8] BAU_MEMBER_SET_USAGE=§8/§7bau {0} §8[§eSpieler§8]
BAU_MEMBER_TOGGLE_TARGET=§aDu kannst nun auf der Welt von §e{0}§a {1}. BAU_MEMBER_SET_TARGET=§7Du bist nun ein §e{1}§7 auf der Welt von §e{0}§7.
BAU_MEMBER_TOGGLE=§aDer Spieler darf nun {0}. BAU_MEMBER_SET=§7Der Spieler ist nun §e{0}§7.
BAU_MEMBER_TOGGLE_TARGET_OFF=§cDu kannst nun nicht mehr auf der Welt von §e{0}§c {1}. BAU_MEMBER_SET_SPECTATOR = Zuschauer
BAU_MEMBER_TOGGLE_OFF=§cDer Spieler darf nun nicht mehr {0}. BAU_MEMBER_SET_BUILDER = Builder
BAU_MEMBER_TOGGLE_WORLD_EDIT = WorldEdit verwenden BAU_MEMBER_SET_SUPERVISOR = Supervisor
BAU_MEMBER_TOGGLE_WORLD = Einstellungen vornehmen BAU_START_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht starten.
#ChallengeCommand #ChallengeCommand
CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8] CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8]