Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to change max players by a command #5989

Open
wants to merge 1 commit into
base: minor-next
Choose a base branch
from

Conversation

JavierLeon9966
Copy link
Contributor

@JavierLeon9966 JavierLeon9966 commented Aug 12, 2023

Introduction

Sometimes we want to limit the number of players that can join our server without needing to restart it and have to make them rejoin it and possibly make unwanted players join in the process. This pull request adds the /setmaxplayers command to change the max player count during runtime.

Relevant issues

None

Changes

API changes

None

Behavioural changes

None

Backwards compatibility

None

Follow-up

Requires translations:

Name Value in eng.ini
commands.setmaxplayers.success Set max players to {%0}.
commands.setmaxplayers.success.lowerbound (Bound to current player count)
commands.setmaxplayers.usage /setmaxplayers <maxPlayers>
pocketmine.command.setmaxplayers.description Sets the maximum number of players for this server.
pocketmine.permission.command.setmaxplayers Allows the user to change the max player count

Tests

TODO

@dktapps
Copy link
Member

dktapps commented Aug 15, 2023

I feel like this is better suited to a plugin

@SOF3
Copy link
Member

SOF3 commented Aug 15, 2023

First, the changes to Server.php must be merged to make this possible through a plugin.

Second, this is a BC break. There might be plugins assuming an new SplFixedArray($server->getMaxPlayers()) and end up overflowing.

@dktapps
Copy link
Member

dktapps commented Aug 15, 2023

First, the changes to Server.php must be merged to make this possible through a plugin.

I hadn't actually noticed this wasn't currently possible. In that case, we should probably add some actual APIs rather than using configs for this.

I still don't think a command for this is appropriate for the core though.

@JavierLeon9966
Copy link
Contributor Author

I hadn't actually noticed this wasn't currently possible. In that case, we should probably add some actual APIs rather than using configs for this.

I still don't think a command for this is appropriate for the core though.

At first I considered making Server->setMaxPlayers() with validation checks, but then I realized Server had no set methods and it used the config instead, so I decided to opt for that for consistency.

Second, this is a BC break. There might be plugins assuming an new SplFixedArray($server->getMaxPlayers()) and end up overflowing.

I also considered limiting it to Limits::INT32_MAX because Minecraft uses that for the max player count and anything above that goes into the negatives, but I chose PHP_INT_MAX to be consistent with the config which has no bounds checks.

@ShockedPlot7560 ShockedPlot7560 added Category: API Related to the plugin API Category: Core Related to internal functionality Requires translations Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Aug 30, 2023
@dktapps dktapps added the BC break Breaks API compatibility label Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC break Breaks API compatibility Category: API Related to the plugin API Category: Core Related to internal functionality Requires translations Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants