PEXPlugins / PermissionsEx

A powerful permissions plugin for Minecraft
https://permissionsex.stellardrift.ca
Apache License 2.0
479 stars 297 forks source link

[Sponge] Events #2139

Open Favorlock opened 9 years ago

Favorlock commented 9 years ago

Will you be adding any events for sponge? Would be really helpful for 3rd party plugins that need to listen for when a players group changes, etc. Would like to be able to support PEX early on in the Sponge version of the Enjin plugin, but without a means to listen for group changes I can't support it.

zml2008 commented 9 years ago

I plan to add events -- mostly been debating how to structure events best with PEX's new structure.

My current plan, for subject-specific events, is to just have an event that is cancellable with old subject, new subject, making it the listener's job to figure out what changes are relevant.

System event will most likely be similar to before, or perhaps even simpler, just a reload event. Unsure currently.

zml2008 commented 9 years ago

So I'm not sure if this way of going forward makes sense. Current, what PermissionsEx uses internally is instances of the Caching interface, which are called any time data is updated with the new data. However, this system is not very well exposed to higher-level objects like CalculatedSubject or SubjectDataReference. I'm thinking the simplest way to handle folks wanting to listen for changes is to tweak SubjectDataReference to allow registering arbitrary listeners. That fits well with the way that PEX works internally, but for the Sponge permissions API something different would have to be used -- especially since the Sponge API .

Also keep in mind that the Caching system only holds weak references to listeners -- so if the listener isn't being held on to by anything else, it's removed.

Favorlock commented 8 years ago

I see. I'll be happy as long as I have a way to listen for when a rank is changed. Considering that PEX is the only plugin that appears to be usable with Sponge it'll be nice to be able to offer extended permission functionality that the Enjin plugin relies on.

Favorlock commented 8 years ago

Any news on this?

Favorlock commented 8 years ago

Still no news on this?

zml2008 commented 8 years ago

Right now what you probably want to do is to add a listener to a SubjectDataReference (gotten from pex.getSubjects(SUBJECTS_USER).persistentData().getReference(player.getUniqueId().toString());

(as well as the one from transientData)

You just have to keep the SubjectDataReference instance around to prevent the listener from getting garbage-collected.

Let me know if that's enough to deal with your usecase. The one thing that might be a blocker for that is if the reference's state is updated before listeners are called, but that should be able to be swapped pretty easily.

Favorlock commented 8 years ago

@zml2008 I can't call getManager from outside the same package it would appear.

Asides from that issue I was able to make it work by creating a class in "ninja.leaping.permissionsex.sponge" package.

Favorlock commented 8 years ago

@zml2008 any chance you've made changes to make it possible to move my class whever I want?

zml2008 commented 6 years ago

Unfortunately PermissionsEx is currently unmaintained and no further updates are planned. Because of this, all pull requests are being closed. If you are looking for an actively maintained permissions plugin, take a look at LuckPerms. It is compatible with major server platforms and can import data from PEX.