diff --git a/README.md b/README.md index 72f3317a..75c07434 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,8 @@ 👤 **TriumphTeam** -* Documentation: https://triumphteam.dev/docs/triumph-gui 🚧 **work in progress** +* Documentation: https://triumphteam.dev/docs/triumph-gui 🚧 * Maven Central: https://search.maven.org/artifact/dev.triumphteam/triumph-gui -* Github: [@ipsk](https://github.com/ipsk) ## 🤝 Contributing @@ -26,5 +25,5 @@ Give a ⭐️ if this project helped you! ## 📝 License -Copyright © 2021 [TriumphTeam](https://github.com/ipsk).
+Copyright © 2024 [TriumphTeam](https://github.com/ipsk).
This project is [MIT](https://github.com/TriumphTeam/triumph-gui/blob/master/LICENSE) licensed. diff --git a/build.gradle.kts b/build.gradle.kts index 9a5b239a..26b6d9db 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,22 +21,5 @@ subprojects { } group = "dev.triumphteam" - version = "3.1.11-SNAPSHOT" - - dependencies { - compileOnly("org.jetbrains:annotations:21.0.1") - - val adventureVersion = "4.17.0" - api("net.kyori:adventure-api:$adventureVersion") - api("net.kyori:adventure-text-serializer-legacy:$adventureVersion") - api("net.kyori:adventure-text-serializer-gson:$adventureVersion") - api("net.kyori:adventure-platform-bukkit:4.3.4") - } - - license { - header = rootProject.file("LICENSE") - encoding = "UTF-8" - mapping("java", "JAVADOC_STYLE") - include("**/*.java") - } + version = "3.1.11" } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index bd348550..3fd74b56 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -11,6 +11,21 @@ repositories { dependencies { compileOnly("com.mojang:authlib:1.5.25") compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") + + compileOnly("org.jetbrains:annotations:21.0.1") + + val adventureVersion = "4.17.0" + api("net.kyori:adventure-api:$adventureVersion") + api("net.kyori:adventure-text-serializer-legacy:$adventureVersion") + api("net.kyori:adventure-text-serializer-gson:$adventureVersion") + api("net.kyori:adventure-platform-bukkit:4.3.4") +} + +license { + header = rootProject.file("LICENSE") + encoding = "UTF-8" + mapping("java", "JAVADOC_STYLE") + include("**/*.java") } val javaComponent: SoftwareComponent = components["java"] @@ -90,8 +105,8 @@ tasks { } credentials { - username = System.getenv("SONATYPE_USER") - password = System.getenv("SONATYPE_PASSWORD") + username = project.providers.gradleProperty("ossrh.username").get() + password = project.providers.gradleProperty("ossrh.password").get() } url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") diff --git a/core/src/main/java/dev/triumphteam/gui/TriumphGui.java b/core/src/main/java/dev/triumphteam/gui/TriumphGui.java new file mode 100644 index 00000000..13225a8d --- /dev/null +++ b/core/src/main/java/dev/triumphteam/gui/TriumphGui.java @@ -0,0 +1,23 @@ +package dev.triumphteam.gui; + +import dev.triumphteam.gui.guis.BaseGui; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; + +public final class TriumphGui { + + // The plugin instance for registering the event and for the close delay. + private static Plugin PLUGIN = null; + + private TriumphGui() {} + + public static void init(final @NotNull Plugin plugin) { + PLUGIN = plugin; + } + + public static @NotNull Plugin getPlugin() { + if (PLUGIN == null) init(JavaPlugin.getProvidingPlugin(BaseGui.class)); + return PLUGIN; + } +} diff --git a/core/src/main/java/dev/triumphteam/gui/components/GuiType.java b/core/src/main/java/dev/triumphteam/gui/components/GuiType.java index a2443060..aaabd4f4 100644 --- a/core/src/main/java/dev/triumphteam/gui/components/GuiType.java +++ b/core/src/main/java/dev/triumphteam/gui/components/GuiType.java @@ -26,22 +26,23 @@ import org.bukkit.event.inventory.InventoryType; import org.jetbrains.annotations.NotNull; -// TODO COMMENTS public enum GuiType { - CHEST(InventoryType.CHEST, 9), - WORKBENCH(InventoryType.WORKBENCH, 9), - HOPPER(InventoryType.HOPPER, 5), - DISPENSER(InventoryType.DISPENSER, 8), - BREWING(InventoryType.BREWING, 4); + CHEST(InventoryType.CHEST, 9, 9), + WORKBENCH(InventoryType.WORKBENCH, 9, 10), + HOPPER(InventoryType.HOPPER, 5, 5), + DISPENSER(InventoryType.DISPENSER, 8, 9), + BREWING(InventoryType.BREWING, 4, 5); @NotNull private final InventoryType inventoryType; private final int limit; + private final int fillSize; - GuiType(@NotNull final InventoryType inventoryType, final int limit) { + GuiType(@NotNull final InventoryType inventoryType, final int limit, final int fillSize) { this.inventoryType = inventoryType; this.limit = limit; + this.fillSize = fillSize; } @NotNull @@ -53,4 +54,7 @@ public int getLimit() { return limit; } + public int getFillSize() { + return fillSize; + } } diff --git a/core/src/main/java/dev/triumphteam/gui/components/util/GuiFiller.java b/core/src/main/java/dev/triumphteam/gui/components/util/GuiFiller.java index a7a4d09e..ced3ebfa 100644 --- a/core/src/main/java/dev/triumphteam/gui/components/util/GuiFiller.java +++ b/core/src/main/java/dev/triumphteam/gui/components/util/GuiFiller.java @@ -189,7 +189,7 @@ public void fill(@NotNull final List guiItems) { if (type == GuiType.CHEST) { fill = gui.getRows() * type.getLimit(); } else { - fill = type.getLimit(); + fill = type.getFillSize(); } final List items = repeatList(guiItems); diff --git a/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java b/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java index b2dcc234..e0bc047f 100644 --- a/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java +++ b/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java @@ -23,6 +23,7 @@ */ package dev.triumphteam.gui.guis; +import dev.triumphteam.gui.TriumphGui; import dev.triumphteam.gui.components.GuiAction; import dev.triumphteam.gui.components.GuiType; import dev.triumphteam.gui.components.InteractionModifier; @@ -43,7 +44,6 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,7 +68,7 @@ public abstract class BaseGui implements InventoryHolder { // The plugin instance for registering the event and for the close delay. - private static final Plugin plugin = JavaPlugin.getProvidingPlugin(BaseGui.class); + private static final Plugin plugin = TriumphGui.getPlugin(); private static Method GET_SCHEDULER_METHOD = null; diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02c..81aa1c04 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists