A slot Response consists of two fields: a slot number and a "responder" class triggered by clicking said slot's Item. Without a Response, your Item is purely cosmetic and will do nothing once clicked.
You may attach a Response to your Item like this:
// Show a cute fruit in the first slotsetItem(0,new Item(Material.APPLE));// Add a command which admins can change latergetGui().addTask(0,"say Fruit for life!");// Set the responder class for executing a commandaddResponse(0,new CommandResponder(commandSender,"say Fruit for life!",true));
Alternatively, you can set everything at once through an ItemSection at instantiation:
setItem(new ItemSection(0,new Item(Material.ITEM),"say Fruit for life!",// Tasknew CommandResponder(commandSender,"say Fruit for life!",true)); // Response
Note how we set the String of "say Fruit for life!" twice. This because the Task will be saved to file, while the Response will not. If you should wish to load your GUI from file, where the command has potentially been changed, you could now do this instead:
publicclassMyCustomGUIextendsBasicGUI {publicMyCustomGUI(Player player) { super(newGUI("Fruit Fanatic"),Rows.SIX);finalBasicGUI loaded /*= ...loadGuiData(fileName)*/;if (loaded ==null) {// First time opening GUIsetItem(0,new Item(Material.APPLE));getGui().addTask(0,"say Fruit for life!");addResponse(0,new CommandResponder(cmdSender,"say Fruit for life!",true)); } else {// Loaded saved GUI from filesetGUI(loaded.getGui());for (finalEntry<Integer,String> entry :getGui().getTasks().entrySet()) {addResponse(entry.getKey(),new CommandResponder(cmdSender,entry.getValue(),true)); } } }}
Obviously, this is only an example. You may instead wish to copy all your GUI files to disk beforehand or only load files into memory at server startup. That's up to you!