{"id":18660156,"url":"https://github.com/magiclu550/nkscript","last_synced_at":"2026-02-08T20:10:19.718Z","repository":{"id":102906254,"uuid":"242049429","full_name":"MagicLu550/nkscript","owner":"MagicLu550","description":"NKScript Plugin For Nukkit","archived":false,"fork":false,"pushed_at":"2024-10-17T16:21:12.000Z","size":212,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-12T17:16:44.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MagicLu550.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-21T03:55:04.000Z","updated_at":"2020-10-23T10:55:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"d415854f-64b8-4179-9b93-533cec5af985","html_url":"https://github.com/MagicLu550/nkscript","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/MagicLu550/nkscript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagicLu550%2Fnkscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagicLu550%2Fnkscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagicLu550%2Fnkscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagicLu550%2Fnkscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MagicLu550","download_url":"https://codeload.github.com/MagicLu550/nkscript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagicLu550%2Fnkscript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29241725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T19:36:48.828Z","status":"ssl_error","status_checked_at":"2026-02-08T19:27:12.336Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T07:42:29.889Z","updated_at":"2026-02-08T20:10:19.702Z","avatar_url":"https://github.com/MagicLu550.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NKscript\n\n- [中文](README_ZH.md)\n- English\n\n![logo](images/logo.png)\n\nSimplify the development mode of the Nk plugin, use scripted programming, and run directly without compilation\n\nNKScript scripted programming solution\n\nThe purpose of NKScript is to simplify development and debug plugins better.\n\n### For project structure and call files\n\nNKScript is mainly divided into 5 modules\n\n-info.ns\n-main.ns\n-listener\n-command\n-other\n\ninfo.ns is similar to nukkit's plugin.yml, and its content is basically similar to plugin.yml.\nThe special element is the `id` element, which is designed to prevent conflicts between multiple plugins, and it will be used as the class root directory of the registration file.\nWhen calling a script, the format is id. The name of the script file\nFor example id is `net.noyark`, then the script hello.ns is written\n```groovy\n\nclass hello {\n    /// ...\n}\n\n```\nWhen called\n```groovy\nimport net.noyark.hello\n```\nOf course, when writing the main class and listener, `package` and` class` can be omitted\nLike main.ns\n```groovy\n@Override\nvoid onLoad () {\n    // ...\n}\n```\nlistener.ns\n```groovy\n@EventHandler\nvoid onJoin (PlayerJoinEvent e) {\n\n}\n\n```\nThe main file of the script must be main.ns, when calling the main file, it is `import your id. Plugin name`\nIf the plugin name is `Hello` and the id is` net.noyark`\n```groovy\n// Import the main class\nimport net.noyark.Hello\n```\n\nIn short, for file import, except the main class is id.pluginName, the others are id. Script file names,\nOnly listener and command, the main class can omit packageName and class, others must be\nClass name\nPackage names can be omitted when writing other classes\n\nFor each class (except the main class), the default package name is id. Its folder\n\nIn the root directory, the script file must not have the same name as the plugin name\n\nIn addition, override the onCommand method with the parameter onCommand (CommandInfo info)\ninfo.getCommand () Get command object\ninfo.getLabel () Get instruction label\ninfo.getArgs () Get command parameters\ninfo.getSender () Get command sender\n\n### info.nsWriting\n```groovy\ninfo{\n      name \"Hello\" //插件名称,必须有\n      version \"1.0.0\" //版本，可不写，不写默认为1.0.0\n      author \"MagicLu\" //作者名 可不写\n      listeners [\"listener.ns\"] //注册的监听器 如果没有可不写\n      commandsMap [\"command.ns\"] //注册的指令 如果没有可不写\n      id \"net.noyark.www\" //id号，意义如同前面所讲 \n      description \"\" //介绍，可不写\n      permissions ([\n           \"FirstPlugin.fp\" : [\n                  description : \"\",\n                  default : \"op\"\n           ]\n      ]) //和nk插件的plugin.yml结构相同\n      commands ([\n          fp : [\n              \"usage\" : \"/fp help\",\n              \"description\" : \"指令介绍\",\n              \"permission\" : \"FirstPlugin.fp\"\n          ]\n      ]) //和nk插件的plugin.yml结构相同\n}\ndepends{ //依赖，如果没有可以忽略\n    softDepend ([])\n    depend ([])\n    loadBefore([])\n    scriptDepend([]) //前置脚本\n}\n\n```\n\nOthers are basically the same as NK. It uses groovy syntax and supports java writing. Registering listeners and instructions is also possible.\nUse the original method.\nThe default command is to use SimpleCommand, see the example file for use.\n\n### Native getInstance and injection assignment\nThe main file comes with a static getInstance method by default, which can directly get the current object\nLike listener.ns, if my plugin name is HelloWorld and id is net.noyark.www\n```groovy\nimport net.noyark.www.HelloWorld\n\nimport cn.nukkit.event.EventHandler\nimport cn.nukkit.event.player.PlayerJoinEvent\n\n@EventHandler\nvoid onPlayerJoin (PlayerJoinEvent e) {\n    // getInstance () is the built-in method of HelloWorld\n    PluginBase base = HelloWorld.getInstance ()\n\n}\n\n```\nAutomatic assignment\nYou can directly get the main class object through @MainPlugin. Of course, it can only be used in the main class, listener class, and command class.\nE.g. listener.ns\n```groovy\nimport net.noyark.www.HelloWorld\n\nimport cn.nukkit.event.EventHandler\nimport cn.nukkit.event.player.PlayerJoinEvent\n\n@MainPlugin\nPluginBase base\n\n@EventHandler\nvoid onPlayerJoin (PlayerJoinEvent e) {\n    base.logger.info (\"hello, world\") // Can be called directly here\n}\n```\n\n### Third-party library import\nJust add the jar package in the root directory of your script folder / libs, and it will be read and loaded.\n![libs](images/libs.png)\n\n### What to do if Groovy script is inefficient?\nYou can discard dynamic typing because Groovy is still strongly typed. It can use @CompileStatic annotation to make your code compile statically, but you need to discard dynamic typing, similar to this\n```groovy\n@Command (name = \"hello\", description = \"233\", usageMessage = \"/ hello\")\n@Arguments (max = 10, min = 0)\n@CompileStatic\nboolean onHelloCommand (CommandSender sender, String label, String [] args) {\n    // Write instruction processing code here\n    base.logger.info (\"hello, world\")\n    return true\n}\n```\n\n### info.retain property\nInfo.retain is set to true, you can compile the main class without shell.\n\ninfo.ns\n```groovy\ninfo{\n      name \"Game\"\n      version \"1.0.0\"\n      author \"MagicLu\"\n      listeners ([\"PlayerListener.ns\"])\n      retain true\n      id \"net.noyark.www\"\n      description \"\"\n      permissions ([\n           \"FirstPlugin.fp\" : [\n                  description : \"\",\n                  default : \"op\"\n           ]\n      ])\n      commands ([\n          fp : [\n              \"usage\" : \"/fp help\",\n              \"description\" : \"指令介绍\",\n              \"permission\" : \"FirstPlugin.fp\"\n          ]\n      ])\n}\n```\n\nmain.ns can only be written as\n```groovy\n\nclass Game extends PluginBase{\n    void onLoad(){\n        this.logger.info(\"MagicLu's script example02,the simple pvp game\")\n    }\n\n    void onEnable(){\n        this.logger.info(\"插件已经加载\")\n    }\n\n    void onDisable(){\n\n    }\n}\n```\n\nSignificance of designing this: Some people may turn on ide's completion feature in order to use it\n### Use a well-written script\nJust put the folder under`plugins/NKScript`\n![use](images/use.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclu550%2Fnkscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclu550%2Fnkscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclu550%2Fnkscript/lists"}