Updated FoliaLib dependency. Fixed ProcessPlayerEvent scheduler in WorldGuardPlugin.java. Fixed cancelling of Bukkit tasks if not running on Folia. Made SessionManager task async. Updated PaperAPI to 1.20.2. Fixed plugin.yml formatting. Updated README.md to reflect new project member(@Loving11ish).

This commit is contained in:
Loving11ish 2024-01-28 23:41:21 +00:00
parent 50e4f4a6a1
commit b658d97d95
10 changed files with 43 additions and 31 deletions

View File

@ -38,9 +38,12 @@ Please read CONTRIBUTING.md for important guidelines to follow.
Submissions must be licensed under the GNU Lesser General Public License v3.
# Folia Inquisitors
This Folia support is maintained by the following organizations and people:
[<img src="https://github.com/Folia-Inquisitors.png" width=80 alt="Folia-Inquisitors">](https://github.com/orgs/Folia-Inquisitors/repositories)
[<img src="https://github.com/TechnicallyCoded.png" width=80 alt="TechnicallyCoded">](https://github.com/TechnicallyCoded)
[<img src="https://github.com/Yomamaeatstoes.png" width=80 alt="Yomamaeatstoes">](https://github.com/Yomamaeatstoes)
[<img src="https://github.com/Loving11ish.png" width=80 alt="Loving11ish">](https://github.com/Loving11ish)
Links
-----

View File

@ -1,2 +1,2 @@
group=com.sk89q.worldguard
version=7.1.0-SNAPSHOT-Custom-Folia
version=7.1.0-SNAPSHOT

View File

@ -24,13 +24,13 @@
dependencies {
"api"(project(":worldguard-core"))
"compileOnly"("io.papermc.paper:paper-api:1.20-R0.1-SNAPSHOT")
"runtimeOnly"("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") {
"compileOnly"("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
"runtimeOnly"("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") {
exclude("junit", "junit")
}
"api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false }
"implementation"("com.google.guava:guava:${Versions.GUAVA}")
"implementation"("com.tcoded:FoliaLib:0.2.3")
"implementation"("com.tcoded:FoliaLib:0.3.1")
"compileOnly"("com.sk89q:commandbook:2.3") { isTransitive = false }
"shadeOnly"("io.papermc:paperlib:1.0.8")
"shadeOnly"("org.bstats:bstats-bukkit:3.0.1")

View File

@ -96,7 +96,7 @@ public void onChunkUnload(ChunkUnloadEvent event) {
}, plugin);
int interval = CACHE_INVALIDATION_INTERVAL * 50;
plugin.foliaLib.getImpl().runTimerAsync(cache::invalidateAll, interval, interval, TimeUnit.MILLISECONDS);
plugin.getFoliaLib().getImpl().runTimerAsync(cache::invalidateAll, interval, interval, TimeUnit.MILLISECONDS);
// Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, cache::invalidateAll, CACHE_INVALIDATION_INTERVAL, CACHE_INVALIDATION_INTERVAL);
}

View File

@ -114,7 +114,7 @@ public class WorldGuardPlugin extends JavaPlugin {
private static final int BSTATS_PLUGIN_ID = 3283;
public FoliaLib foliaLib;
private FoliaLib foliaLib;
/**
* Construct objects. Actual loading occurs when the plugin is enabled, so
@ -174,7 +174,7 @@ public void onEnable() {
}
int runDelayMs = BukkitSessionManager.RUN_DELAY * 50;
foliaLib.getImpl().runTimer(sessionManager, runDelayMs, runDelayMs, TimeUnit.MILLISECONDS);
foliaLib.getImpl().runTimerAsync(sessionManager, runDelayMs, runDelayMs, TimeUnit.MILLISECONDS);
// getServer().getScheduler().scheduleSyncRepeatingTask(this, sessionManager, BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);
// Register events
@ -216,25 +216,28 @@ public void onEnable() {
}
worldListener.registerEvents();
if (foliaLib.isFolia()) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
foliaLib.getImpl().runAtEntity(player, new Runnable() {
@Override
public void run() {
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
Events.fire(event);
}
});
}
}
else {
Bukkit.getScheduler().runTask(this, () -> {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
Events.fire(event);
}
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
foliaLib.getImpl().runAtEntity(player, (task) -> {
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
Events.fire(event);
});
}
// if (foliaLib.isFolia()) {
// for (Player player : Bukkit.getServer().getOnlinePlayers()) {
// foliaLib.getImpl().runAtEntity(player, (task) -> {
// ProcessPlayerEvent event = new ProcessPlayerEvent(player);
// Events.fire(event);
// });
// }
// }
// else {
// Bukkit.getScheduler().runTask(this, () -> {
// for (Player player : Bukkit.getServer().getOnlinePlayers()) {
// ProcessPlayerEvent event = new ProcessPlayerEvent(player);
// Events.fire(event);
// }
// });
// }
((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).setInitialized(true);
((SimpleDomainRegistry) WorldGuard.getInstance().getDomainRegistry()).setInitialized(true);
@ -290,7 +293,9 @@ private void setupCustomCharts(Metrics metrics) {
@Override
public void onDisable() {
WorldGuard.getInstance().disable();
// this.getServer().getScheduler().cancelTasks(this);
if (!foliaLib.isFolia()) {
this.getServer().getScheduler().cancelTasks(this);
}
foliaLib.getImpl().cancelAllTasks();
}
@ -551,4 +556,7 @@ public PlayerMoveListener getPlayerMoveListener() {
return playerMoveListener;
}
public FoliaLib getFoliaLib() {
return foliaLib;
}
}

View File

@ -994,7 +994,7 @@ public void onInventoryMoveItem(InventoryMoveItemEvent event) {
Hopper hopperCauseHolder = (Hopper) causeHolder;
Location location = hopperCauseHolder.getLocation();
getPlugin().foliaLib.getImpl().runAtLocationLater(location, () -> {
getPlugin().getFoliaLib().getImpl().runAtLocationLater(location, () -> {
Block block = location.getBlock();
if (block.getType() == Material.HOPPER) {
block.breakNaturally();

View File

@ -133,7 +133,7 @@ public void onPlayerMove(PlayerMoveEvent event) {
player.teleport(override.clone().add(0, 1, 0));
getPlugin().foliaLib.getImpl().runAtEntityLater(player, () -> {
getPlugin().getFoliaLib().getImpl().runAtEntityLater(player, () -> {
player.teleport(override.clone().add(0, 1, 0));
}, 50, TimeUnit.MILLISECONDS);
// Bukkit.getScheduler().runTaskLater(getPlugin(), () -> player.teleport(override.clone().add(0, 1, 0)), 1);

View File

@ -72,10 +72,10 @@ public void run() {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
Session session = get(localPlayer);
FoliaLib foliaLib = WorldGuardPlugin.inst().foliaLib;
FoliaLib foliaLib = WorldGuardPlugin.inst().getFoliaLib();
ServerImplementation impl = foliaLib.getImpl();
if (foliaLib.isFolia()) impl.runAtEntity(player, () -> session.tick(localPlayer));
if (foliaLib.isFolia()) impl.runAtEntity(player, (task) -> session.tick(localPlayer));
else session.tick(localPlayer);
}
}

View File

@ -25,6 +25,7 @@
import com.google.common.cache.LoadingCache;
import com.sk89q.worldedit.util.report.DataReport;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.tcoded.folialib.wrapper.task.WrappedTask;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
@ -53,7 +54,7 @@ public Optional<Field> load(Class<?> clazz) throws Exception {
public SchedulerReport() {
super("Scheduler");
append("Error", "MODDED FOLIA VERSION - DO NOT REPORT TO WORLDGUARD");
append("Error", "FOLIA VERSION - PLEASE REPORT TO WORLDGUARD");
// List<BukkitTask> tasks = Bukkit.getServer().getScheduler().getPendingTasks();
//// WorldGuardPlugin.inst().foliaLib.getImpl().

View File

@ -4,4 +4,4 @@ version: "${internalVersion}"
depend: [WorldEdit]
softdepend: [CommandBook]
api-version: "1.20"
folia-supported: true
folia-supported: true