Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
15c48d4
Add Folia providers
JRoy Mar 28, 2023
0e4bab2
Get like 70% of the plugin to work
JRoy Mar 28, 2023
07fbf93
Ensure nuke commands runs on correct threads
JRoy Mar 29, 2023
2088294
Actually fire init tasks in Folia
JRoy Mar 29, 2023
a649f97
Add some thread checking helper methods
JRoy Mar 29, 2023
04683ee
Fix async entity dismounts
JRoy Mar 29, 2023
1d93ebf
Fix moo
JRoy Mar 29, 2023
05a8aa8
Switch to Paper repo
JRoy Mar 30, 2023
9a5ac3c
Fix tests
JRoy Mar 30, 2023
4ff9286
Move over some discord things
JRoy Mar 30, 2023
2d8cc82
Add method for checking the global thread
JRoy Mar 30, 2023
7216fdd
Add helper methods for ensuring thread contexts
JRoy Mar 30, 2023
2ba1eb0
fix "Fix moo"
JRoy Apr 1, 2023
7279be7
allow DiscordMessageEvent calls from any context
JRoy Apr 3, 2023
4cb861b
Run interaction commands async for now (hopefully okay)
JRoy Apr 3, 2023
ec5007c
fix wrong period/timeunit for folia scheduling
JRoy Apr 12, 2023
9133dce
Merge branch '2.x' into refactor/folia
JRoy Apr 16, 2023
4256909
Fix folia init tasks never getting called LOLW
JRoy Apr 27, 2023
10fc005
Merge remote-tracking branch 'upstream/2.x' into refactor/folia
JRoy Jul 27, 2023
1a108b5
Bump folia version
JRoy Jul 27, 2023
d4ebaf6
Fix weather command
JRoy Jul 27, 2023
0c8bc16
Fix time command
JRoy Jul 27, 2023
d0493cc
Merge remote-tracking branch 'upstream/2.x' into refactor/folia
JRoy Aug 22, 2023
d73ed13
Fix time/weather commands
JRoy Aug 22, 2023
25685a8
Merge branch '2.x' into feat/folia/merge-2.x-changes
Warriorrrr Feb 13, 2026
00e3509
Update scheduling providers to work with new provider system
Warriorrrr Feb 13, 2026
b300213
Move economy layers initialization to after providers
Warriorrrr Feb 13, 2026
4423bc8
Merge branch '2.x' into fork/Warriorrrr/feat/folia/merge-2.x-changes
JRoy Feb 28, 2026
63dcfa2
sure
JRoy Feb 28, 2026
e7461bf
Run kill command on entity thread
Warriorrrr Apr 16, 2026
853ac1e
Fix merge artifact (?)
Warriorrrr Apr 16, 2026
bb0f9f3
Fix retrieving tile entity count for gc command
Warriorrrr Apr 16, 2026
eb9b7dc
Modify thunder on global thread
Warriorrrr Apr 16, 2026
736171a
Run smite with entity scheduler
Warriorrrr Apr 16, 2026
f1baa3f
Merge upstream 2.x into folia-support
Meshrifz Jul 5, 2026
48c8085
Fix ConsoleInjector.java: remove dangling reference to 2.x-deleted ra…
Meshrifz Jul 5, 2026
83b4afe
Fix baseline compile errors after 2.x merge
Meshrifz Jul 5, 2026
a496944
Disable Discord integration on Folia
Meshrifz Jul 6, 2026
db1bbd9
Disable XMPP integration on Folia
Meshrifz Jul 6, 2026
37b092d
Fix /nyan command's Folia-unsafe BukkitRunnable
Meshrifz Jul 6, 2026
db41722
Always dispatch command-map reload mutations onto the global thread
Meshrifz Jul 6, 2026
471abd4
Make Backup's shared fields volatile for cross-thread visibility
Meshrifz Jul 6, 2026
70c8cec
Dispatch /antioch's TNT spawn onto the target location's region thread
Meshrifz Jul 6, 2026
8bf901f
Fix /lightning's self-strike branch to dispatch onto the strike's own…
Meshrifz Jul 6, 2026
8bd35e2
Dispatch /spawner's block read+mutation onto the target's region thread
Meshrifz Jul 6, 2026
3610655
Dispatch EssentialsTimer's AFK-kick and notify loop through scheduleE…
Meshrifz Jul 6, 2026
75a2666
Resolve RandomTeleport's FIXME: dispatch Y-lookup onto the region thread
Meshrifz Jul 6, 2026
3d0877f
Dispatch AsyncTeleport.nowAsync's safety check + teleport onto the de…
Meshrifz Jul 6, 2026
2baadbc
Restore real TPS calculation for /tps and the {TPS} placeholder
Meshrifz Jul 6, 2026
be8a8b9
Fix onDisable() crash on Folia: legacy scheduler.cancelTasks() is uns…
Meshrifz Jul 6, 2026
cf50889
Fix PaperLib misdetecting Minecraft 26.x, causing Folia teleport/bed-…
Meshrifz Jul 7, 2026
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
2 changes: 2 additions & 0 deletions Essentials/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
api(project(path: ':providers:PaperProvider', configuration: 'shadow')){
exclude(module: 'paper-api')
}
api project(':providers:FoliaProvider')
api(project(':providers:NMSReflectionProvider')) {
exclude(module: 'bukkit')
}
Expand Down Expand Up @@ -73,6 +74,7 @@ shadowJar {
include (dependency('net.kyori:adventure-text-minimessage'))
include (project(':providers:BaseProviders'))
include (project(path: ':providers:PaperProvider', configuration: 'shadow'))
include (project(':providers:FoliaProvider'))
include (project(':providers:NMSReflectionProvider'))
include (project(':providers:1_8Provider'))
include (project(':providers:1_12Provider'))
Expand Down
71 changes: 29 additions & 42 deletions Essentials/src/main/java/com/earth2me/essentials/AsyncTeleport.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,6 @@ public void nowUnsafe(Location loc, TeleportCause cause, CompletableFuture<Boole
paperFuture.exceptionally(future::completeExceptionally);
}

private void runOnMain(final Runnable runnable) throws ExecutionException, InterruptedException {
if (Bukkit.isPrimaryThread()) {
runnable.run();
return;
}
final CompletableFuture<Object> taskLock = new CompletableFuture<>();
Bukkit.getScheduler().runTask(ess, () -> {
runnable.run();
taskLock.complete(new Object());
});
taskLock.get();
}

protected void nowAsync(final IUser teleportee, final ITarget target, final TeleportCause cause, final CompletableFuture<Boolean> future) {
cancel(false);

Expand All @@ -169,8 +156,8 @@ protected void nowAsync(final IUser teleportee, final ITarget target, final Tele
}

try {
runOnMain(() -> teleportee.getBase().eject()); //EntityDismountEvent requires a sync context.
} catch (final ExecutionException | InterruptedException e) {
ess.ensureEntity(teleportee.getBase(), () -> teleportee.getBase().eject()); //EntityDismountEvent requires a sync context.
} catch (final RuntimeException e) {
future.completeExceptionally(e);
return;
}
Expand All @@ -186,38 +173,38 @@ protected void nowAsync(final IUser teleportee, final ITarget target, final Tele
targetLoc.setZ(LocationUtil.getZInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockZ()));
}
PaperLib.getChunkAtAsync(targetLoc.getWorld(), targetLoc.getBlockX() >> 4, targetLoc.getBlockZ() >> 4, true, true).thenAccept(chunk -> {
Location loc = targetLoc;
if (LocationUtil.isBlockUnsafeForUser(ess, teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
if (ess.getSettings().isTeleportSafetyEnabled()) {
if (ess.getSettings().isForceDisableTeleportSafety()) {
//The chunk we're teleporting to is 100% going to be loaded here, no need to teleport async.
teleportee.getBase().teleport(loc, cause);
} else {
try {
//There's a chance the safer location is outside the loaded chunk so still teleport async here.
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
} catch (final Exception e) {
future.completeExceptionally(e);
return;
ess.scheduleLocationDelayedTask(targetLoc, () -> {
Location loc = targetLoc;
if (LocationUtil.isBlockUnsafeForUser(ess, teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
if (ess.getSettings().isTeleportSafetyEnabled()) {
if (ess.getSettings().isForceDisableTeleportSafety()) {
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
} else {
try {
//There's a chance the safer location is outside the loaded chunk so still teleport async here.
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
} catch (final Exception e) {
future.completeExceptionally(e);
return;
}
}
} else {
future.completeExceptionally(new TranslatableException("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
return;
}
} else {
future.completeExceptionally(new TranslatableException("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
return;
}
} else {
if (ess.getSettings().isForceDisableTeleportSafety()) {
//The chunk we're teleporting to is 100% going to be loaded here, no need to teleport async.
teleportee.getBase().teleport(loc, cause);
} else {
if (ess.getSettings().isTeleportToCenterLocation()) {
loc = LocationUtil.getRoundedDestination(loc);
if (ess.getSettings().isForceDisableTeleportSafety()) {
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
} else {
if (ess.getSettings().isTeleportToCenterLocation()) {
loc = LocationUtil.getRoundedDestination(loc);
}
//There's a *small* chance the rounded destination produces a location outside the loaded chunk so still teleport async here.
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
}
//There's a *small* chance the rounded destination produces a location outside the loaded chunk so still teleport async here.
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
}
}
future.complete(true);
future.complete(true);
});
}).exceptionally(th -> {
future.completeExceptionally(th);
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.earth2me.essentials;

import java.util.UUID;
import java.util.concurrent.CompletableFuture;

import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.ess3.provider.SchedulingProvider;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;

import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

import net.essentialsx.api.v2.events.TeleportWarmupCancelledEvent;
import net.essentialsx.api.v2.events.TeleportWarmupCancelledEvent.CancelReason;

Expand All @@ -31,7 +32,7 @@ public class AsyncTimedTeleport implements Runnable {
private final boolean timer_canMove;
private final Trade timer_chargeFor;
private final TeleportCause timer_cause;
private int timer_task;
private SchedulingProvider.EssentialsTask timer_task;
private double timer_health;

AsyncTimedTeleport(final IUser user, final IEssentials ess, final AsyncTeleport teleport, final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
Expand All @@ -55,7 +56,7 @@ public class AsyncTimedTeleport implements Runnable {
this.timer_respawn = respawn;
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");

timer_task = ess.runTaskTimerAsynchronously(this, 20, 20).getTaskId();
timer_task = ess.runTaskTimerAsynchronously(this, 20, 20);

if (future != null) {
this.parentFuture = future;
Expand Down Expand Up @@ -142,16 +143,16 @@ public void run() {
}
}

ess.scheduleSyncDelayedTask(new DelayedTeleportTask());
ess.scheduleEntityDelayedTask(teleportOwner.getBase(), new DelayedTeleportTask());
}

//If we need to cancelTimer a pending teleportPlayer call this method
void cancelTimer(final boolean notifyUser) {
if (timer_task == -1) {
if (timer_task == null) {
return;
}
try {
ess.getServer().getScheduler().cancelTask(timer_task);
timer_task.cancel();

final IUser teleportUser = ess.getUser(this.timer_teleportee);
if (teleportUser != null && teleportUser.getBase() != null) {
Expand All @@ -167,7 +168,7 @@ void cancelTimer(final boolean notifyUser) {
}
}
} finally {
timer_task = -1;
timer_task = null;
}
}
}
19 changes: 10 additions & 9 deletions Essentials/src/main/java/com/earth2me/essentials/Backup.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.earth2me.essentials;

import net.ess3.api.IEssentials;
import net.ess3.provider.SchedulingProvider;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;

Expand All @@ -17,10 +18,10 @@ public class Backup implements Runnable {
private transient final Server server;
private transient final IEssentials ess;
private final AtomicBoolean pendingShutdown = new AtomicBoolean(false);
private transient boolean running = false;
private transient int taskId = -1;
private transient boolean active = false;
private transient CompletableFuture<Object> taskLock = null;
private transient volatile boolean running = false;
private transient volatile SchedulingProvider.EssentialsTask task = null;
private transient volatile boolean active = false;
private transient volatile CompletableFuture<Object> taskLock = null;

public Backup(final IEssentials ess) {
this.ess = ess;
Expand All @@ -36,10 +37,10 @@ public void onPlayerJoin() {

public synchronized void stopTask() {
running = false;
if (taskId != -1) {
server.getScheduler().cancelTask(taskId);
if (task != null) {
task.cancel();
}
taskId = -1;
task = null;
}

private synchronized void startTask() {
Expand All @@ -48,7 +49,7 @@ private synchronized void startTask() {
if (interval < 1200) {
return;
}
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
task = ess.scheduleGlobalRepeatingTask(this, interval, interval);
running = true;
}
}
Expand Down Expand Up @@ -123,7 +124,7 @@ public void run() {
}

if (!pendingShutdown.get()) {
ess.scheduleSyncDelayedTask(new BackupEnableSaveTask());
ess.scheduleGlobalDelayedTask(new BackupEnableSaveTask());
}
}
});
Expand Down
Loading