SamJakob / SpiGUI

A comprehensive GUI API for Spigot with pages support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please Write Docs!

ArvidHoppe opened this issue · comments

Please do us a favor and write good documentation.
I wasted literally 3 hours trying to figure out how to make custom Toolbars!
Not everyone knows your thoughts and your concepts!

I really like your effort and the result, don't get me wrong. But I would appreciate a good documentation :)

Have you checked out the JavaDoc? I think virtually all the methods and even fields should be documented on there:

https://javadoc.jitpack.io/com/github/SamJakob/SpiGUI/1.3.1/javadoc/index.html

Specifically, for your case:

https://javadoc.jitpack.io/com/github/SamJakob/SpiGUI/1.3.1/javadoc/index.html?com/samjakob/spigui/toolbar/SGToolbarBuilder.html

https://javadoc.jitpack.io/com/github/SamJakob/SpiGUI/1.3.1/javadoc/com/samjakob/spigui/menu/SGMenu.html#setToolbarBuilder-com.samjakob.spigui.toolbar.SGToolbarBuilder-

It should be pretty comprehensive. Was there something specific you wanted, e.g., more details in the JavaDoc, a guide or example code?

Also see here for an example in the demo code:

myAwesomeMenu.setToolbarBuilder((slot, page, defaultType, menu) -> {
if (slot == 8) {
return new SGButton(
new ItemBuilder(Material.EMERALD)
.name(String.format("&a&l%d gems", gems.getOrDefault(player, 5)))
.lore(
"&aUse gems to buy cosmetics",
"&aand other items in the store!",
"",
"&7&o(Click to add more)"
)
.build()
).withListener((event) -> {
gems.put(player, gems.getOrDefault(player, 5) + 5);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a&l&oSUCCESS! &aYou have been given &25 &agems!"));
menu.refreshInventory(event.getWhoClicked());
});
}
// Fallback to rendering the default button for a slot.
return spiGUI.getDefaultToolbarBuilder().buildToolbarButton(slot, page, defaultType, menu);
// Or, alternatively, to render a button when NEITHER a custom per-inventory button OR a fallback
// button has been defined:
// (Comment above line and uncomment below to enable this)
/*
// Ensure fallbackButton is not null before rendering. If it is, render an alternative button
// instead.
SGButton fallbackButton = spiGUI.getDefaultToolbarBuilder().buildToolbarButton(slot, page, defaultType, menu);
if (fallbackButton != null) return fallbackButton;
return new SGButton(new ItemBuilder(Material.BARRIER).name(" ").build());
// You could check if defaultType is UNASSIGNED, however this won't deal with the cases when the
// previous or next button is not shown (there will be an empty space).
*/
});

For me, javadocs are nice if you know what you want to know. But if youre new to a Project or a Library, only a JavaDoc is equali as good as decompiling the jar and read the code itself (im exaggerating here). What I missed was specific Examples and tweeks to your Library in on a centralized, searchable place.

Your JavaDoc is well done, but as an initial Doc, a javadoc isnt the best format i think :)

Fair enough! I'll write some guides on the GitHub wiki when I have time

TYSM!