Skip to content

Predefined Plugin RequiredApiVersion#370

Open
tayjay wants to merge 4 commits intonorthwood-studios:masterfrom
tayjay:default-labapi-version
Open

Predefined Plugin RequiredApiVersion#370
tayjay wants to merge 4 commits intonorthwood-studios:masterfrom
tayjay:default-labapi-version

Conversation

@tayjay
Copy link

@tayjay tayjay commented Mar 6, 2026

Small change for consideration.

Usually a plugin is made for the LabAPI version it's built with. This can be found in the LabAPI plugin example as well https://github.com/northwood-studios/LabAPI/wiki/Writing-Your-First-Plugin.

Proposed change is to set the Plugin#RequiredApiVersion using LabApiProperties.CompiledVersion in the base class and change the member from abstract to virtual. This will still allow developers to change the version if they prefer, but will not be a required override.

It's 1 less boilerplate step for making new plugins.

@Axwabo
Copy link
Contributor

Axwabo commented Mar 7, 2026

Unfortunately, this change is not viable. At the moment, CompiledVersion is not a const, so it does nothing. If it was a const, this would get evaluated at LabAPI's compile time, not at the plugin's compile time.

@louis1706
Copy link

Unfortunately, this change is not viable. At the moment, CompiledVersion is not a const, so it does nothing. If it was a const, this would get evaluated at LabAPI's compile time, not at the plugin's compile time.

despite making it virtual it's a good idea

@Axwabo
Copy link
Contributor

Axwabo commented Mar 9, 2026

despite making it virtual it's a good idea

@louis1706 Could you rephrase this?

@louis1706
Copy link

despite making it virtual it's a good idea

@louis1706 Could you rephrase this?

Making it virtual is a good idea :3

@Axwabo
Copy link
Contributor

Axwabo commented Mar 11, 2026

Making it virtual is a good idea :3

What would the default value be then?

@tayjay
Copy link
Author

tayjay commented Mar 11, 2026

(I misread your original comment, but the runtime result is still the same)

I was looking into that and noticed, CompiledVersion is static readonly, not const. So it will be evaluated at runtime with the latest version, not compile time. I expect this is not desired behaviour but the decompiled API and plugin both show it's calculating on runtime, not a baked string.
image
image
I'll take a minute later to confirm on a server.

@tayjay
Copy link
Author

tayjay commented Mar 11, 2026

RequiredApiVersion in the Plugin class would need to be a const to keep its compile time version. Changing from abstract to virtual doesn't change the behaviour of the current calculated version, it will always be the runtime version of LabAPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants