Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h3>Behavior packs</h3>
<path class="pixel-light" d="M3 5h2v1H3zM3.5 6h1v2h-1z"/>
</svg>
<h3>Plugins</h3>
<p>Events, commands, custom content and services, in C++, C# or Java. <span class="more">Plugin API &rarr;</span></p>
<p>Events, commands, custom content and services, in C++, Java or WebAssembly. <span class="more">Plugin API &rarr;</span></p>
</a>
</div>
</div>
Expand Down
32 changes: 23 additions & 9 deletions plugins.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Plugins - Falcon</title>
<meta name="description" content="Extend Falcon with plugins in C++, C# or Java. Events, commands, custom items, blocks and entities, services between plugins, all on one stable API.">
<meta name="keywords" content="Minecraft, Bedrock, server, plugins, plugin API, C++, C#, Java, Falcon">
<meta name="description" content="Extend Falcon with plugins in C++, Java or sandboxed WebAssembly. Events, commands, custom items, blocks and entities, services between plugins, all on one stable API.">
<meta name="keywords" content="Minecraft, Bedrock, server, plugins, plugin API, C++, Java, WebAssembly, Wasm, Falcon">
<meta name="author" content="Falcon-MC">
<meta name="robots" content="index, follow">
<meta name="theme-color" content="#0d1117">
Expand All @@ -16,15 +16,15 @@
<meta property="og:site_name" content="Falcon">
<meta property="og:url" content="https://falcon-mc.github.io/plugins.html">
<meta property="og:title" content="Falcon plugins">
<meta property="og:description" content="Extend Falcon with plugins in C++, C# or Java, all on one stable API.">
<meta property="og:description" content="Extend Falcon with plugins in C++, Java or sandboxed WebAssembly, all on one stable API.">
<meta property="og:image" content="https://falcon-mc.github.io/assets/social.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:locale" content="en_US">

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Falcon plugins">
<meta name="twitter:description" content="Extend Falcon with plugins in C++, C# or Java, all on one stable API.">
<meta name="twitter:description" content="Extend Falcon with plugins in C++, Java or sandboxed WebAssembly, all on one stable API.">
<meta name="twitter:image" content="https://falcon-mc.github.io/assets/social.png">

<link rel="icon" type="image/png" href="assets/favicon.png">
Expand Down Expand Up @@ -52,14 +52,14 @@
<section class="page-hero">
<h1>Plugins for Falcon</h1>
<p class="lead">
Extend the server with plugins written in C++, C# or Java. Every language sits on the same stable API, so a
Extend the server with plugins written in C++, Java or WebAssembly. Every language sits on the same stable API, so a
plugin keeps working when the server updates.
</p>
<div class="badges">
<span>API 1.2</span>
<span>C++17</span>
<span>C#</span>
<span>Java</span>
<span>WebAssembly</span>
<span>Windows, Linux &amp; macOS</span>
</div>
<div class="actions">
Expand All @@ -73,6 +73,17 @@ <h1>Plugins for Falcon</h1>
<div class="container">
<h2 class="reveal">Pick a runtime</h2>
<div class="runtime-grid">
<article class="feature reveal">
<h3>WebAssembly <span class="tag ready">New</span></h3>
<p>Sandboxed plugins in any language with WIT bindings for core modules. The recommended choice for
new plugins: a broken or hostile plugin is stopped without taking the server down.</p>
<ul>
<li>No file system or network access</li>
<li>Memory capped by <code>wasm-plugin-memory-mb</code>, work per server call by
<code>wasm-plugin-fuel</code></li>
<li><code>"runtime": "wasm"</code></li>
</ul>
</article>
<article class="feature reveal">
<h3>Native C++ <span class="tag ready">Available</span></h3>
<p>Header-only C++ classes over a stable C ABI. Build with any compiler and the plugin loads on every
Expand All @@ -94,8 +105,9 @@ <h3>Internal C++ <span class="tag ready">Available</span></h3>
</ul>
</article>
<article class="feature reveal">
<h3>C# <span class="tag ready">Available</span></h3>
<p>.NET class libraries loaded in-process, with the same events, commands and content as C++.</p>
<h3>C# <span class="tag">Deprecated</span></h3>
<p>.NET class libraries loaded in-process. Deprecated and removed in a future release: move to
WebAssembly, native C++ or Java.</p>
<ul>
<li>Needs the .NET runtime</li>
<li><code>"runtime": "dotnet"</code></li>
Expand Down Expand Up @@ -169,10 +181,12 @@ <h2 class="reveal">Your first plugin</h2>
<div class="language-tabs reveal" id="language-tabs" role="tablist" aria-label="Plugin language" hidden>
<span class="language-indicator" id="language-indicator" aria-hidden="true"></span>
<button type="button" role="tab" data-language="cpp" aria-selected="true">C++</button>
<button type="button" role="tab" data-language="wasm" aria-selected="false">WebAssembly</button>
<button type="button" role="tab" data-language="csharp" aria-selected="false">C#</button>
<button type="button" role="tab" data-language="java" aria-selected="false">Java</button>
</div>
<p class="language-note" id="language-note" hidden>C# and Java support is brand new: tell us on
<p class="language-note" id="language-note" hidden>Java and WebAssembly support is brand new, and C# is
deprecated: tell us on
<a href="https://discord.gg/KZb6YxSHkb">Discord</a> if something does not work.</p>
<div class="tutorial" id="tutorial">
<div class="split reveal">
Expand Down
49 changes: 48 additions & 1 deletion plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,52 @@ FALCON_PLUGIN(MyPlugin)`
"main": "MyPlugin",
"depend": [],
"softdepend": []
}`
}
],
wasm: [
{
title: "Build the module",
text: "Generate the C bindings from <code>wasm/falcon.wit</code> in the plugin SDK with " +
"<code>wit-bindgen</code> and build a core module with clang and a WASI sysroot. The server loads " +
"the core module, not a component.",
file: "build.sh",
syntax: "cmake",
code: `wit-bindgen c PluginAPI/wasm --out-dir build
clang --target=wasm32-wasip1 --sysroot="$WASI_SYSROOT" -mexec-model=reactor -O2 \\
-Ibuild -IPluginAPI/wasm/c -o build/MyPlugin.wasm \\
MyPlugin.c PluginAPI/wasm/c/falcon_wasm.c build/falcon_plugin.c build/falcon_plugin_component_type.o`
},
{
title: "Write the plugin",
text: "Implement <code>falcon_enable</code>, subscribe to events and register commands. The " +
"<code>falcon_wasm.h</code> helper hides the bindings; everything else stays reachable through them.",
file: "MyPlugin.c",
syntax: "cpp",
code: `#include "falcon_wasm.h"

static void welcome(void) {
falcon_player player;
if (falcon_event_player(&player))
falcon_send(player, "Welcome!");
}

bool falcon_enable(void) {
falcon_on(FALCON_EVENT_PLAYER_JOIN, welcome);
return true;
}`
},
{
title: "Install it",
text: "Put the module next to a <code>plugin.json</code> in <code>plugins/MyPlugin/</code>. It runs " +
"with no file system or network access.",
file: "plugin.json",
syntax: "json",
code: `{
"name": "MyPlugin",
"version": "1.0.0",
"runtime": "wasm",
"main": "MyPlugin.wasm"
}`
}
],
Expand Down Expand Up @@ -158,7 +204,8 @@ public class MyPlugin extends Plugin {

const KEYWORDS = {
cmake: ["include", "FetchContent_Declare", "FetchContent_MakeAvailable", "falcon_add_plugin"],
cpp: ["#include", "class", "public", "bool", "override", "return", "true", "false", "const", "auto"],
cpp: ["#include", "class", "public", "bool", "override", "return", "true", "false", "const", "auto", "static",
"void", "if"],
csharp: ["using", "namespace", "public", "class", "override", "bool", "return", "true", "false"],
java: ["package", "import", "public", "class", "extends", "boolean", "return", "true", "false", "@Override"],
json: ["true", "false", "null"],
Expand Down