Add ServerChangeMaxPlayerSlotsEvent#11710
Conversation
|
Hi and welcome to paper 🥳 Thank you for your first PR. We generally do not provide API for plugin calls as it makes interoperability between plugins a bit iffy if a plugin cannot rely on its API calls being executed. |
|
Hi! What are you referring to? Are you referring the cancelability / setMaxPlayers in the event or are you concerned about the event in general? Regarding the event in general: |
|
Yea I am concerned about the event in general. Regarding a player queue, the max players are only ever updated this way by other plugins. I am unsure of how many plugins I know that change the max player count like this, especially in the context of server networks, where this kind of logic is probably better of at the queue level itself, rather than a server deciding its own max player limit. |
|
So you are saying that we would have to recode every plugin or ask for a changeevent on their side to provide this functionallity? I mean really the other choice is to send a request from the velocity to the server every tick in order to fetch this state change? |
|
Well no, I am not saying anything, I was just asking what kind of third party plugins exist that change the max player numbers like this on their own without being prompted to do so. It sounds like a rather destructive way of managing a full server on the plugins part, so I am just curious. I am mostly asking because, as stated prior, we generally are not a fan of events for this as plugins expect their API calls to work. |
|
https://www.spigotmc.org/resources/changeslots-change-max-players-slots-bukkit-bungee.49648/ - Easy Plugin - Could do this on our own with no issue This plugin is the main issue we are currently having, resulting in us trying to have this event included. Other than that you could take any gamemode (BedWars, SkyWars, etc.). Some of them change the playercount when the plugin is loaded resulting in the velocity not knowing the max player count anymore. |
|
That plugin doesn't even modify the slots in a manner that this event would fire; It's long been tradition that, outside of some very key explicit areas, events are not fired; if a plugin does something, that operation occurs. I can maybe understand notification-esque events for some of this stuff, but, not fond of aspects like cancellation |
You are right. They did some kind of update where they are setting this via reflections for some reason. Nevermind on that plugin then. Doesnt change the fact that other plugins do it via the correct .setMaxPlayers method. |
|
Well the reason I am asking so much for a usecase is that, for API we are generally not happy to include due to the mentioned reasons), we'd need a really good usecase to justify that. As cat stated, a notification-like event should solve your usecase? (e.g. no setters or cancellation) |
This pull request introduces a new event to handle changes in the maximum number of player slots on the server. The changes include the addition of a new event class and its integration into the server code.
Event Addition:
patches/api/0502-Add-ServerChangeMaxPlayerSlotsEvent.patch: Added a new event classServerChangeMaxPlayerSlotsEventto handle changes in the maximum number of player slots. This class includes methods to get and set the old and new maximum player slots, as well as to handle event cancellation.Server Integration:
patches/server/1073-Add-ServerChangeMaxPlayerSlotsEvent.patch: Integrated theServerChangeMaxPlayerSlotsEventinto theCraftServerclass. The event is called when the maximum number of player slots is set, allowing for the new maximum to be adjusted or the event to be cancelled.