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

Add API to allow/disallow tick sleeping #11611

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Abelkrijgtalles
Copy link
Contributor

Hi,
I added a simple API to Server which allows or disallows the server sleeping, as requested in #11511.
This works with a simple boolean in MinecraftServer which is now one of the requirements to sleep.
CraftServer sets this boolean whenever Server#allowSleeping gets called.
That's all, and I wish you a wonderful rest of your day!

@Abelkrijgtalles Abelkrijgtalles requested a review from a team as a code owner November 12, 2024 21:33
@Abelkrijgtalles
Copy link
Contributor Author

I could also add a check which puts the server out of sleep when this gets called.

@Abelkrijgtalles
Copy link
Contributor Author

I have implemented the changes. The original reason to make it static was a bit dumb, because I didn't know that MinecraftServer#getServer existed. The good thing is that you learn from your mistakes :)

@jpenilla
Copy link
Member

plugins could easily step on each other like this, it might be best to have this be a list of plugins blocking sleep or something to that effect instead

@Abelkrijgtalles
Copy link
Contributor Author

Abelkrijgtalles commented Nov 14, 2024

plugins could easily step on each other like this, it might be best to have this be a list of plugins blocking sleep or something to that effect instead

Something like that all plugins have to allow it, but when only one plugin disallows it (and the others allow it) that pausing still gets disabled?

@Abelkrijgtalles
Copy link
Contributor Author

The new system adds a Map<JavaPlugin, Boolean> to CraftServer. When the hashmap contains the value false (a plugin not allowing pausing), the server will not pause.

@Abelkrijgtalles
Copy link
Contributor Author

I don't know how to fix this test error. Could I maybe get a bit of help?

Copy link
Contributor

@Leguan16 Leguan16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should fix the test.

patches/api/0496-API-to-allow-disallow-tick-sleeping.patch Outdated Show resolved Hide resolved
@Abelkrijgtalles
Copy link
Contributor Author

The tests are fixed.

@jpenilla
Copy link
Member

I don't think a map is needed - a list or set should be enough. If the collection is not empty then sleep would be blocked.

@Abelkrijgtalles
Copy link
Contributor Author

I don't think a map is needed - a list or set should be enough. If the collection is not empty then sleep would be blocked.

I have made these changes, the only thing is that Intellij randomly imported a bunch of things, but hopefully this isn't a problem.

@Abelkrijgtalles
Copy link
Contributor Author

I am now using FQN imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Changes required
Development

Successfully merging this pull request may close these issues.

4 participants