Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
theEvilReaper committed Jun 15, 2024
1 parent 12fca91 commit 31d411e
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/main/java/net/onelitefeather/bettergopaint/utils/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@

import java.util.List;

/**
* A utility class to generate GUIs for the goPaint plugin.
* @version 1.0.0
* @since 1.0.0
*/
public final class GUI {

private static final String INCREASE_DECREASE_LORE = "\n§7Left click to increase\n§7Right click to decrease";
Expand All @@ -57,12 +62,21 @@ private GUI() {
throw new UnsupportedOperationException("This class cannot be instantiated");
}

public static @NotNull Inventory create(PlayerBrush pb) {
/**
* Creates a new {@link Inventory} with the current {@link PlayerBrush} settings.
* @param pb the player brush to get the settings from
* @return the generated inventory
*/
public static @NotNull Inventory create(@NotNull PlayerBrush pb) {
Inventory inv = Bukkit.createInventory(null, 54, Component.text("goPaint Menu", NamedTextColor.DARK_BLUE));
update(inv, pb);
return inv;
}

/**
* Generates an {@link Inventory} with all the brushes represented by an {@link ItemStack}.
* @return the generated inventory
*/
public static @NotNull Inventory generateBrushes() {
Inventory inv = Bukkit.createInventory(null, 27, Component.text("goPaint Brushes", NamedTextColor.DARK_BLUE));
// FILLER
Expand All @@ -76,12 +90,21 @@ private GUI() {
return inv;
}

/**
* Applies a default formating to the given {@link Inventory}.
* @param inventory the inventory to format
*/
private static void formatDefault(@NotNull Inventory inventory) {
for (int slot = 0; slot < inventory.getSize(); slot++) {
inventory.setItem(slot, LIME_DECORATION);
}
}

/**
* Updates the given {@link Inventory} with the current {@link PlayerBrush} settings.
* @param inventory the inventory to update
* @param playerBrush the player brush to get the settings from
*/
public static void update(@NotNull Inventory inventory, @NotNull PlayerBrush playerBrush) {
Brush brush = playerBrush.brush();

Expand Down Expand Up @@ -155,6 +178,14 @@ public static void update(@NotNull Inventory inventory, @NotNull PlayerBrush pla
inventory.setItem(21, WHITE_DECORATION);
}

if (brush instanceof SplatterBrush || brush instanceof PaintBrush || brush instanceof GradientBrush) {
inventory.setItem(3, WHITE_DECORATION);
inventory.setItem(12, Items.create(Material.BLAZE_POWDER, 1,
"§6Falloff Strength: §e" + playerBrush.falloffStrength() + "%",
INCREASE_DECREASE_LORE
));
inventory.setItem(21, WHITE_DECORATION);
}
// angle settings
if (brush instanceof GradientBrush) {
inventory.setItem(4, WHITE_DECORATION);
Expand All @@ -165,15 +196,6 @@ public static void update(@NotNull Inventory inventory, @NotNull PlayerBrush pla
inventory.setItem(22, WHITE_DECORATION);
}

if (brush instanceof SplatterBrush || brush instanceof PaintBrush || brush instanceof GradientBrush) {
inventory.setItem(3, WHITE_DECORATION);
inventory.setItem(12, Items.create(Material.BLAZE_POWDER, 1,
"§6Falloff Strength: §e" + playerBrush.falloffStrength() + "%",
INCREASE_DECREASE_LORE
));
inventory.setItem(21, WHITE_DECORATION);
}


// Size
inventory.setItem(5, WHITE_DECORATION);
Expand Down Expand Up @@ -289,5 +311,4 @@ private static void addSurfaceModeSwitch(@NotNull Inventory inv, @NotNull Player
));
inv.setItem(25, pane);
}

}

0 comments on commit 31d411e

Please sign in to comment.