Skip to content

Commit

Permalink
Re-support Folia :
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Jul 7, 2024
1 parent f31c2e6 commit d94cbe7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ jobs:
name: logs for ${{ matrix.os }}
path: '**/*.log'

- name: Upload WorldEdit jar
uses: actions/upload-artifact@v2
with:
name: WorldEdit-Folia-Snapshot
path: worldedit-bukkit/build/libs/*
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ public boolean isActive() {
updateActive();
} else {
// we should update it eventually
Bukkit.getScheduler().callSyncMethod(plugin,
Bukkit.getGlobalRegionScheduler().execute(plugin,
this::updateActive);
/*Bukkit.getScheduler().callSyncMethod(plugin,
() -> {
updateActive();
return null;
});
});*/
}
return active;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public Location getLocation() {
public boolean setLocation(Location location) {
org.bukkit.entity.Entity entity = entityRef.get();
if (entity != null) {
return entity.teleport(BukkitAdapter.adapt(location));
entity.teleportAsync(BukkitAdapter.adapt(location));
return true;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ public void print(Component component) {

@Override
public boolean trySetPosition(Vector3 pos, float pitch, float yaw) {
return player.teleport(new Location(player.getWorld(), pos.x(), pos.y(),
player.teleportAsync(new Location(player.getWorld(), pos.x(), pos.y(),
pos.z(), yaw, pitch));
return true;
}

@Override
Expand Down Expand Up @@ -224,7 +225,8 @@ public com.sk89q.worldedit.util.Location getLocation() {

@Override
public boolean setLocation(com.sk89q.worldedit.util.Location location) {
return player.teleport(BukkitAdapter.adapt(location));
player.teleportAsync(BukkitAdapter.adapt(location));
return true;
}

@SuppressWarnings("deprecation") // Paper's deprecation, we need to support Spigot still
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ public void reload() {

@Override
public int schedule(long delay, long period, Runnable task) {
return Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay, period);
io.papermc.paper.threadedregions.scheduler.ScheduledTask scheduledTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, task1 -> task.run(), delay, period);
return scheduledTask.getExecutionState() == io.papermc.paper.threadedregions.scheduler.ScheduledTask.ExecutionState.CANCELLED ? -1 : scheduledTask.hashCode();
//return Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay, period);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void onDisable() {
if (config != null) {
config.unload();
}
this.getServer().getScheduler().cancelTasks(this);
cancelTasks();
worldEdit.getExecutorService().shutdown();
}

Expand Down Expand Up @@ -575,4 +575,9 @@ public void onAsyncTabComplete(com.destroystokyo.paper.event.server.AsyncTabComp
event.setHandled(true);
}
}

private void cancelTasks() {
this.getServer().getAsyncScheduler().cancelTasks(this);
this.getServer().getGlobalRegionScheduler().cancelTasks(this);
}
}
5 changes: 3 additions & 2 deletions worldedit-bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: WorldEdit
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
version: "${internalVersion}"
version: "${internalVersion}-Folia"
load: STARTUP
api-version: 1.13
softdepend: [Vault]
author: EngineHub
website: https://enginehub.org/worldedit
website: https://enginehub.org/worldedit
folia-supported: true

0 comments on commit d94cbe7

Please sign in to comment.