![[​IMG]](/proxy/image?url=https%3A%2F%2Fhaxe.org%2Fimg%2Fbranding%2Fhaxe-logo-white-background.png)
​
This plugin (loader) allows you to load plugins for Spigot servers written in the Haxe programming language. It uses
its own custom API to access Minecraft's features.
What is Haxe?
Haxe is a high-level programming language and toolkit that can transpile its code to various different target programming languages.
Who should use this?
Everyone can use this for free, but the main users are probably something along the following:
- Haxe enthusiasts and people who prefer it over Java.
- People who are looking for an easy way to create simple plugins or do not like the Spigot API.
- People who like experimentation or like to try something new.
Features / technical aspects
This section will briefly explain some of the technical aspects/features of this loader. The Haxe Minecraft API is experimental and does not include all the features Spigot has.
How does it work?
Essentially, executing Haxe code from a Minecraft server works through a popular principle called dependency inversion. A set of interfaces is created in Haxe defining the functions that give us access to Minecraft's functionality. The interfaces are transipled to Java and the loader is an adapter for these interfaces. Basically the loader translates our Haxe function calls to Spigot function calls, but it has lots of (complex) systems and fancy optimizations behind the scenes.
Performance
Some of you may think that this is just another layer of bloat slowing things down. That is true in the sense that the code itself won't be faster and plugin file size won't be smaller than traditional Spigot plugins. But for the developers this might be very innovative, and there are systems built into the loader to take care of most performance issues. The most important one being the automatic multi-threading system, inspired by the way mobile phone apps run multi-threaded.
Every trigger for a plugin's code will start a new thread from a thread pool. The loader ensures thread safety for Spigot calls. The biggest advantage of this is that Haxe plugins will never lag your server. Threads are running on a lower priority than the server's main thread. So if your CPU cannot keep up the main game will have priority over plugins. Another benefit is that Haxe plugins will enable and disable in parallel, decreasing start/stop times with many plugins.
Aside from multi-threading, the loader uses lazy loading and caching for resources required by certain parts of the API.
Compatibility
The loader determines what Spigot versions your Haxe plugins are compatible with and which Haxe version is used. The advantages of this are that your plugins are not affected by game updates and server owners only have to update the loader when a compatibility issue occurs between Spigot or API versions. The disadvantages are that developers of Haxe plugins do not have control over what Spigot version they develop for and have to adapt to the Haxe version used by the loader. Since a0.2, the loader will work on nearly all Minecraft versions, but the further back you go, the less functions will work.
With that said, I will try to keep the loader up-to-date with the latest Spigot and Haxe version whenever an update comes out. Minor versions might be skipped but major versions will get a new loader release if necessary, and if I have the time to do the update.
Stability
This loader is highly experimental and at this time is likely to contain bugs. I myself have successfully developed multiple plugins using this API trying to test many different parts of the API. For whenever it may come in handy, Haxe plugins can be disabled and re-enabled individually at runtime through a command (since a0.2).
Extensibility
Haxe plugins can communicate with each other through a shared map of values and respond to value changes through callbacks. This system could be used to create custom events for other plugins. Regular server plugins can (since a0.2) also use this shared memory to communicate with Haxe plugins, or extend the capabilities of a Haxe plugin. I am not sure if it is possible to directly use existing Java libraries within Haxe plugins as I have never tried that.
Installation
- Remove your previous HaxePluginLoader (when updating).
- Drop the jar file into your server's plugins folder.
Haxe plugins in your plugins folder, or the folder named after the loader plugin, should now work on your server.
Develop
To develop Haxe plugins, watch the video below or read the instructions on the
GitHub page of the API. The setup part of the video takes about 15 minutes, the rest of the video is more about the API.
​
Known bugs & reporting
Feel free to use this Spigot thread or
discuss things here.
Discord
​