Skip to content

Commit 6596367

Browse files
Add missing javadoc
1 parent 6feac53 commit 6596367

18 files changed

+108
-4
lines changed

invui/src/main/java/xyz/xenondevs/invui/Click.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ public record Click(
1515
Player player,
1616
ClickType clickType,
1717
int hotbarButton
18-
) {
18+
)
19+
{
1920

21+
/**
22+
* Creates a new {@link Click} with the given player and click type.
23+
*
24+
* @param player The player who clicked.
25+
* @param clickType The type of click.
26+
*/
2027
public Click(Player player, ClickType clickType) {
2128
this(player, clickType, -1);
2229
}

invui/src/main/java/xyz/xenondevs/invui/InvUI.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import java.util.List;
1313
import java.util.logging.Logger;
1414

15+
/**
16+
* Main class of InvUI, managing the plugin instance.
17+
*/
1518
public class InvUI implements Listener {
1619

1720
private static final InvUI INSTANCE = new InvUI();
@@ -22,10 +25,23 @@ public class InvUI implements Listener {
2225
private InvUI() {
2326
}
2427

28+
/**
29+
* Returns the singleton instance of InvUI.
30+
*
31+
* @return the InvUI instance
32+
*/
2533
public static InvUI getInstance() {
2634
return INSTANCE;
2735
}
2836

37+
/**
38+
* Gets the plugin instance that InvUI is running under.
39+
* If possible, the plugin instance is inferred from the class loader.
40+
* If this is not possible, the plugin instance must be set manually using {@link #setPlugin(Plugin)} beforehand.
41+
*
42+
* @return The plugin instance.
43+
* @throws IllegalStateException If the plugin instance is not set and cannot be inferred.
44+
*/
2945
public Plugin getPlugin() {
3046
if (plugin == null) {
3147
setPlugin(tryFindPlugin());
@@ -52,6 +68,13 @@ public Plugin getPlugin() {
5268
return null;
5369
}
5470

71+
/**
72+
* Sets the plugin instance that InvUI is running under.
73+
* This is used to register event listeners, schedule tasks, etc.
74+
*
75+
* @param plugin The plugin instance to set.
76+
* @throws IllegalStateException If the plugin instance is already set.
77+
*/
5578
public void setPlugin(@Nullable Plugin plugin) {
5679
if (this.plugin != null)
5780
throw new IllegalStateException("Plugin is already set");
@@ -63,10 +86,21 @@ public void setPlugin(@Nullable Plugin plugin) {
6386
this.plugin = plugin;
6487
}
6588

89+
/**
90+
* Gets the logger of the configured plugin instance.
91+
*
92+
* @return The logger of the plugin instance.
93+
* @throws IllegalStateException If the plugin instance is not set and cannot be inferred.
94+
*/
6695
public Logger getLogger() {
6796
return getPlugin().getLogger();
6897
}
6998

99+
/**
100+
* Adds a {@link Runnable} that is executed when the plugin is disabled.
101+
*
102+
* @param runnable The runnable to execute on plugin disable.
103+
*/
70104
public void addDisableHandler(Runnable runnable) {
71105
disableHandlers.add(runnable);
72106
}

invui/src/main/java/xyz/xenondevs/invui/gui/AbstractIngredientMapper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
@SuppressWarnings("unchecked")
1414
abstract class AbstractIngredientMapper<S extends AbstractIngredientMapper<S>> implements IngredientMapper<S> {
1515

16+
/**
17+
* Maps ingredient keys ({@link Character characters}) to their corresponding {@link Ingredient} instances.
18+
*/
1619
protected HashMap<Character, Ingredient> ingredientMap = new HashMap<>();
1720

1821
@Override
@@ -93,6 +96,9 @@ public S clone() {
9396
}
9497
}
9598

99+
/**
100+
* Called when the ingredient mapping is updated.
101+
*/
96102
protected void handleUpdate() {}
97103

98104
}

invui/src/main/java/xyz/xenondevs/invui/gui/ScrollGui.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.util.List;
1212
import java.util.SequencedSet;
1313
import java.util.function.BiConsumer;
14-
import java.util.function.Consumer;
1514

1615
/**
1716
* A {@link Gui} that displays content in lines that can be scrolled through.
@@ -36,6 +35,7 @@ static Builder<Item> itemsBuilder() {
3635
* @param height The height of the {@link ScrollGui}.
3736
* @param items The {@link Item Items} to use.
3837
* @param contentListSlots The slots where content should be displayed.
38+
* @param direction The direction in which the {@link ScrollGui} will scroll.
3939
* @return The created {@link ScrollGui}.
4040
*/
4141
static ScrollGui<Item> ofItems(int width, int height, List<? extends Item> items, SequencedSet<Slot> contentListSlots, ScrollDirection direction) {
@@ -69,6 +69,7 @@ static Builder<Gui> guisBuilder() {
6969
* @param height The height of the {@link ScrollGui}.
7070
* @param guis The {@link Gui Guis} to use.
7171
* @param contentListSlots The slots where content should be displayed.
72+
* @param direction The direction in which the {@link ScrollGui} will scroll.
7273
* @return The created {@link ScrollGui}.
7374
*/
7475
static ScrollGui<Gui> ofGuis(int width, int height, List<? extends Gui> guis, SequencedSet<Slot> contentListSlots, ScrollDirection direction) {
@@ -102,6 +103,7 @@ static Builder<Inventory> inventoriesBuilder() {
102103
* @param height The height of the {@link ScrollGui}.
103104
* @param inventories The {@link Inventory VirtualInventories} to use.
104105
* @param contentListSlots The slots where content should be displayed.
106+
* @param direction The direction in which the {@link ScrollGui} will scroll.
105107
* @return The created {@link ScrollGui}.
106108
*/
107109
static ScrollGui<Inventory> ofInventories(int width, int height, List<? extends Inventory> inventories, SequencedSet<Slot> contentListSlots, ScrollDirection direction) {

invui/src/main/java/xyz/xenondevs/invui/gui/SlotElement.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public SlotElement getHoldingElement() {
6262
*/
6363
record InventoryLink(Inventory inventory, int slot, @Nullable ItemProvider background) implements SlotElement {
6464

65+
/**
66+
* Creates a new {@link InventoryLink} using the given {@link Inventory} and slot.
67+
*
68+
* @param inventory The {@link Inventory} to link to
69+
* @param slot The slot in the {@link Inventory} to link to
70+
*/
6571
public InventoryLink(Inventory inventory, int slot) {
6672
this(inventory, slot, null);
6773
}

invui/src/main/java/xyz/xenondevs/invui/i18n/Languages.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public class Languages {
3131
private Languages() {
3232
}
3333

34+
/**
35+
* Gets the singleton instance of Languages.
36+
* @return The singleton instance of Languages.
37+
*/
3438
public static Languages getInstance() {
3539
return INSTANCE;
3640
}

invui/src/main/java/xyz/xenondevs/invui/inventory/Inventory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ public void removeViewer(AbstractWindow<?> viewer, int what, int how) {
224224

225225
/**
226226
* Gets all {@link Window Windows} displaying this {@link Inventory}.
227+
*
228+
* @return A list of all {@link Window Windows} displaying this {@link Inventory}.
227229
*/
228230
public List<Window> getWindows() {
229231
var windows = new ArrayList<Window>();

invui/src/main/java/xyz/xenondevs/invui/inventory/InventorySlot.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
/**
44
* A record encapsulating a slot of an {@link Inventory}.
5+
*
6+
* @param inventory The {@link Inventory} this slot belongs to.
7+
* @param slot The slot index in the {@link Inventory}.
58
*/
69
public record InventorySlot(Inventory inventory, int slot) {
710

invui/src/main/java/xyz/xenondevs/invui/inventory/event/PlayerUpdateReason.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public sealed interface PlayerUpdateReason extends UpdateReason {
2929
*/
3030
record Click(Player player, xyz.xenondevs.invui.Click click) implements PlayerUpdateReason {
3131

32+
/**
33+
* Creates a new {@link Click} update reason from a {@link xyz.xenondevs.invui.Click}.
34+
*
35+
* @param click The click that was performed.
36+
*/
3237
public Click(xyz.xenondevs.invui.Click click) {
3338
this(click.player(), click);
3439
}
@@ -52,7 +57,7 @@ record Drag(
5257
/**
5358
* A {@link PlayerUpdateReason} for selecting an item in a bundle.
5459
*
55-
* @param player The player that selected the item.
60+
* @param player The player that selected the item.
5661
* @param bundleSlot The slot inside the bundle that was selected.
5762
*/
5863
record BundleSelect(Player player, int bundleSlot) implements PlayerUpdateReason {}

invui/src/main/java/xyz/xenondevs/invui/item/Item.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public sealed interface Item permits AbstractItem, BoundItem {
5353
* Called when the {@link #getItemProvider(Player) ItemProvider} has bundle contents
5454
* and the player selects a bundle slot.
5555
*
56+
* @param player The {@link Player} that interacted with the bundle.
5657
* @param bundleSlot The selected bundle slot, or -1 if the player's cursor left the {@link ItemProvider}.
5758
*/
5859
void handleBundleSelect(Player player, int bundleSlot);

0 commit comments

Comments
 (0)