Code (Text):
package com.aim.coltonjgriswold.egp;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.aim.coltonjgriswold.sga.api.SimpleGui;
import com.aim.coltonjgriswold.sga.api.gui.ISimpleAction;
import com.aim.coltonjgriswold.sga.api.gui.ISimpleGuiPage;
public class ExampleGuiPlugin extends JavaPlugin implements Listener {
private static ExampleGuiPlugin plugin;
private SimpleGui gui;
public void onEnable() {
plugin = this;
gui = new SimpleGui();
ISimpleGuiPage page = gui.createPage("Test 0", 9);
page.addSimpleButton(Material.RED_CONCRETE, "&6Secret Message", new ISimpleAction() {
@Override
public void run(Player player, ClickType click) {
player.sendMessage("STOP THAT!");
}
});
page.addSimpleButton(Material.GREEN_CONCRETE, "Say hi.", new ExampleAction());
gui.addPages(page);
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void OnClickAir(PlayerInteractEvent event) {
if (event.getAction().equals(Action.LEFT_CLICK_AIR)) {
Player player = event.getPlayer();
gui.open(player, 0);
}
}
public static ExampleGuiPlugin instance() {
return plugin;
}
}