Skip to content

Marking plugins as enabled after onEnable executes#14073

Closed
TurboJax wants to merge 1 commit into
PaperMC:mainfrom
TurboJax:move_enable
Closed

Marking plugins as enabled after onEnable executes#14073
TurboJax wants to merge 1 commit into
PaperMC:mainfrom
TurboJax:move_enable

Conversation

@TurboJax

Copy link
Copy Markdown

I was using this.isEnabled() to check if my plugin was being enabled twice. This caused the init to get messed up because all plugins are marked as enabled before onEnable is executed. I changed it to update enabled after the plugin is enabled/disabled so that people can check this flag in their onEnable functions.

@TurboJax
TurboJax requested a review from a team as a code owner July 16, 2026 23:38
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Jul 16, 2026

@Strokkur424 Strokkur424 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why the massive diff? From what this does, it seems to me that simply replacing if (isEnable) with if (enabled) and moving the isEnable = enabled; assignment after the if/else would've sufficed.

Anyways, I don't know about potential implications of what this might cause to behave differently, I leave this up to someone with more knowledge in the plugin loading system.

@TurboJax

TurboJax commented Jul 17, 2026

Copy link
Copy Markdown
Author

I also changed some of the logic to remove some nesting.

Basically just

if (x) {
  // do x
}

to

if (!x) {
    return;
}

// do x

You are right though, just that would've been fine.

@masmc05

masmc05 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Wouldn't this break a lot of api checks like scheduling tasks in onEnable? Also I agree that tons of plugins definitely already depends too much on this behaviour, it's too old to be touched

@TurboJax

Copy link
Copy Markdown
Author

I could totally run through and find all those checks. That kind of thing should probably use the more specific isBeingEnabled variable, though that currently doesn't have a public accessor. I could add that though!

@mbax

mbax commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The big issue is this would break any plugin relying on this behavior in their onEnable.

@Malfrador

Copy link
Copy Markdown
Member

I don't really understand the usecase here. How is your plugin "being enabled twice"? That should not happen during normal startup, duplicate plugins are simply not loaded.
And plugin enabling/disabling/reloading at runtime is entirely unsupported.

@masmc05

masmc05 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

I feel like the proper solution is for your plugin to have this flag that you track and check it instead of isEnable. Even if you increase this pr from a 50 lines change to a 50000 lines change to adapt the rest of the api, you won't be able to adapt the plugins. And if you're fine with isBeingEnabled but you need it in the API and not a private field in your own plugin, then I think this is more of a xy problem that you could get help with in discord instead

@TurboJax

Copy link
Copy Markdown
Author

Alright, if it's gonna cause trouble, I'll just close this then.

@TurboJax TurboJax closed this Jul 17, 2026
@github-project-automation github-project-automation Bot moved this from Awaiting review to Closed in Paper PR Queue Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

5 participants