From c5049990a38957e9d20b8b7cea4cef34557342c4 Mon Sep 17 00:00:00 2001 From: Corey D Date: Sat, 12 Feb 2022 23:14:57 +1100 Subject: [PATCH] Add bitwise SetBitFlags for AdminId and GroupId (#1677) * Add bitwise SetFlags for AdminId * Inline SetFlags natives --- plugins/include/admin.inc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/plugins/include/admin.inc b/plugins/include/admin.inc index 2e1eb90d..b861c767 100644 --- a/plugins/include/admin.inc +++ b/plugins/include/admin.inc @@ -191,6 +191,20 @@ methodmap AdminId { // @param enabled True to enable, false to disable. public native void SetFlag(AdminFlag flag, bool enabled); + // Sets multiple bitwise flags to be enabled/disabled on an admin. + // + // @param flags Bitwise admin flags (ADMFLAG_*). + // @param enabled True to set the flag, false to unset/disable. + public void SetBitFlags(int flags, bool enabled) + { + AdminFlag flagArray[AdminFlags_TOTAL]; + int num = FlagBitsToArray(flags, flagArray, sizeof(flagArray)); + for (int i = 0; i < num; i++) + { + this.SetFlag(flagArray[i], enabled); + } + } + // Returns whether or not a flag is enabled on an admin. // // @param flag Admin flag to use. @@ -278,6 +292,20 @@ methodmap GroupId { // @param enabled True to set the flag, false to unset/disable. public native void SetFlag(AdminFlag flag, bool enabled); + // Adds or removes multiple bitwise flags from a group's flag set. + // + // @param flags Bitwise admin flags (ADMFLAG_*). + // @param enabled True to set the flag, false to unset/disable. + public void SetBitFlags(int flags, bool enabled) + { + AdminFlag flagArray[AdminFlags_TOTAL]; + int num = FlagBitsToArray(flags, flagArray, sizeof(flagArray)); + for (int i = 0; i < num; i++) + { + this.SetFlag(flagArray[i], enabled); + } + } + // Returns the flag set that is added to users from this group. // // @return Bitstring containing the flags enabled.