From 45e39646debf03cf180d74f5fd32d85877cb8f61 Mon Sep 17 00:00:00 2001 From: Albert Pulchny Date: Tue, 28 Oct 2025 15:33:46 +0100 Subject: [PATCH 1/2] SetGroup Method! New method allowing you to set or remove user group for specified players! --- .../Methods/PlayerMethods/SetGroupMethod.cs | 24 +++++++++++++++++++ SER.csproj | 1 + 2 files changed, 25 insertions(+) create mode 100644 MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs diff --git a/MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs b/MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs new file mode 100644 index 0000000..d487b18 --- /dev/null +++ b/MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using SER.ArgumentSystem.Arguments; +using SER.ArgumentSystem.BaseArguments; +using SER.MethodSystem.BaseMethods; +using LabApi.Features.Wrappers; + +namespace SER.MethodSystem.Methods.PlayerMethods; + +public class SetGroupMethod : SynchronousMethod +{ + public override string Description => "Sets or removes group from specified players"; + + public override Argument[] ExpectedArguments => [ + new PlayersArgument("players"), + new TextArgument("group"){Description = "Name of the group or set to NONE if you want to remove group from specified players" } + ]; + + public override void Execute() + { + string gr = Args.GetText("group"); + List pls = Args.GetPlayers("players"); + pls.ForEach(p=>p.UserGroup = ServerStatic.PermissionsHandler.GetGroup(gr == "NONE" ? null: gr)); + } +} \ No newline at end of file diff --git a/SER.csproj b/SER.csproj index 609eef1..feff6ec 100644 --- a/SER.csproj +++ b/SER.csproj @@ -208,6 +208,7 @@ + From cb16d4dc4ec7f8eeb68843deeda2a401edf6c3d9 Mon Sep 17 00:00:00 2001 From: Albert Pulchny Date: Tue, 28 Oct 2025 18:10:33 +0100 Subject: [PATCH 2/2] SetGroup Method Fix Method works. WARNING If you want to remove the group from players, from unknown reason, badge name still exists next to the player nickname in player list. --- MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs b/MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs index d487b18..2afb91d 100644 --- a/MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs +++ b/MethodSystem/Methods/PlayerMethods/SetGroupMethod.cs @@ -19,6 +19,9 @@ public override void Execute() { string gr = Args.GetText("group"); List pls = Args.GetPlayers("players"); - pls.ForEach(p=>p.UserGroup = ServerStatic.PermissionsHandler.GetGroup(gr == "NONE" ? null: gr)); + foreach(Player p in pls) + { + p.UserGroup = gr == "NONE" ? null : ServerStatic.PermissionsHandler.GetGroup(gr); + } } } \ No newline at end of file