not worked server.pluginManager.getPlugin('PermissionsEx')
lastuniverse opened this issue ยท 3 comments
I have a spigot v 1.11.2 and installed PermissionsEx
var pex = server.pluginManager.getPlugin('PermissionsEx');
if (pex.getUser(sender).inGroup('admin') ) {
console.log("pex isAdmin "+sender.name);
}
[05:53:10 ERROR]: Could not pass event PlayerCommandPreprocessEvent to scriptcraft v3.2.1-2016-12-23
jdk.nashorn.internal.runtime.ECMAException: TypeError: pex.getUser is not a function
Just a note to update this request... After I get through some other basic changes, I'm going to take some time to access plugins like this and see how they behave in this environment.
The thing to do in a case like this to find out what you have and then work out how to get what you want. So my questions for the current issue (and I'll test it myself too...):
-
What is the value of
sender
? Is it an instanceofPlayer
? ofCommandSender
? -
Is
pex
an object? DidgetPlugin()
return null? Is it an object of typePlugin
? -
What might this return?
var enabled = server.pluginManager.isPluginEnabled("PermissionsEx"); //true/false?
I'd try this too...
var pex = server.pluginManager.getPlugin('PermissionsExPlugin');
if (pex.getManager().getUser(sender).inGroup('admin') ) {
console.log("pex isAdmin "+sender.name);
}
or...
if(pex !== null) {
var mgr = pex.getManager(); // instance of PermissionManager
if(mgr !== null) {
var user = mgr.getUser(sender); // instance of PermissionUser
}
}
There are a few overloads of the getUser() method. Try a couple others. See here and look further down in the code for others.
Find out where it falls down.
I'll come back around to this as time permits.
Thank you.
So it happened that I wrote with my fool my own pex, somewhat expanding its functionality (added not only permissions but also options)
module:
Https://github.com/lastuniverse/scripcraft_plugins/blob/master/modules/last/permissions.js
settings file for groups:
https://github.com/lastuniverse/scripcraft_plugins/blob/master/data/config/modules/last/permissions/groups.json
user settings file:
Https://github.com/lastuniverse/scripcraft_plugins/blob/master/data/config/modules/last/permissions/users.json
Now I will think how I will get rid of my option in favor of the standard PermissionEx :)