Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add player whitelist events

Open SageSphinx63920 opened this issue 2 years ago • 21 comments

This pr add events when a player is being removed from the whitelist or added.

SageSphinx63920 avatar May 14 '23 11:05 SageSphinx63920

Thx! I've done some patching before but first time on paper

SageSphinx63920 avatar May 14 '23 11:05 SageSphinx63920

So we do have 2 opinions here: One is getting the player is up to the plugin, which would be useful for plugins that add custom behavior like an own whitelist system and the other saying we should pass an OfflinePlayer because other whitelist related API does it. Which one is the best now?

SageSphinx63920 avatar May 15 '23 16:05 SageSphinx63920

One doesn't really dismiss the other, a whitelist plugin might be using their own system but providing the OfflinePlayer/PlayerProfile is still valuable data.

emilyy-dev avatar May 15 '23 17:05 emilyy-dev

i think if its no additional server load providing the OfflinePlayer is a good idea.

Leguan16 avatar May 15 '23 19:05 Leguan16

Is using org.bukkit.Bukkit.getOfflinePlayer(profile.getId()) the way i should do this?

SageSphinx63920 avatar May 15 '23 19:05 SageSphinx63920

Is using org.bukkit.Bukkit.getOfflinePlayer(profile.getId()) the way i should do this?

yes :+1:

lynxplay avatar May 24 '23 06:05 lynxplay

I would say to provide the PlayerProfile the default, but then have a utility in the event to provide an OfflinePlayer if needed. That way it will only be retrieved if needed, and later calls will use the cached version.

Owen1212055 avatar May 28 '23 18:05 Owen1212055

Do you mean the vanilla used player profile or the paper implementation? And should I only make a getter for the profile or also one that converts the profile into an offline player

SageSphinx63920 avatar May 28 '23 18:05 SageSphinx63920

In the event, pass a paper PlayerProfile, where then there would be a utility method in the event that uses the provided player profile to fetch an OfflinePlayer.

So you'd have both

Owen1212055 avatar May 28 '23 18:05 Owen1212055

@Owen1212055 done

SageSphinx63920 avatar May 30 '23 11:05 SageSphinx63920

Is this ready to merge then?

SageSphinx63920 avatar May 31 '23 20:05 SageSphinx63920

I think that having target interfaces for events in general might be an idea; I’m also not 100% sure about separate events for add/remove, maybe a single event and an action?

electronicboy avatar Jun 01 '23 07:06 electronicboy

maybe a single event and an action?

that's what i initially thought. Don't really see a reason for having 2 separate events. Just means unnecessary code on both sides (paper and plugin). Having a WhitelistChangeEvent with an ADD and REMOVE enum constant would do it imo.

Leguan16 avatar Jun 01 '23 07:06 Leguan16

I decided to make this use a single event for both updates

SageSphinx63920 avatar Jun 03 '23 20:06 SageSphinx63920

Isn't the event already called PlayerWhitelistUpdateEvent

SageSphinx63920 avatar Jun 03 '23 20:06 SageSphinx63920

The enum

electronicboy avatar Jun 03 '23 20:06 electronicboy

So i should call it WhitelistStatus?

SageSphinx63920 avatar Jun 03 '23 20:06 SageSphinx63920

Yes

On Sat, 3 Jun 2023, 21:14 Sage, @.***> wrote:

So i should call it WhitelistStatus?

— Reply to this email directly, view it on GitHub https://github.com/PaperMC/Paper/pull/9209#issuecomment-1575171202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJMAZESYHFK5N7YGS7K5L3XJOLKHANCNFSM6AAAAAAYBCZ3NE . You are receiving this because your review was requested.Message ID: @.***>

electronicboy avatar Jun 03 '23 20:06 electronicboy

Any changes i should do?

SageSphinx63920 avatar Jun 04 '23 12:06 SageSphinx63920

Will this be merged before the 1.20 release of paper?

SageSphinx63920 avatar Jun 07 '23 20:06 SageSphinx63920

just keep it up to date and it will be merged eventually.

Leguan16 avatar Jun 09 '23 12:06 Leguan16