差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
modding:pluginandjvm [2022/10/04 01:06] – old revision restored (2022/03/14 13:37) 111.225.149.108 | modding:pluginandjvm [2022/10/04 03:58] (当前版本) – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== Plugins & JVM Mods ====== | ||
+ | |||
+ | Mindustry supports loading '' | ||
+ | |||
+ | Theoretically, | ||
+ | |||
+ | Jar/JVM mods use the same '' | ||
+ | |||
+ | If a main class is not specified, it defaults to '' | ||
+ | |||
+ | A simple '' | ||
+ | |||
+ | <code hjson> | ||
+ | name: " | ||
+ | author: " | ||
+ | main: " | ||
+ | description: | ||
+ | version: " | ||
+ | </ | ||
+ | |||
+ | See the [[https:// | ||
+ | |||
+ | ===== Plugins ===== | ||
+ | |||
+ | Plugins are Java mods that are intended to be run on servers only. Usually, these add //new commands// or //new gamemodes// | ||
+ | |||
+ | Plugins name their meta file '' | ||
+ | |||
+ | You can see an example plugin [[https:// | ||
+ | ===== Importing ===== | ||
+ | |||
+ | Unlike JS or JSON mods, JAR mods need to be compiled. This means that they cannot be imported directly from Github - instead, //Github Releases// are used. | ||
+ | |||
+ | When a user tries to install a JAR mod, Mindustry will check the latest (and //only// the latest) Github release for '' | ||
+ | |||
+ | I recommend using Github Actions (or any other CI) to automatically build and upload jar artifacts to new releases. | ||
+ | |||
+ | ===== Multithreading ===== | ||
+ | |||
+ | Unless otherwise noted, **no Mindustry code is thread-safe**. Performing any actions (e.g. sending packets, changing tiles) from a thread other than the main one will result in random crashes or network errors. To run something on the main thread, use '' | ||
+ | |||
+ | ===== Capabilities & Security ===== | ||
+ | |||
+ | As jar mods are loaded directly through a '' | ||
+ | |||
+ | * All Java APIs can be accessed. | ||
+ | * Reflection can be used to access private/ | ||
+ | * Mods have full access to the client’s computer, opening the door to potentially malicious actions. | ||
+ | * Mods can change game files or rewrite core bytecode. | ||
+ | |||
+ | Thus, you should //never import jar mods from untrusted sources.// Now, you may be wondering: Why aren’t jar mods sandboxed? Isn’t that a massive security risk? | ||
+ | |||
+ | The answer is: //Yes//, it is. However, there are no good alternatives. Even if I implemented a '' | ||
+ | |||
+ | As a point of comparison, Forge (//a popular Java mod loader for Minecraft// | ||
+ | |||
+ | |||
+ | |||