Minesite Plugin API

(This wiki page is still in progress, and we'll be updating it soon! If you have questions or feedback for now, please feel free to join the Discord server)

Download the Minesite plugin here to get started developing with the Minesite API!

The Minesite plugin supports both Kotlin and Java.

Getting an instance of the API for variables

Java

JavaPlugin plugin; // An instance of your plugin's Main class
MinesiteV1 minesite = Minesite.v1(plugin);
MinesiteVariableHandler variables = minesite.variables;

Kotlin

Much of Minesite's Kotlin API is built on suspend functions. If you'd prefer to not use suspend functions, you should use the Java API instead (you can still use the Java API if the rest of your plugin is in Kotlin!)
val plugin: JavaPlugin; // An instance of your plugin's Main class
val minesite: MinesiteV1Kotlin = Minesite.v1(plugin).kotlin;
val variables: MinesiteVariableHandlerKotlin = minesite.variables;

Getting and Setting variables

Java

String namespace = "my_plugin";
String key = "variable_name";

MinesiteFuture<Void> future = variables.setSiteVariableFuture(namespace, key, "Hello, World!");
future.get(result -> {
    // This runs asynchronously

    if(result.isSuccess()){
        // Success! The variable will be set
    }
    else{
        // Something went wrong!
        result.exceptionOrNull().printStackTrace();
    }
});

MinesiteFuture<String> future = variables.getSiteVariableFuture(namespace, key);
future.get(stringResult -> {
    // This runs asynchronously

    if(stringResult.isSuccess()){
        String value = stringResult.getOrThrow();
        System.out.println(namespace + ":" + key + " is set to " + value);
    }
    else{
        // Something went wrong!
        stringResult.exceptionOrNull().printStackTrace();
    }
});

Kotlin

val namespace = "my_plugin";
val key = "variable_name";

// Suspend function
val result: Result<Unit> = variables.setSiteVariable(namespace, key, "Hello, World!");
if(result.isSuccess){
    // Success! The variable will be set
}
else{
    // Something went wrong!
    result.exceptionOrNull()?.printStackTrace()
}

// Suspend function
val result: Result<String?> = variables.getSiteVariable(namespace, key);
if(result.isSuccess){
    val value = result.getOrThrow()
    println("$namcespace:$key is set to $value")
}
else{
    // Something went wrong!
    result.exceptionOrNull()?.printStackTrace()
}