Skip to content

Commit

Permalink
chore: Added way to set plugin instance, and fixed central publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
LichtHund committed Dec 8, 2024
1 parent bf52c70 commit 3c1a270
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 34 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -26,5 +25,5 @@ Give a ⭐️ if this project helped you!

## 📝 License

Copyright © 2021 [TriumphTeam](https://github.com/ipsk).<br />
Copyright © 2024 [TriumphTeam](https://github.com/ipsk).<br />
This project is [MIT](https://github.com/TriumphTeam/triumph-gui/blob/master/LICENSE) licensed.
19 changes: 1 addition & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
19 changes: 17 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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/")
Expand Down
23 changes: 23 additions & 0 deletions core/src/main/java/dev/triumphteam/gui/TriumphGui.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
18 changes: 11 additions & 7 deletions core/src/main/java/dev/triumphteam/gui/components/GuiType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,4 +54,7 @@ public int getLimit() {
return limit;
}

public int getFillSize() {
return fillSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void fill(@NotNull final List<GuiItem> guiItems) {
if (type == GuiType.CHEST) {
fill = gui.getRows() * type.getLimit();
} else {
fill = type.getLimit();
fill = type.getFillSize();
}

final List<GuiItem> items = repeatList(guiItems);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3c1a270

Please sign in to comment.