SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.06k stars 368 forks source link

Addons update and NoSuchFieldError hasDelayBefore #4012

Closed TPGamesNL closed 2 years ago

TPGamesNL commented 3 years ago

Due to a recent update to the internal workings of Skript, many addons need updating, otherwise some of their syntaxes won't work on the latest Skript version. The change causing this, is PR #3924, which introduces parallel script loading. Skript had to be changed internally for this system to work, and a lot of addons could break in the process of this change.

If you see a big error in console, with the phrase java.lang.NoSuchFieldError: currentScript, java.lang.NoSuchFieldError: currentSections, java.lang.NoSuchFieldError: currentLoops or java.lang.NoSuchFieldError: hasDelayBefore, this is probably why.

Affected addons

The addons below have been (partially) broken by this update, and will need to be updated. If an addon you use is not in this list, it might still be affected. I've checked all addons that are available on SkriptTools.net, so if an addon you use is on that site, but not in this list, then this update probably didn't break it.

Do note that addons on this list will probably still work, but some syntaxes of the addons can be broken.

What users can do to fix this

You should report this issue to the addon author. Unfortunately, not all addons are still maintained. For that reason, SkriptAddonPatcher has been created. This tool patches addons so that they work with the new system. The instructions on how to use it, can be found on the GitHub page of the patcher tool. You can also use this tool if the addon hasn't updated yet, but you do want to start using the new Skript update.

Another tool that can be used is RuntimeSkriptAddonPatcher, which is based on SkriptAddonPatcher, but as a plugin. This plugin is easier to use then the tool, see the README for instructions on how to use the plugin.

What addon developers can do to fix this

If you want to check if your addon needs to be updated, you can use the patcher tool, which shows if your addon needs to be updated, and it shows which classes have to be updated. The tool checks if your addon use any of the following fields:

Usages of these fields can be replaced with getters and setters in the ScriptLoader class:

Once you have replaced the field usages with these getters and setters, it should work again, so if you want to quickly update the addon to make it work, you can stop here.

You will notice that these methods you just used are deprecated, and so are a lot of other methods in ScriptLoader, such as isCurrentEvent(Class<? extends Event>). All of these methods have been moved to the ParserInstance class, and are no longer static. To get an ParserInstance object, use ParserInstance.get(), using this you can call your methods as you would previously on the ScriptLoader class. Because ParserInstance.get() is rather long, the method getParser() is available in all syntax element classes, for example see ExprMe

TPGamesNL commented 3 years ago

I've also created RuntimeSkriptAddonPatcher, which is easier to use as it's just a plugin you can put on your server. See the README for instructions on how to use it.