Extensions - OfficialDonut/VisualBukkit GitHub Wiki

Installation

  1. Download extension jar
  2. Launch Visual Bukkit
  3. Click Extensions > Manage
  4. Place the extension jar in the opened folder
  5. Restart Visual Bukkit
  6. Enable the extension for a project in the plugin settings tab

Developing Extensions

Extensions you might find useful to reference.

Add Visual Bukkit as a dependency

Maven
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.OfficialDonut</groupId>
    <artifactId>VisualBukkit</artifactId>
    <version>[version]</version>
</dependency>
Gradle
repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.OfficialDonut:VisualBukkit:[version]'
}

Create a class extending VisualBukkitExtension

import com.gmail.visualbukkit.extensions.VisualBukkitExtension;

public class ExampleExtension extends VisualBukkitExtension {

    public ExampleExtension() {
        // register blocks
        // do anything else that needs to be done when the extension is first loaded
    }

    @Override
    public void activate(Project project) {
        // this runs when a project that has this extension enabled loads
        // you probably do not need to use this
    }

    @Override
    public void save(Project project, JSONObject data) {
        // save any data that needs to be persistent in the JSONObject
        // you probably do not need to use this
    }

    @Override
    public void deactivate(Project project) {
        // this runs when a project that does not have this extension enabled loads (if this extension is activated)
        // you probably do not need to use this
    }

    @Override
    public String getName() {
        return "Example";
    }

    @Override
    public String getVersion() {
        return "1.0";
    }

    @Override
    public String getAuthor() {
        return "Donut";
    }

    @Override
    public String getDescription() {
        return "This is an example";
    }
}
  • The methods getName(), getVersion(), getAuthor(), and getDescription() must be implemented in this class.
  • You may optionally override the methods activate(), save(), and deactivate().
  • In the constructor of this class you should call BlockRegistry method(s) to register blocks for your extension.

Manually Define Blocks

There are several block classes that you can extend:

  • PluginComponent
  • Statement
    • Container
  • Expression
    • SimpleExpression
    • VarArgsExpression

Examples of blocks manually defined in Visual Bukkit.

Call BlockRegistry#register(VisualBukkitExtension extension, String packageName) to register all block classes within the specified package.

Generate Blocks

Download the block generator jar.

The generator is a doclet so run the Javadoc Tool to use it.

Example Invocation:

javadoc @options.txt

Options.txt
-docletpath BlockGenerator.jar
-doclet com.gmail.visualbukkit.generator.GeneratorDoclet
-sourcepath ../src/main/java
-d GeneratorOutput
-deprecated
--ignore-source-errors

org.bukkit
org.bukkit.advancement
org.bukkit.attribute
org.bukkit.block
org.bukkit.block.banner
org.bukkit.block.data
org.bukkit.block.data.type
org.bukkit.block.structure
org.bukkit.boss
org.bukkit.enchantments
org.bukkit.entity
org.bukkit.entity.memory
org.bukkit.entity.minecart
org.bukkit.event.block
org.bukkit.event.enchantment
org.bukkit.event.entity
org.bukkit.event.hanging
org.bukkit.event.inventory
org.bukkit.event.player
org.bukkit.event.raid
org.bukkit.event.server
org.bukkit.event.vehicle
org.bukkit.event.weather
org.bukkit.event.world
org.bukkit.inventory
org.bukkit.inventory.meta
org.bukkit.loot
org.bukkit.map
org.bukkit.potion
org.bukkit.projectiles
org.bukkit.scoreboard

../src/main/java/org/bukkit/command/CommandSender.java
../src/main/java/org/bukkit/command/BlockCommandSender.java
../src/main/java/org/bukkit/command/ConsoleCommandSender.java
../src/main/java/org/bukkit/permissions/Permissible.java
../src/main/java/org/bukkit/permissions/ServerOperator.java
../src/main/java/org/bukkit/util/BoundingBox.java
../src/main/java/org/bukkit/util/EulerAngle.java
../src/main/java/org/bukkit/util/RayTraceResult.java
../src/main/java/org/bukkit/util/Vector.java

The generator will output Blocks.json which contains the JSON representation of the blocks.

In your extension class, call BlockRegistry#register(VisualBukkitExtension extension, JSONArray blockArray) to register the generated blocks where the JSONArray argument is created from the contents of the output file.

Deploy Extension

The last step is to compile the extension into a jar. The jar must have a manifest file with the main-class attribute set to the class extending VisualBukkitExtension.

⚠️ **GitHub.com Fallback** ⚠️