From 2c12935250f0cee5fbebb226f76dff9b597adcf2 Mon Sep 17 00:00:00 2001 From: zontreck Date: Tue, 9 Jan 2024 14:21:40 -0700 Subject: [PATCH] Add a playerIsOp helper function to ServerUtilities --- gradle.properties | 2 +- .../zontreck/libzontreck/util/ServerUtilities.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 02b099a..1e0798d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPLv3 # The mod version. See https://semver.org/ -mod_version=1.10.010924.0329 +mod_version=1.10.010924.1421 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java b/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java index be9cadb..abd8d57 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java +++ b/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java @@ -82,4 +82,18 @@ public class ServerUtilities if(LibZontreck.THE_SERVER.getPlayerList().getPlayer(ID) == null) return true; else return false; } + + /** + * Checks if the user has operator permissions on the server + * @param ID The player ID + * @return True if the player is op + */ + public static boolean playerIsOp(UUID ID) + { + ServerPlayer player = getPlayerByID(ID.toString()); + if(player.hasPermissions(player.getServer().getOperatorUserPermissionLevel())) + { + return true; + }else return false; + } } \ No newline at end of file