Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jwulf/camunda-minecraft-plugin

The Camunda Engine embedded in a Minecraft plugin
https://github.com/jwulf/camunda-minecraft-plugin

camunda minecraft scriptcraft

Last synced: about 1 month ago
JSON representation

The Camunda Engine embedded in a Minecraft plugin

Awesome Lists containing this project

README

        

# CamundaCraft - The Minecraft BPMN Plugin

![](img/CamundaCraft.jpg)

_Orchestrate Minecraft with BPMN and JavaScript!_

The Camunda Engine embedded in a Minecraft plugin for Bukkit-compatible Minecraft servers.

The plugin has a single delegate method for task execution. The executor uses a field injection named `delegate` from a service task.

It uses the value of this field to look up a JavaScript handler in a map.

Any .bpmn and .js files in `plugins/CamundaPlugin` will be loaded. Take a look at the files in [test-data](test-data) for the format of the .js file.

Register the handlers using the `registerHandler(name, code)` method. See the example below.

## Try it out!

If you have docker and npm installed, it is easy to test using the [Scriptcraft Modular Architecture](https://github.com/Magikcraft/scriptcraft-modular-arch) image.

Run:

```
npm i -g smac
mvn package
smac
```

This will start a Minecraft server in Docker and mount the plugin into it.

It will pipe the server log to your terminal, and - _bonus!_ - give you an interactive session.

When the server finishes booting, type: `ts on`. This turns the terminal into a TypeScript REPL on the server. _Magic_.

Now paste these commands in:

```typescript
const xml = `SequenceFlow_0krhw54SequenceFlow_0tmt5j8someFunctionSequenceFlow_0tmt5j8SequenceFlow_0krhw54`

const c = server.getPluginManager().getPlugin("CamundaPlugin")

c.registerHandler("someFunction", "function(execution) { var process = execution.getProcessInstanceId(); __plugin.logger.info('Yay!!! The job handler was called from process instance ' + process )}")

c.deployBpmn("model.bpmn", xml);

c.runtimeService.createProcessInstanceByKey("my-project-process").execute()
```

You will see the handler execute:

```
[02:14:06 INFO]: [CamundaPlugin] Yay!!! The job handler was called from process instance 24
```

_Epico!_

To shut down the server, type: `smac stop`.