Some of the more useful features of the Bukkit API are not very well documented outside
the javadocs. I've stumbled upon quite a few:
Graphical UI using inventoriesIt's possible to create inventories of any size, type and title on the fly using the
org.bukkit.Server.createInventory() series of functions. Combined with
org.bukkit.event.inventory events and
org.bukkit.entity.HumanEntity.openInventory(), you can create creative ways for players to interact with your plugin.
Scheduled tasksYou can schedule tasks to run later or repeatedly. You can also run tasks asynchronously to avoid clogging up your main thread. There are mainly two ways to schedule tasks:
Example using method
a:
public class Broadcaster extends JavaPlugin {
private final MyRunnable runnable = new MyRunnable(this.getServer());
@Override
public void onEnable() {
// run task every minute (=1200 ticks)
this.runnable.runTaskTimer(this, 0, 1200);
}
@Override
public void onDisable() {
// cancel task
this.runnable.cancel();
}
}
class MyRunnable extends BukkitRunnable {
private final Server server;
public MyRunnable(Server server) {
this.server = server;
}
@Override
public void run() {
this.server.broadcastMessage("It works!");
}
}
Example using method
b:
public class Broadcaster extends JavaPlugin implements Runnable {
@Override
public void run() {
this.getServer().broadcastMessage("It works!");
}
@Override
public void onEnable() {
// run task every minute (=1200 ticks)
this.getServer().getScheduler().runTaskTimer(this, this, 0, 1200);
}
@Override
public void onDisable() {
// cancel all tasks scheduled by this plugin
this.getServer().getScheduler().cancelTasks(this);
}
}
Custom recipesYou can't create custom items, but you can add custom recipes.
Define the recipe by instantiating one of the classes implementing
org.bukkit.inventory.Recipe. Then add the recipe to the server using
org.bukkit.Server.addRecipe().
Some other functions for managing recipes:
Example:
// define recipe
public final Recipe myRecipe = new FurnaceRecipe(new ItemStack(Material.WATER_BUCKET), Material.ICE);
@Override
public void onEnable() {
// add recipe
this.getServer().addRecipe(myRecipe);
}
@Override
public void onDisable() {
// remove recipe
Iterator<Recipe> iterator = this.getServer().iterateRecipes();
while (iterator.hasNext()) if (iterator.next() == this.myRecipe) iterator.remove();
}
I'd also like to point out
org.bukkit.conversations, though I've never used it myself.
Feel free to post your own tips & tricks.