Repository navigation
Expand file tree
/
Copy pathplugins.html
More file actions
285 lines (269 loc) · 14.4 KB
/
Copy pathplugins.html
File metadata and controls
285 lines (269 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<!DOCTYPE html>
<html lang="en">
<head>
<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="author" content="Falcon-MC">
<meta name="robots" content="index, follow">
<meta name="theme-color" content="#0d1117">
<meta name="color-scheme" content="dark">
<link rel="canonical" href="https://falcon-mc.github.io/plugins.html">
<meta property="og:type" content="website">
<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: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:image" content="https://falcon-mc.github.io/assets/social.png">
<link rel="icon" type="image/png" href="assets/favicon.png">
<link rel="apple-touch-icon" href="assets/apple-touch-icon.png">
<script>document.documentElement.classList.add("js");</script>
<link rel="stylesheet" href="style.css?v=10">
</head>
<body>
<header class="nav">
<a class="brand" href="index.html">
<img src="assets/icon-white.png" alt="" width="32" height="32">
<span>Falcon</span>
</a>
<button class="menu-toggle" id="menu-toggle" aria-label="Open menu" aria-expanded="false" aria-controls="site-menu">
<span></span><span></span><span></span>
</button>
<nav id="site-menu">
<a href="index.html">Home</a>
<a href="https://discord.gg/KZb6YxSHkb">Discord</a>
<a href="https://github.com/Falcon-MC/PluginAPI" class="button small">SDK</a>
</nav>
</header>
<main id="top">
<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
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>Windows, Linux & macOS</span>
</div>
<div class="actions">
<a class="button" href="https://github.com/Falcon-MC/PluginAPI">Plugin SDK</a>
<a class="button ghost" href="https://github.com/Falcon-MC/PluginAPI/tree/main/examples">Example plugins</a>
<a class="button ghost" href="https://discord.gg/KZb6YxSHkb">Ask on Discord</a>
</div>
</section>
<section id="runtimes" class="section alt">
<div class="container">
<h2 class="reveal">Pick a runtime</h2>
<div class="runtime-grid">
<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
server with the same API major version.</p>
<ul>
<li>One <code>.dll</code>, <code>.so</code> or <code>.dylib</code> per plugin</li>
<li>Survives server updates without a rebuild</li>
<li><code>"runtime": "native"</code></li>
</ul>
</article>
<article class="feature reveal">
<h3>Internal C++ <span class="tag ready">Available</span></h3>
<p>Full access to the server's own classes: subclass blocks, items, mobs, AI goals and commands, and
override vanilla ones.</p>
<ul>
<li>Built against one release with its SDK archive</li>
<li>Rebuilt for every server update</li>
<li><code>"runtime": "internal"</code></li>
</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>
<ul>
<li>Needs the .NET runtime</li>
<li><code>"runtime": "dotnet"</code></li>
</ul>
</article>
<article class="feature reveal">
<h3>Java <span class="tag ready">Available</span></h3>
<p>Jar files running in one embedded JVM, calling the server through the foreign function API.</p>
<ul>
<li>Needs Java 22 or newer</li>
<li><code>"runtime": "java"</code></li>
</ul>
</article>
</div>
</div>
</section>
<section id="api" class="section">
<div class="container">
<h2 class="reveal">What a plugin can do</h2>
<div class="grid">
<article class="feature featured reveal">
<h3>Events</h3>
<p>Listen with priorities from lowest to monitor, cancel, and change what happens next.</p>
<ul>
<li>Players: join, quit, chat, move, death, respawn, commands, game mode, dimension, drop and pickup</li>
<li>Blocks: break, place, interact, fire spread, burn</li>
<li>Entities: damage, death, interact, projectile hit, explosion with editable blocks</li>
<li>Inventories: open, close, every click, crafting</li>
<li>Server: tick, console commands, raw packets in and out</li>
</ul>
</article>
<article class="feature reveal">
<h3>Commands</h3>
<p>Register commands with a description, usage and permission. They show up in the player's command
list.</p>
</article>
<article class="feature reveal">
<h3>Custom content</h3>
<p>New items, blocks and entities with their own behaviour, sent to players automatically.</p>
</article>
<article class="feature reveal">
<h3>World</h3>
<p>Read and set blocks, spawn entities, drop items, change time and weather, strike lightning and
create explosions.</p>
</article>
<article class="feature reveal">
<h3>Players and items</h3>
<p>Inventories, armor, offhand, health, food, experience, titles, game modes, lore and enchantments.</p>
</article>
<article class="feature reveal">
<h3>Scheduler</h3>
<p>Delayed and repeating tasks on the main thread, and async work that reports back safely.</p>
</article>
<article class="feature reveal">
<h3>Permissions and config</h3>
<p>Permission nodes with defaults, per-player grants, and a <code>config.yml</code> per plugin.</p>
</article>
<article class="feature reveal">
<h3>Raw packets</h3>
<p>Send any packet to a player, and read, rewrite or drop every packet going in and out.</p>
</article>
</div>
</div>
</section>
<section id="first-plugin" class="section alt">
<div class="container">
<h2 class="reveal">Your first plugin</h2>
<p class="section-lead reveal">Pick a language and follow the three steps.</p>
<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="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
<a href="https://discord.gg/KZb6YxSHkb">Discord</a> if something does not work.</p>
<div class="tutorial" id="tutorial">
<div class="split reveal">
<div>
<h3>1. Add the SDK</h3>
<p>The SDK is a CMake project. <code>falcon_add_plugin</code> builds the shared library with the right
settings for your platform.</p>
</div>
<pre class="code"><span class="keyword">include</span>(FetchContent)
<span class="keyword">FetchContent_Declare</span>(
falcon_plugin_api
GIT_REPOSITORY https://github.com/Falcon-MC/PluginAPI.git
GIT_TAG main
)
<span class="keyword">FetchContent_MakeAvailable</span>(falcon_plugin_api)
<span class="keyword">falcon_add_plugin</span>(MyPlugin MyPlugin.cpp)</pre>
</div>
<div class="split reveal">
<div>
<h3>2. Write the plugin</h3>
<p>Subclass <code>falcon::Plugin</code>, subscribe to events and register commands in
<code>onEnable</code>. A plugin can be split into as many classes and folders as you like.</p>
</div>
<pre class="code"><span class="keyword">#include</span> <span class="string"><falcon/Falcon.hpp></span>
<span class="keyword">class</span> MyPlugin : <span class="keyword">public</span> falcon::Plugin {
<span class="keyword">public</span>:
<span class="keyword">bool</span> onEnable() <span class="keyword">override</span> {
events().on<falcon::PlayerJoinEvent>(
[](falcon::PlayerJoinEvent &event) {
event.player().sendMessage(<span class="string">"Welcome!"</span>);
});
<span class="keyword">return true</span>;
}
};
FALCON_PLUGIN(MyPlugin)</pre>
</div>
<div class="split reveal">
<div>
<h3>3. Install it</h3>
<p>Put the library next to a <code>plugin.json</code> in <code>plugins/MyPlugin/</code> and start the
server. Dependencies between plugins are declared here and load in the right order.</p>
</div>
<pre class="code">{
<span class="string">"name"</span>: <span class="string">"MyPlugin"</span>,
<span class="string">"version"</span>: <span class="string">"1.0.0"</span>,
<span class="string">"api-version"</span>: <span class="string">"1.2"</span>,
<span class="string">"main"</span>: <span class="string">"MyPlugin"</span>,
<span class="string">"depend"</span>: [],
<span class="string">"softdepend"</span>: []
}</pre>
</div>
</div>
</div>
</section>
<section id="services" class="section">
<div class="container">
<h2 class="reveal">Talk to other plugins</h2>
<div class="split reveal">
<div>
<h3>Services</h3>
<p>A plugin provides a named service and any other plugin calls it, whatever language either of them
is written in. Requests and responses are text, usually JSON.</p>
<h3>Custom events</h3>
<p>Fire your own events and let other plugins listen, cancel them or change their data, with the same
priorities as the server's events.</p>
</div>
<pre class="code">services().provide(<span class="string">"economy:balance"</span>, [](<span class="keyword">const</span> std::string &request) {
<span class="keyword">return</span> std::string(<span class="string">"{\"balance\":250}"</span>);
});
<span class="keyword">auto</span> balance = services().call(<span class="string">"economy:balance"</span>, <span class="string">"{\"player\":\"Steve\"}"</span>);
services().on(<span class="string">"quests:completed"</span>, [](falcon::CustomEvent &event) {
event.setData(event.data() + <span class="string">" rewarded"</span>);
});
services().fire(<span class="string">"quests:completed"</span>, <span class="string">"{\"quest\":\"miner\"}"</span>, <span class="keyword">true</span>);</pre>
</div>
<div class="split reveal">
<div>
<h3>Internal plugins</h3>
<p>Every release ships a <code>FalconSDK-<platform>.tar.gz</code> with the server's headers.
Extract it next to your project and build against it with the compiler named in its
<code>README.txt</code>.</p>
</div>
<pre class="code">cmake -B build -DFALCON_SDK_DIR=/path/to/FalconSDK-linux
cmake --build build</pre>
</div>
</div>
</section>
</main>
<footer class="footer">
<p>Falcon is not affiliated with Mojang. All brands and trademarks belong to their respective owners.</p>
<p>
<a href="index.html">Home</a> ·
<a href="https://discord.gg/KZb6YxSHkb">Discord</a> ·
<a href="https://github.com/Falcon-MC/PluginAPI">Plugin SDK</a> ·
<a href="https://github.com/Falcon-MC/falcon-mc.github.io">Website source</a>
</p>
</footer>
<script src="site.js?v=1"></script>
<script src="plugins.js?v=1"></script>
</body>
</html>