Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<artifactId>json</artifactId>
<version>20240303</version>
</dependency>-->
<dependency>
<groupId>com.tcoded</groupId>
<artifactId>FoliaLib</artifactId>
<version>0.5.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
Expand Down Expand Up @@ -285,14 +291,18 @@
<goals>
<goal>shade</goal>
</goals>
<!--<configuration>
<configuration>
<relocations>
<relocation>
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>de.rapha149.signgui.lib.folialib</shadedPattern>
</relocation>
<!--<relocation>
<pattern>org.json</pattern>
<shadedPattern>de.rapha149.signgui.json</shadedPattern>
</relocation>
</relocation>-->
</relocations>
</configuration>-->
</configuration>
</execution>
</executions>
</plugin>
Expand Down
27 changes: 27 additions & 0 deletions api/src/main/java/de/rapha149/signgui/FoliaLibManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.rapha149.signgui;

import com.tcoded.folialib.FoliaLib;
import org.bukkit.plugin.java.JavaPlugin;


public class FoliaLibManager {

private static FoliaLib foliaLib;
public static boolean initialized = false;

public static void initialize(JavaPlugin plugin) {
if (initialized) {
throw new IllegalStateException("FoliaLibManager is already initialized");
}

foliaLib = new FoliaLib(plugin);
initialized = true;
}

public static FoliaLib getFoliaLib() {
if (!initialized) {
throw new IllegalStateException("FoliaLibManager is not initialized");
}
return foliaLib;
}
}
3 changes: 1 addition & 2 deletions api/src/main/java/de/rapha149/signgui/SignGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import de.rapha149.signgui.exception.SignGUIVersionException;
import de.rapha149.signgui.version.VersionMatcher;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
Expand Down Expand Up @@ -108,7 +107,7 @@ public void open(Player player) throws SignGUIException {
};

if (callHandlerSynchronously)
Bukkit.getScheduler().runTask(plugin, runnable);
FoliaLibManager.getFoliaLib().getScheduler().runAtEntity(player, task -> runnable.run());
else
runnable.run();
});
Expand Down
5 changes: 2 additions & 3 deletions api/src/main/java/de/rapha149/signgui/SignGUIAction.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.rapha149.signgui;

import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
Expand Down Expand Up @@ -122,7 +121,7 @@ public SignGUIActionInfo getInfo() {

@Override
public void execute(SignGUI gui, SignEditor signEditor, Player player) {
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(inventory));
FoliaLibManager.getFoliaLib().getScheduler().runAtEntity(player, task -> player.openInventory(inventory));
}
};
}
Expand Down Expand Up @@ -175,7 +174,7 @@ public SignGUIActionInfo getInfo() {

@Override
public void execute(SignGUI gui, SignEditor signEditor, Player player) {
Bukkit.getScheduler().runTask(plugin, runnable);
FoliaLibManager.getFoliaLib().getScheduler().runAtEntity(player, task -> runnable.run());
}
};
}
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/de/rapha149/signgui/SignGUIBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ public SignGUIBuilder setHandler(SignGUIFinishHandler handler) {
public SignGUIBuilder callHandlerSynchronously(JavaPlugin plugin) {
this.callHandlerSynchronously = true;
this.plugin = plugin;

// Initialize FoliaLibManager if not already initialized
if (!FoliaLibManager.initialized) {
FoliaLibManager.initialize(plugin);
}

return this;
}

Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<id>nms-repo</id>
<url>https://repo.codemc.org/repository/nms/</url>
</repository>
<repository>
<id>tcoded-releases</id>
<url>https://repo.tcoded.com/releases</url>
</repository>
</repositories>

<build>
Expand Down