A Minecraft library which has advanced features for developers.
- Listen to global events.
- Listen to entity specific events.
- Listen to commands.
- Save data and load data.
- Create and modify inventories.
- Execute code stored as json.
Setting up the PluginLibrary.
class Main extends JavaPlugin {
public static final PluginLibrary library = new PluginLibrary(this);
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
}
Global event listener.
library.on(PlayerMoveEvent.class, e -> {
e.getPlayer().sendMessage("You moved!");
});
Global command listener. (Note: This does NOT require you to specify the command in the plugin.yml).
library.onCommand("hello", "Sends you a nice hello.", "/hello", e -> {
if (e.getSender() instanceof Player) {
Player player = (Player) e.getSender();
player.sendMessage("Hello Player!");
}
});
Entity specific event listener, only events specific to this inventory will be triggered. This can be done to a class that implements IEventListener
.
AInventory inventory = new AInventoryBuilder().json(jsonData).build();
inventory.on(AInventoryClickEvent.class, e -> {
e.setCancelled(true);
});
The data classes. (Note: The attributes must be public.)
public class DatabaseContext extends Context {
public ArrayList<Arena> arenas = new ArrayList<>();
}
public class Arena extends Data {
public int id;
public String name;
public ArrayList<String> players = new ArrayList<>();
}
Register the context at startup and save it when the server closes.
@Override
public void onEnable() {
// This must only be done once.
library.registerContext(DatabaseContext.class);
}
@Override
public void onDisable() {
library.getContext(DatabaseContext.class).save(this);
}
Basic usage.
DatabaseContext database = library.getContext(DatabaseContext.class);
database.arenas.add(new Arena() {{
id = 1;
name = "Arena name";
}});