From 3f7902639939615c93df2dfbe28c51ec8af79b8c Mon Sep 17 00:00:00 2001 From: Thorge Engelmann <56771258+TeddyBear2004@users.noreply.github.com.> Date: Sat, 25 Oct 2025 20:40:59 +0200 Subject: [PATCH 1/2] Add support for Folia and update scheduler to use AsyncScheduler --- .../simplevanish/handling/ScheduleHandler.java | 16 +++++++++------- src/main/resources/plugin.yml | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/simplexity/simplevanish/handling/ScheduleHandler.java b/src/main/java/simplexity/simplevanish/handling/ScheduleHandler.java index f3f1825..5964d30 100644 --- a/src/main/java/simplexity/simplevanish/handling/ScheduleHandler.java +++ b/src/main/java/simplexity/simplevanish/handling/ScheduleHandler.java @@ -1,17 +1,19 @@ package simplexity.simplevanish.handling; +import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; +import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.scheduler.BukkitTask; import simplexity.simplevanish.SimpleVanish; import simplexity.simplevanish.config.ConfigHandler; import simplexity.simplevanish.config.Message; import simplexity.simplevanish.saving.Cache; +import java.util.concurrent.TimeUnit; + public class ScheduleHandler { - private BukkitTask task; - private final BukkitScheduler scheduler = SimpleVanish.getInstance().getServer().getScheduler(); + private ScheduledTask task; + private final AsyncScheduler scheduler = SimpleVanish.getInstance().getServer().getAsyncScheduler(); private final MiniMessage miniMessage = SimpleVanish.getMiniMessage(); private ScheduleHandler(){} private static ScheduleHandler instance; @@ -22,17 +24,17 @@ public static ScheduleHandler getInstance(){ public void startScheduler(){ if (task != null) task.cancel(); - task = scheduler.runTaskTimer(SimpleVanish.getInstance(), this::displayActionBar, 0L, ConfigHandler.getInstance().getRemindInterval() * 20L); + task = scheduler.runAtFixedRate(SimpleVanish.getInstance(), this::displayActionBar, 0L, ConfigHandler.getInstance().getRemindInterval(), TimeUnit.SECONDS); } public void stopScheduler(){ if (task != null) task.cancel(); } - private void displayActionBar(){ + private void displayActionBar(ScheduledTask scheduledTask){ if (Cache.getVanishedPlayers().isEmpty()) return; for (Player player : Cache.getVanishedPlayers()) { - player.sendActionBar(miniMessage.deserialize(Message.VANISH_REMINDER.getMessage())); + player.getScheduler().run(SimpleVanish.getInstance(), task1 -> player.sendActionBar(miniMessage.deserialize(Message.VANISH_REMINDER.getMessage())), () -> {}); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0e4b0c3..489aa9b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,6 +4,7 @@ main: simplexity.simplevanish.SimpleVanish api-version: '1.21.6' softdepend: - PlaceholderAPI +folia-supported: true permissions: vanish.view: default: op From 0bb0db09bf8471a6910766988b2c94c265e5167a Mon Sep 17 00:00:00 2001 From: Thorge Engelmann <56771258+TeddyBear2004@users.noreply.github.com.> Date: Sat, 25 Oct 2025 20:42:48 +0200 Subject: [PATCH 2/2] Bump version to 2.1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 04849d5..09606ad 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ simplexity SimpleVanish - 2.1.1 + 2.1.2 jar SimpleVanish