From 0e4bab24cbc62d77ff35043b553bbc01e3f680bc Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Mon, 27 Mar 2023 23:31:39 -0400 Subject: [PATCH] Get like 70% of the plugin to work --- .../earth2me/essentials/AsyncTeleport.java | 6 +- .../essentials/AsyncTimedTeleport.java | 13 +- .../java/com/earth2me/essentials/Backup.java | 13 +- .../com/earth2me/essentials/Essentials.java | 75 +++- .../essentials/EssentialsBlockListener.java | 2 +- .../essentials/EssentialsEntityListener.java | 2 +- .../essentials/EssentialsPlayerListener.java | 23 +- .../earth2me/essentials/EssentialsTimer.java | 32 +- .../com/earth2me/essentials/IEssentials.java | 35 +- .../java/com/earth2me/essentials/IUser.java | 8 - .../java/com/earth2me/essentials/Jails.java | 22 - .../earth2me/essentials/RandomTeleport.java | 2 +- .../com/earth2me/essentials/Settings.java | 4 +- .../com/earth2me/essentials/Teleport.java | 403 ------------------ .../earth2me/essentials/TimedTeleport.java | 140 ------ .../java/com/earth2me/essentials/User.java | 15 +- .../com/earth2me/essentials/api/IJails.java | 11 - .../commands/Commandbalancetop.java | 2 +- .../essentials/commands/Commandbeezooka.java | 2 +- .../essentials/commands/Commandgc.java | 2 +- .../commands/Commandkittycannon.java | 2 +- .../essentials/commands/Commandseen.java | 2 +- .../essentials/commands/Commandskull.java | 2 +- .../essentials/commands/Commandsudo.java | 2 +- .../essentials/economy/EconomyLayers.java | 2 +- .../textreader/KeywordReplacer.java | 2 +- .../essentials/utils/VersionUtil.java | 10 + Essentials/src/main/resources/plugin.yml | 1 + .../src/main/resources/plugin.yml | 2 +- EssentialsChat/src/main/resources/plugin.yml | 1 + .../discord/EssentialsDiscord.java | 2 +- .../discord/JDADiscordService.java | 2 +- .../InteractionControllerImpl.java | 2 +- .../discord/util/DiscordCommandSender.java | 7 +- .../essentialsx/discord/util/DiscordUtil.java | 6 +- .../src/main/resources/plugin.yml | 1 + .../discordlink/AccountLinkManager.java | 2 +- .../listeners/LinkBukkitListener.java | 2 +- .../src/main/resources/plugin.yml | 1 + EssentialsGeoIP/src/main/resources/plugin.yml | 1 + .../src/main/resources/plugin.yml | 1 + .../spawn/EssentialsSpawnPlayerListener.java | 6 +- EssentialsSpawn/src/main/resources/plugin.yml | 1 + 43 files changed, 155 insertions(+), 717 deletions(-) delete mode 100644 Essentials/src/main/java/com/earth2me/essentials/Teleport.java delete mode 100644 Essentials/src/main/java/com/earth2me/essentials/TimedTeleport.java diff --git a/Essentials/src/main/java/com/earth2me/essentials/AsyncTeleport.java b/Essentials/src/main/java/com/earth2me/essentials/AsyncTeleport.java index 19ab45818..26567ffaa 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/AsyncTeleport.java +++ b/Essentials/src/main/java/com/earth2me/essentials/AsyncTeleport.java @@ -192,8 +192,7 @@ public class AsyncTeleport implements IAsyncTeleport { 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); + 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. @@ -209,8 +208,7 @@ public class AsyncTeleport implements IAsyncTeleport { } } 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); + PaperLib.teleportAsync(teleportee.getBase(), loc, cause); } else { if (ess.getSettings().isTeleportToCenterLocation()) { loc = LocationUtil.getRoundedDestination(loc); diff --git a/Essentials/src/main/java/com/earth2me/essentials/AsyncTimedTeleport.java b/Essentials/src/main/java/com/earth2me/essentials/AsyncTimedTeleport.java index e38ee1625..df3dc6932 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/AsyncTimedTeleport.java +++ b/Essentials/src/main/java/com/earth2me/essentials/AsyncTimedTeleport.java @@ -2,6 +2,7 @@ package com.earth2me.essentials; 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; @@ -30,7 +31,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) { @@ -54,7 +55,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; @@ -141,16 +142,16 @@ public class AsyncTimedTeleport implements Runnable { } } - 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(); if (notifyUser) { teleportOwner.sendMessage(tl("pendingTeleportCancelled")); if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getBase().getUniqueId())) { @@ -158,7 +159,7 @@ public class AsyncTimedTeleport implements Runnable { } } } finally { - timer_task = -1; + timer_task = null; } } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/Backup.java b/Essentials/src/main/java/com/earth2me/essentials/Backup.java index 837170df7..8d2970cd3 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Backup.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Backup.java @@ -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; @@ -18,7 +19,7 @@ public class Backup implements Runnable { private transient final IEssentials ess; private final AtomicBoolean pendingShutdown = new AtomicBoolean(false); private transient boolean running = false; - private transient int taskId = -1; + private transient SchedulingProvider.EssentialsTask task = null; private transient boolean active = false; private transient CompletableFuture taskLock = null; @@ -36,10 +37,10 @@ public class Backup implements Runnable { 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() { @@ -48,7 +49,7 @@ public class Backup implements Runnable { if (interval < 1200) { return; } - taskId = ess.scheduleSyncRepeatingTask(this, interval, interval); + task = ess.scheduleGlobalRepeatingTask(this, interval, interval); running = true; } } @@ -123,7 +124,7 @@ public class Backup implements Runnable { } if (!pendingShutdown.get()) { - ess.scheduleSyncDelayedTask(new BackupEnableSaveTask()); + ess.scheduleGlobalDelayedTask(new BackupEnableSaveTask()); } } }); diff --git a/Essentials/src/main/java/com/earth2me/essentials/Essentials.java b/Essentials/src/main/java/com/earth2me/essentials/Essentials.java index 287446cd3..77b24ca1f 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Essentials.java @@ -65,6 +65,7 @@ import net.ess3.provider.MaterialTagProvider; import net.ess3.provider.PersistentDataProvider; import net.ess3.provider.PotionMetaProvider; import net.ess3.provider.ProviderListener; +import net.ess3.provider.SchedulingProvider; import net.ess3.provider.SerializationProvider; import net.ess3.provider.ServerStateProvider; import net.ess3.provider.SignDataProvider; @@ -77,9 +78,11 @@ import net.ess3.provider.providers.BaseLoggerProvider; import net.ess3.provider.providers.BasePotionDataProvider; import net.ess3.provider.providers.BlockMetaSpawnerItemProvider; import net.ess3.provider.providers.BukkitMaterialTagProvider; +import net.ess3.provider.providers.BukkitSchedulingProvider; import net.ess3.provider.providers.BukkitSpawnerBlockProvider; import net.ess3.provider.providers.FixedHeightWorldInfoProvider; import net.ess3.provider.providers.FlatSpawnEggProvider; +import net.ess3.provider.providers.FoliaSchedulingProvider; import net.ess3.provider.providers.LegacyItemUnbreakableProvider; import net.ess3.provider.providers.LegacyPotionMetaProvider; import net.ess3.provider.providers.LegacySpawnEggProvider; @@ -95,6 +98,7 @@ import net.ess3.provider.providers.PaperSerializationProvider; import net.ess3.provider.providers.PaperServerStateProvider; import net.essentialsx.api.v2.services.BalanceTop; import net.essentialsx.api.v2.services.mail.MailService; +import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; import org.bukkit.block.Block; @@ -104,6 +108,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginIdentifiableCommand; import org.bukkit.command.TabCompleter; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; @@ -120,8 +125,6 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPluginLoader; -import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.scheduler.BukkitTask; import java.io.File; import java.io.IOException; @@ -182,6 +185,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { private transient ItemUnbreakableProvider unbreakableProvider; private transient WorldInfoProvider worldInfoProvider; private transient SignDataProvider signDataProvider; + private transient SchedulingProvider schedulingProvider; private transient Kits kits; private transient RandomTeleport randomTeleport; private transient UpdateChecker updateChecker; @@ -358,6 +362,12 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { confList.add(jails); execTimer.mark("Init(Jails)"); + if (VersionUtil.FOLIA) { + schedulingProvider = new FoliaSchedulingProvider(this); + } else { + schedulingProvider = new BukkitSchedulingProvider(this); + } + EconomyLayers.onEnable(this); //Spawner item provider only uses one but it's here for legacy... @@ -464,7 +474,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { alternativeCommandsHandler = new AlternativeCommandsHandler(this); timer = new EssentialsTimer(this); - scheduleSyncRepeatingTask(timer, 1000, 50); + scheduleGlobalRepeatingTask(timer, 1000, 50); Economy.setEss(this); execTimer.mark("RegHandler"); @@ -881,11 +891,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { } } - @Override - public BukkitScheduler getScheduler() { - return this.getServer().getScheduler(); - } - @Override public IJails getJails() { return jails; @@ -1164,33 +1169,63 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { } @Override - public BukkitTask runTaskAsynchronously(final Runnable run) { - return this.getScheduler().runTaskAsynchronously(this, run); + public void scheduleInitTask(Runnable runnable) { + schedulingProvider.registerInitTask(runnable); } @Override - public BukkitTask runTaskLaterAsynchronously(final Runnable run, final long delay) { - return this.getScheduler().runTaskLaterAsynchronously(this, run, delay); + public void runTaskAsynchronously(final Runnable run) { + schedulingProvider.runAsyncTask(run); } @Override - public BukkitTask runTaskTimerAsynchronously(final Runnable run, final long delay, final long period) { - return this.getScheduler().runTaskTimerAsynchronously(this, run, delay, period); + public void runTaskLaterAsynchronously(final Runnable run, final long delay) { + schedulingProvider.runAsyncTaskLater(run, delay); } @Override - public int scheduleSyncDelayedTask(final Runnable run) { - return this.getScheduler().scheduleSyncDelayedTask(this, run); + public SchedulingProvider.EssentialsTask runTaskTimerAsynchronously(final Runnable run, final long delay, final long period) { + return schedulingProvider.runAsyncTaskRepeating(run, delay, period); } @Override - public int scheduleSyncDelayedTask(final Runnable run, final long delay) { - return this.getScheduler().scheduleSyncDelayedTask(this, run, delay); + public void scheduleEntityDelayedTask(Entity entity, Runnable run) { + schedulingProvider.runEntityTask(entity, run); } @Override - public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period) { - return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period); + public SchedulingProvider.EssentialsTask scheduleEntityDelayedTask(Entity entity, Runnable run, long delay) { + return schedulingProvider.runEntityTask(entity, run, delay); + } + + @Override + public SchedulingProvider.EssentialsTask scheduleEntityRepeatingTask(Entity entity, Runnable run, long delay, long period) { + return schedulingProvider.runEntityTaskRepeating(entity, run, delay, period); + } + + @Override + public void scheduleLocationDelayedTask(Location location, Runnable run) { + schedulingProvider.runLocationalTask(location, run); + } + + @Override + public void scheduleLocationDelayedTask(Location location, Runnable run, long delay) { + schedulingProvider.runLocationalTask(location, run, delay); + } + + @Override + public SchedulingProvider.EssentialsTask scheduleLocationRepeatingTask(Location location, Runnable run, long delay, long period) { + return schedulingProvider.runLocationalTaskRepeating(location, run, delay, period); + } + + @Override + public void scheduleGlobalDelayedTask(Runnable run, long delay) { + schedulingProvider.runGlobalLocationalTask(run, delay); + } + + @Override + public SchedulingProvider.EssentialsTask scheduleGlobalRepeatingTask(Runnable run, long delay, long period) { + return schedulingProvider.runGlobalLocationalTaskRepeating(run, delay, period); } @Override diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java index c0a861ce7..aa4455117 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsBlockListener.java @@ -42,7 +42,7 @@ public class EssentialsBlockListener implements Listener { final User user = ess.getUser(event.getPlayer()); if (user.hasUnlimited(is) && user.getBase().getGameMode() == GameMode.SURVIVAL) { - ess.scheduleSyncDelayedTask(() -> { + ess.scheduleEntityDelayedTask(user.getBase(), () -> { if (is != null && is.getType() != null && !MaterialUtil.isAir(is.getType())) { final ItemStack cloneIs = is.clone(); cloneIs.setAmount(1); diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsEntityListener.java index a1ab286b9..26ca44335 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsEntityListener.java @@ -112,7 +112,7 @@ public class EssentialsEntityListener implements Listener { } } - ess.scheduleSyncDelayedTask(new PowerToolInteractTask()); + ess.scheduleEntityDelayedTask(attacker.getBase(), new PowerToolInteractTask()); event.setCancelled(true); return; diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java index c2dff750f..d18f0d6c9 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java @@ -15,6 +15,7 @@ import io.papermc.lib.PaperLib; import net.ess3.api.IEssentials; import net.ess3.api.events.AfkStatusChangeEvent; import net.ess3.provider.CommandSendListenerProvider; +import net.ess3.provider.SchedulingProvider; import net.ess3.provider.providers.BukkitCommandSendListenerProvider; import net.ess3.provider.providers.PaperCommandSendListenerProvider; import net.essentialsx.api.v2.events.AsyncUserDataLoadEvent; @@ -79,7 +80,7 @@ import static com.earth2me.essentials.I18n.tl; public class EssentialsPlayerListener implements Listener, FakeAccessor { private final transient IEssentials ess; - private final ConcurrentHashMap pendingMotdTasks = new ConcurrentHashMap<>(); + private final ConcurrentHashMap pendingMotdTasks = new ConcurrentHashMap<>(); public EssentialsPlayerListener(final IEssentials parent) { this.ess = parent; @@ -245,9 +246,9 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { public void onPlayerQuit(final PlayerQuitEvent event) { final User user = ess.getUser(event.getPlayer()); - final Integer pendingId = pendingMotdTasks.remove(user.getUUID()); - if (pendingId != null) { - ess.getScheduler().cancelTask(pendingId); + final SchedulingProvider.EssentialsTask pendingTask = pendingMotdTasks.remove(user.getUUID()); + if (pendingTask != null) { + pendingTask.cancel(); } if (hideJoinQuitMessages() || (ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silentquit"))) { @@ -401,7 +402,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { final int motdDelay = ess.getSettings().getMotdDelay() / 50; final DelayMotdTask motdTask = new DelayMotdTask(user); if (motdDelay > 0) { - pendingMotdTasks.put(user.getUUID(), ess.scheduleSyncDelayedTask(motdTask, motdDelay)); + pendingMotdTasks.put(user.getUUID(), ess.scheduleEntityDelayedTask(user.getBase(), motdTask, motdDelay)); } else { motdTask.run(); } @@ -493,7 +494,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { } } - ess.scheduleSyncDelayedTask(new DelayJoinTask()); + ess.scheduleEntityDelayedTask(player, new DelayJoinTask()); } // Makes the compass item ingame always point to the first essentials home. #EasterEgg @@ -579,7 +580,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { final User user = ess.getUser(event.getPlayer()); if (user.hasUnlimited(new ItemStack(event.getBucket()))) { event.getItemStack().setType(event.getBucket()); - ess.scheduleSyncDelayedTask(user.getBase()::updateInventory); + ess.scheduleEntityDelayedTask(user.getBase(), user.getBase()::updateInventory); } } @@ -824,7 +825,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { } } - ess.scheduleSyncDelayedTask(new DelayedClickJumpTask()); + ess.scheduleEntityDelayedTask(user.getBase(), new DelayedClickJumpTask()); } catch (final Exception ex) { if (ess.getSettings().isDebug()) { ess.getLogger().log(Level.WARNING, ex.getMessage(), ex); @@ -855,7 +856,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { } } - ess.scheduleSyncDelayedTask(new PowerToolUseTask()); + ess.scheduleEntityDelayedTask(user.getBase(), new PowerToolUseTask()); } } @@ -916,7 +917,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { } if (refreshPlayer != null) { - ess.scheduleSyncDelayedTask(refreshPlayer::updateInventory, 1); + ess.scheduleEntityDelayedTask(refreshPlayer, refreshPlayer::updateInventory, 1); } } @@ -958,7 +959,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { } if (refreshPlayer != null) { - ess.scheduleSyncDelayedTask(refreshPlayer::updateInventory, 1); + ess.scheduleEntityDelayedTask(refreshPlayer, refreshPlayer::updateInventory, 1); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsTimer.java index fbc96e1d2..edab1924b 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsTimer.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsTimer.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.Set; import java.util.UUID; import java.util.logging.Level; @@ -13,36 +12,19 @@ import java.util.logging.Level; public class EssentialsTimer implements Runnable { private final transient IEssentials ess; private final transient Set onlineUsers = new HashSet<>(); // Field is necessary for hidden users - private final LinkedList history = new LinkedList<>(); - @SuppressWarnings("FieldCanBeLocal") - private final long maxTime = 10 * 1000000; - @SuppressWarnings("FieldCanBeLocal") - private final long tickInterval = 50; - private transient long lastPoll = System.nanoTime(); + private static final long maxTime = 10 * 1000000; private int skip1 = 0; private int skip2 = 0; EssentialsTimer(final IEssentials ess) { this.ess = ess; - history.add(20d); } @Override public void run() { final long startTime = System.nanoTime(); final long currentTime = System.currentTimeMillis(); - long timeSpent = (startTime - lastPoll) / 1000; - if (timeSpent == 0) { - timeSpent = 1; - } - if (history.size() > 10) { - history.remove(); - } - final double tps = tickInterval * 1000000.0 / timeSpent; - if (tps <= 21) { - history.add(tps); - } - lastPoll = startTime; + int count = 0; onlineUsers.clear(); for (final Player player : ess.getOnlinePlayers()) { @@ -99,14 +81,4 @@ public class EssentialsTimer implements Runnable { user.resetInvulnerabilityAfterTeleport(); } } - - public double getAverageTPS() { - double avg = 0; - for (final Double f : history) { - if (f != null) { - avg += f; - } - } - return avg / history.size(); - } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java b/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java index d8916a958..593341583 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/main/java/com/earth2me/essentials/IEssentials.java @@ -15,6 +15,7 @@ import net.ess3.provider.ItemUnbreakableProvider; import net.ess3.provider.KnownCommandsProvider; import net.ess3.provider.MaterialTagProvider; import net.ess3.provider.PersistentDataProvider; +import net.ess3.provider.SchedulingProvider; import net.ess3.provider.SerializationProvider; import net.ess3.provider.ServerStateProvider; import net.ess3.provider.SignDataProvider; @@ -24,15 +25,15 @@ import net.ess3.provider.SyncCommandsProvider; import net.ess3.provider.WorldInfoProvider; import net.essentialsx.api.v2.services.BalanceTop; import net.essentialsx.api.v2.services.mail.MailService; +import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.scheduler.BukkitTask; import java.util.Collection; import java.util.List; @@ -82,8 +83,6 @@ public interface IEssentials extends Plugin { ISettings getSettings(); - BukkitScheduler getScheduler(); - IJails getJails(); IWarps getWarps(); @@ -98,17 +97,33 @@ public interface IEssentials extends Plugin { UpdateChecker getUpdateChecker(); - BukkitTask runTaskAsynchronously(Runnable run); + void runTaskAsynchronously(Runnable run); - BukkitTask runTaskLaterAsynchronously(Runnable run, long delay); + void runTaskLaterAsynchronously(Runnable run, long delay); - BukkitTask runTaskTimerAsynchronously(Runnable run, long delay, long period); + SchedulingProvider.EssentialsTask runTaskTimerAsynchronously(Runnable run, long delay, long period); - int scheduleSyncDelayedTask(Runnable run); + void scheduleEntityDelayedTask(Entity entity, Runnable run); - int scheduleSyncDelayedTask(Runnable run, long delay); + SchedulingProvider.EssentialsTask scheduleEntityDelayedTask(Entity entity, Runnable run, long delay); - int scheduleSyncRepeatingTask(Runnable run, long delay, long period); + SchedulingProvider.EssentialsTask scheduleEntityRepeatingTask(Entity entity, Runnable run, long delay, long period); + + void scheduleLocationDelayedTask(Location location, Runnable run); + + void scheduleLocationDelayedTask(Location location, Runnable run, long delay); + + SchedulingProvider.EssentialsTask scheduleLocationRepeatingTask(Location location, Runnable run, long delay, long period); + + default void scheduleGlobalDelayedTask(Runnable run) { + scheduleGlobalDelayedTask(run, 1); + } + + void scheduleGlobalDelayedTask(Runnable run, long delay); + + SchedulingProvider.EssentialsTask scheduleGlobalRepeatingTask(Runnable run, long delay, long period); + + void scheduleInitTask(Runnable runnable); PermissionsHandler getPermissionsHandler(); diff --git a/Essentials/src/main/java/com/earth2me/essentials/IUser.java b/Essentials/src/main/java/com/earth2me/essentials/IUser.java index 2625b1fc8..46094dd06 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/IUser.java +++ b/Essentials/src/main/java/com/earth2me/essentials/IUser.java @@ -3,7 +3,6 @@ package com.earth2me.essentials; import com.earth2me.essentials.api.IAsyncTeleport; import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.config.entities.CommandCooldown; -import net.ess3.api.ITeleport; import net.ess3.api.MaxMoneyException; import net.ess3.api.events.AfkStatusChangeEvent; import net.essentialsx.api.v2.services.mail.MailMessage; @@ -15,7 +14,6 @@ import org.bukkit.entity.Player; import org.checkerframework.checker.nullness.qual.Nullable; import java.math.BigDecimal; - import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -71,12 +69,6 @@ public interface IUser { @Deprecated boolean hasOutstandingTeleportRequest(); - /** - * @deprecated This API is not asynchronous. Use {@link com.earth2me.essentials.api.IAsyncTeleport IAsyncTeleport} with {@link IUser#getAsyncTeleport()} - */ - @Deprecated - ITeleport getTeleport(); - IAsyncTeleport getAsyncTeleport(); BigDecimal getMoney(); diff --git a/Essentials/src/main/java/com/earth2me/essentials/Jails.java b/Essentials/src/main/java/com/earth2me/essentials/Jails.java index 123d159f3..677389349 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Jails.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Jails.java @@ -140,28 +140,6 @@ public class Jails implements net.ess3.api.IJails { } } - /** - * @deprecated This method does not use asynchronous teleportation. Use {@link Jails#sendToJail(IUser, String, CompletableFuture)} - */ - @SuppressWarnings("deprecation") - @Override - @Deprecated - public void sendToJail(final IUser user, String jail) throws Exception { - if (jail == null || jail.isEmpty()) { - return; - } - - jail = jail.toLowerCase(Locale.ENGLISH); - synchronized (jails) { - if (jails.containsKey(jail)) { - if (user.getBase().isOnline()) { - user.getTeleport().now(getJail(jail), false, TeleportCause.COMMAND); - } - user.setJail(jail); - } - } - } - @Override public void sendToJail(final IUser user, final String jailName, final CompletableFuture future) throws Exception { if (jailName == null || jailName.isEmpty()) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java b/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java index f020a2cca..f58bbef4b 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java +++ b/Essentials/src/main/java/com/earth2me/essentials/RandomTeleport.java @@ -124,7 +124,7 @@ public class RandomTeleport implements IConf { // Prompts caching random valid locations, up to a maximum number of attempts public void cacheRandomLocations(final Location center, final double minRange, final double maxRange) { - ess.getServer().getScheduler().scheduleSyncDelayedTask(ess, () -> { + ess.scheduleLocationDelayedTask(center, () -> { for (int i = 0; i < this.getFindAttempts(); ++i) { calculateRandomLocation(center, minRange, maxRange).thenAccept(location -> { if (isValidRandomLocation(location)) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index c0b1c6182..f0757c79b 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -708,7 +708,7 @@ public class Settings implements net.ess3.api.ISettings { // This is 2 because Settings are reloaded twice in the startup lifecycle if (reloadCount.get() < 2) { - ess.scheduleSyncDelayedTask(() -> _addAlternativeCommand(effectiveAlias, toDisable)); + ess.scheduleGlobalDelayedTask(() -> _addAlternativeCommand(effectiveAlias, toDisable)); } else { _addAlternativeCommand(effectiveAlias, toDisable); } @@ -721,7 +721,7 @@ public class Settings implements net.ess3.api.ISettings { ess.getLogger().log(Level.INFO, "Syncing commands"); } if (reloadCount.get() < 2) { - ess.scheduleSyncDelayedTask(() -> ess.getSyncCommandsProvider().syncCommands()); + ess.scheduleGlobalDelayedTask(() -> ess.getSyncCommandsProvider().syncCommands()); } else { ess.getSyncCommandsProvider().syncCommands(); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/Teleport.java b/Essentials/src/main/java/com/earth2me/essentials/Teleport.java deleted file mode 100644 index 6038b2e35..000000000 --- a/Essentials/src/main/java/com/earth2me/essentials/Teleport.java +++ /dev/null @@ -1,403 +0,0 @@ -package com.earth2me.essentials; - -import com.earth2me.essentials.utils.DateUtil; -import com.earth2me.essentials.utils.LocationUtil; -import io.papermc.lib.PaperLib; -import net.ess3.api.IEssentials; -import net.ess3.api.ITeleport; -import net.ess3.api.IUser; -import net.ess3.api.events.UserWarpEvent; -import net.ess3.api.events.teleport.PreTeleportEvent; -import net.ess3.api.events.teleport.TeleportWarmupEvent; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - -import java.math.BigDecimal; -import java.util.Calendar; -import java.util.GregorianCalendar; - -import static com.earth2me.essentials.I18n.tl; - -/** - * @deprecated This API is not asynchronous. Use {@link com.earth2me.essentials.AsyncTeleport AsyncTeleport} - */ -@Deprecated -public class Teleport implements ITeleport { - private final IUser teleportOwner; - private final IEssentials ess; - private TimedTeleport timedTeleport; - - private TeleportType tpType; - - @Deprecated - public Teleport(final IUser user, final IEssentials ess) { - this.teleportOwner = user; - this.ess = ess; - tpType = TeleportType.NORMAL; - } - - @Deprecated - public void cooldown(final boolean check) throws Exception { - final Calendar time = new GregorianCalendar(); - if (teleportOwner.getLastTeleportTimestamp() > 0) { - // Take the current time, and remove the delay from it. - final double cooldown = ess.getSettings().getTeleportCooldown(); - final Calendar earliestTime = new GregorianCalendar(); - earliestTime.add(Calendar.SECOND, -(int) cooldown); - earliestTime.add(Calendar.MILLISECOND, -(int) ((cooldown * 1000.0) % 1000.0)); - // This value contains the most recent time a teleportPlayer could have been used that would allow another use. - final long earliestLong = earliestTime.getTimeInMillis(); - - // When was the last teleportPlayer used? - final long lastTime = teleportOwner.getLastTeleportTimestamp(); - - if (lastTime > time.getTimeInMillis()) { - // This is to make sure time didn't get messed up on last teleportPlayer use. - // If this happens, let's give the user the benifit of the doubt. - teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis()); - return; - } else if (lastTime > earliestLong - && cooldownApplies()) { - time.setTimeInMillis(lastTime); - time.add(Calendar.SECOND, (int) cooldown); - time.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0)); - throw new Exception(tl("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis()))); - } - } - // if justCheck is set, don't update lastTeleport; we're just checking - if (!check) { - teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis()); - } - } - - @Deprecated - private boolean cooldownApplies() { - boolean applies = true; - final String globalBypassPerm = "essentials.teleport.cooldown.bypass"; - switch (tpType) { - case NORMAL: - applies = !teleportOwner.isAuthorized(globalBypassPerm); - break; - case BACK: - applies = !(teleportOwner.isAuthorized(globalBypassPerm) && - teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass.back")); - break; - case TPA: - applies = !(teleportOwner.isAuthorized(globalBypassPerm) && - teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass.tpa")); - break; - } - return applies; - } - - @Deprecated - private void warnUser(final IUser user, final double delay) { - final Calendar c = new GregorianCalendar(); - c.add(Calendar.SECOND, (int) delay); - c.add(Calendar.MILLISECOND, (int) ((delay * 1000.0) % 1000.0)); - user.sendMessage(tl("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis()))); - } - - //The now function is used when you want to skip tp delay when teleporting someone to a location or player. - @Override - @Deprecated - public void now(final Location loc, final boolean cooldown, final TeleportCause cause) throws Exception { - if (cooldown) { - cooldown(false); - } - final ITarget target = new LocationTarget(loc); - now(teleportOwner, target, cause); - } - - @Override - @Deprecated - public void now(final Player entity, final boolean cooldown, final TeleportCause cause) throws Exception { - if (cooldown) { - cooldown(false); - } - final ITarget target = new PlayerTarget(entity); - now(teleportOwner, target, cause); - teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ())); - } - - @Deprecated - protected void now(final IUser teleportee, final ITarget target, final TeleportCause cause) throws Exception { - cancel(false); - Location loc = target.getLocation(); - - final PreTeleportEvent event = new PreTeleportEvent(teleportee, cause, target); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - - if (teleportee.isAuthorized("essentials.back.onteleport")) { - teleportee.setLastLocation(); - } - - if (!teleportee.getBase().isEmpty()) { - if (!ess.getSettings().isTeleportPassengerDismount()) { - throw new Exception(tl("passengerTeleportFail")); - } - teleportee.getBase().eject(); - } - - if (LocationUtil.isBlockUnsafeForUser(ess, teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) { - if (ess.getSettings().isTeleportSafetyEnabled()) { - if (ess.getSettings().isForceDisableTeleportSafety()) { - PaperLib.teleportAsync(teleportee.getBase(), loc, cause); - } else { - PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause); - } - } else { - throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); - } - } else { - if (ess.getSettings().isForceDisableTeleportSafety()) { - PaperLib.teleportAsync(teleportee.getBase(), loc, cause); - } else { - if (ess.getSettings().isTeleportToCenterLocation()) { - loc = LocationUtil.getRoundedDestination(loc); - } - PaperLib.teleportAsync(teleportee.getBase(), loc, cause); - } - } - } - - //The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player. - //This method is nolonger used internally and will be removed. - @Deprecated - @Override - public void teleport(final Location loc, final Trade chargeFor) throws Exception { - teleport(loc, chargeFor, TeleportCause.PLUGIN); - } - - @Override - @Deprecated - public void teleport(final Location loc, final Trade chargeFor, final TeleportCause cause) throws Exception { - teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause); - } - - //This is used when teleporting to a player - @Override - @Deprecated - public void teleport(final Player entity, final Trade chargeFor, final TeleportCause cause) throws Exception { - final ITarget target = new PlayerTarget(entity); - teleportOwner.sendMessage(tl("teleportToPlayer", entity.getDisplayName())); - teleport(teleportOwner, target, chargeFor, cause); - } - - //This is used when teleporting to stored location - @Override - @Deprecated - public void teleportPlayer(final IUser teleportee, final Location loc, final Trade chargeFor, final TeleportCause cause) throws Exception { - teleport(teleportee, new LocationTarget(loc), chargeFor, cause); - } - - //This is used on /tphere - @Override - @Deprecated - public void teleportPlayer(final IUser teleportee, final Player entity, final Trade chargeFor, final TeleportCause cause) throws Exception { - final ITarget target = new PlayerTarget(entity); - teleport(teleportee, target, chargeFor, cause); - teleportee.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ())); - teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ())); - } - - @Deprecated - private void teleport(final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause) throws Exception { - double delay = ess.getSettings().getTeleportDelay(); - - final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - delay = event.getDelay(); - - Trade cashCharge = chargeFor; - - if (chargeFor != null) { - chargeFor.isAffordableFor(teleportOwner); - - //This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world. - if (!chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO)) { - //By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport. - cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess); - } - } - - cooldown(true); - if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass") || teleportee.isAuthorized("essentials.teleport.timer.bypass")) { - cooldown(false); - now(teleportee, target, cause); - if (cashCharge != null) { - cashCharge.charge(teleportOwner); - } - return; - } - - cancel(false); - warnUser(teleportee, delay); - initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false); - } - - @Deprecated - private void teleportOther(final IUser teleporter, final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause) throws Exception { - double delay = ess.getSettings().getTeleportDelay(); - - final TeleportWarmupEvent event = new TeleportWarmupEvent(teleporter, teleportee, cause, target, delay); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - delay = event.getDelay(); - - Trade cashCharge = chargeFor; - - if (teleporter != null && chargeFor != null) { - chargeFor.isAffordableFor(teleporter); - - //This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world. - if (!chargeFor.getCommandCost(teleporter).equals(BigDecimal.ZERO)) { - //By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport. - cashCharge = new Trade(chargeFor.getCommandCost(teleporter), ess); - } - } - - cooldown(true); - if (delay <= 0 || teleporter == null - || teleporter.isAuthorized("essentials.teleport.timer.bypass") - || teleportOwner.isAuthorized("essentials.teleport.timer.bypass") - || teleportee.isAuthorized("essentials.teleport.timer.bypass")) { - cooldown(false); - now(teleportee, target, cause); - if (teleporter != null && cashCharge != null) { - cashCharge.charge(teleporter); - } - return; - } - - cancel(false); - warnUser(teleportee, delay); - initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false); - } - - //The respawn function is a wrapper used to handle tp fallback, on /jail and /home - @Override - @Deprecated - public void respawn(final Trade chargeFor, final TeleportCause cause) throws Exception { - double delay = ess.getSettings().getTeleportDelay(); - - final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportOwner, cause, null, delay); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - delay = event.getDelay(); - - if (chargeFor != null) { - chargeFor.isAffordableFor(teleportOwner); - } - cooldown(true); - if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")) { - cooldown(false); - respawnNow(teleportOwner, cause); - if (chargeFor != null) { - chargeFor.charge(teleportOwner); - } - return; - } - - cancel(false); - warnUser(teleportOwner, delay); - initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true); - } - - @Deprecated - void respawnNow(final IUser teleportee, final TeleportCause cause) throws Exception { - final Player player = teleportee.getBase(); - final Location bed = player.getBedSpawnLocation(); - if (bed != null) { - now(teleportee, new LocationTarget(bed), cause); - } else { - if (ess.getSettings().isDebug()) { - ess.getLogger().info("Could not find bed spawn, forcing respawn event."); - } - final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false); - ess.getServer().getPluginManager().callEvent(pre); - now(teleportee, new LocationTarget(pre.getRespawnLocation()), cause); - } - } - - //The warp function is a wrapper used to teleportPlayer a player to a /warp - @Override - @Deprecated - public void warp(final IUser teleportee, String warp, final Trade chargeFor, final TeleportCause cause) throws Exception { - final UserWarpEvent event = new UserWarpEvent(teleportee, warp, chargeFor); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - - warp = event.getWarp(); - final Location loc = ess.getWarps().getWarp(warp); - teleportee.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); - if (!teleportee.equals(teleportOwner)) { - teleportOwner.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); - } - teleport(teleportee, new LocationTarget(loc), chargeFor, cause); - } - - //The back function is a wrapper used to teleportPlayer a player /back to their previous location. - @Override - @Deprecated - public void back(final Trade chargeFor) throws Exception { - back(teleportOwner, chargeFor); - } - - //This function is a wrapper over the other back function for cases where another player performs back for them - @Override - @Deprecated - public void back(final IUser teleporter, final Trade chargeFor) throws Exception { - tpType = TeleportType.BACK; - final Location loc = teleportOwner.getLastLocation(); - teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); - teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND); - } - - //This function is used to throw a user back after a jail sentence - @Override - @Deprecated - public void back() throws Exception { - now(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND); - } - - @Deprecated - public void setTpType(final TeleportType tpType) { - this.tpType = tpType; - } - - //If we need to cancelTimer a pending teleportPlayer call this method - @Deprecated - private void cancel(final boolean notifyUser) { - if (timedTeleport != null) { - timedTeleport.cancelTimer(notifyUser); - timedTeleport = null; - } - } - - @Deprecated - private void initTimer(final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) { - timedTeleport = new TimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, chargeFor, cause, respawn); - } - - public enum TeleportType { - TPA, - BACK, - NORMAL - } -} diff --git a/Essentials/src/main/java/com/earth2me/essentials/TimedTeleport.java b/Essentials/src/main/java/com/earth2me/essentials/TimedTeleport.java deleted file mode 100644 index 9e731918b..000000000 --- a/Essentials/src/main/java/com/earth2me/essentials/TimedTeleport.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.earth2me.essentials; - -import net.ess3.api.IEssentials; -import net.ess3.api.IUser; -import org.bukkit.Location; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - -import java.util.UUID; - -import static com.earth2me.essentials.I18n.tl; - -@Deprecated -public class TimedTeleport implements Runnable { - private static final double MOVE_CONSTANT = 0.3; - private final IUser teleportOwner; - private final IEssentials ess; - private final Teleport teleport; - private final UUID timer_teleportee; - private final long timer_started; // time this task was initiated - private final long timer_delay; // how long to delay the teleportPlayer - // note that I initially stored a clone of the location for reference, but... - // when comparing locations, I got incorrect mismatches (rounding errors, looked like) - // so, the X/Y/Z values are stored instead and rounded off - private final long timer_initX; - private final long timer_initY; - private final long timer_initZ; - private final ITarget timer_teleportTarget; - private final boolean timer_respawn; - private final boolean timer_canMove; - private final Trade timer_chargeFor; - private final TeleportCause timer_cause; - private int timer_task; - private double timer_health; - - TimedTeleport(final IUser user, final IEssentials ess, final Teleport teleport, final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) { - this.teleportOwner = user; - this.ess = ess; - this.teleport = teleport; - this.timer_started = System.currentTimeMillis(); - this.timer_delay = delay; - this.timer_health = teleportUser.getBase().getHealth(); - this.timer_initX = Math.round(teleportUser.getBase().getLocation().getX() * MOVE_CONSTANT); - this.timer_initY = Math.round(teleportUser.getBase().getLocation().getY() * MOVE_CONSTANT); - this.timer_initZ = Math.round(teleportUser.getBase().getLocation().getZ() * MOVE_CONSTANT); - this.timer_teleportee = teleportUser.getBase().getUniqueId(); - this.timer_teleportTarget = target; - this.timer_chargeFor = chargeFor; - this.timer_cause = cause; - this.timer_respawn = respawn; - this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move"); - - timer_task = ess.runTaskTimerAsynchronously(this, 20, 20).getTaskId(); - } - - @Override - public void run() { - - if (teleportOwner == null || !teleportOwner.getBase().isOnline() || teleportOwner.getBase().getLocation() == null) { - cancelTimer(false); - return; - } - - final IUser teleportUser = ess.getUser(this.timer_teleportee); - - if (teleportUser == null || !teleportUser.getBase().isOnline()) { - cancelTimer(false); - return; - } - - final Location currLocation = teleportUser.getBase().getLocation(); - if (currLocation == null) { - cancelTimer(false); - return; - } - - if (!timer_canMove && (Math.round(currLocation.getX() * MOVE_CONSTANT) != timer_initX || Math.round(currLocation.getY() * MOVE_CONSTANT) != timer_initY || Math.round(currLocation.getZ() * MOVE_CONSTANT) != timer_initZ || teleportUser.getBase().getHealth() < timer_health)) { - // user moved, cancelTimer teleportPlayer - cancelTimer(true); - return; - } - - class DelayedTeleportTask implements Runnable { - @Override - public void run() { - - timer_health = teleportUser.getBase().getHealth(); // in case user healed, then later gets injured - final long now = System.currentTimeMillis(); - if (now > timer_started + timer_delay) { - try { - teleport.cooldown(false); - } catch (final Exception ex) { - teleportOwner.sendMessage(tl("cooldownWithMessage", ex.getMessage())); - if (teleportOwner != teleportUser) { - teleportUser.sendMessage(tl("cooldownWithMessage", ex.getMessage())); - } - } - try { - cancelTimer(false); - teleportUser.sendMessage(tl("teleportationCommencing")); - - if (timer_chargeFor != null) { - timer_chargeFor.isAffordableFor(teleportOwner); - } - if (timer_respawn) { - teleport.respawnNow(teleportUser, timer_cause); - } else { - teleport.now(teleportUser, timer_teleportTarget, timer_cause); - } - if (timer_chargeFor != null) { - timer_chargeFor.charge(teleportOwner); - } - - } catch (final Exception ex) { - ess.showError(teleportOwner.getSource(), ex, "\\ teleport"); - } - } - } - } - - ess.scheduleSyncDelayedTask(new DelayedTeleportTask()); - } - - //If we need to cancelTimer a pending teleportPlayer call this method - void cancelTimer(final boolean notifyUser) { - if (timer_task == -1) { - return; - } - try { - ess.getServer().getScheduler().cancelTask(timer_task); - if (notifyUser) { - teleportOwner.sendMessage(tl("pendingTeleportCancelled")); - if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getBase().getUniqueId())) { - ess.getUser(timer_teleportee).sendMessage(tl("pendingTeleportCancelled")); - } - } - } finally { - timer_task = -1; - } - } -} diff --git a/Essentials/src/main/java/com/earth2me/essentials/User.java b/Essentials/src/main/java/com/earth2me/essentials/User.java index 4c63fd0be..b624b3097 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/User.java +++ b/Essentials/src/main/java/com/earth2me/essentials/User.java @@ -57,7 +57,6 @@ public class User extends UserData implements Comparable, IMessageRecipien // User modules private final IMessageRecipient messageRecipient; private transient final AsyncTeleport teleport; - private transient final Teleport legacyTeleport; // User command confirmation strings private final Map confirmingPayments = new WeakHashMap<>(); @@ -97,7 +96,6 @@ public class User extends UserData implements Comparable, IMessageRecipien public User(final Player base, final IEssentials ess) { super(base, ess); teleport = new AsyncTeleport(this, ess); - legacyTeleport = new Teleport(this, ess); if (isAfk()) { afkPosition = this.getLocation(); } @@ -550,15 +548,6 @@ public class User extends UserData implements Comparable, IMessageRecipien return teleport; } - /** - * @deprecated This API is not asynchronous. Use {@link User#getAsyncTeleport()} - */ - @Override - @Deprecated - public Teleport getTeleport() { - return legacyTeleport; - } - public long getLastOnlineActivity() { return lastOnlineActivity; } @@ -811,9 +800,7 @@ public class User extends UserData implements Comparable, IMessageRecipien public void updateActivityOnChat(final boolean broadcast) { if (ess.getSettings().cancelAfkOnChat()) { //Chat happens async, make sure we have a sync context - ess.scheduleSyncDelayedTask(() -> { - updateActivity(broadcast, AfkStatusChangeEvent.Cause.CHAT); - }); + ess.scheduleEntityDelayedTask(base, () -> updateActivity(broadcast, AfkStatusChangeEvent.Cause.CHAT)); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/api/IJails.java b/Essentials/src/main/java/com/earth2me/essentials/api/IJails.java index 94947c9c2..f39179e33 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/api/IJails.java +++ b/Essentials/src/main/java/com/earth2me/essentials/api/IJails.java @@ -46,17 +46,6 @@ public interface IJails extends IConf { */ void removeJail(String jail) throws Exception; - /** - * Attempts to send the given user to the given jail - * - * @param user the user to send to jail - * @param jail the jail to send the user to - * @throws Exception if the user is offline or jail does not exist - * @deprecated Use {@link IJails#sendToJail(IUser, String, CompletableFuture)} - */ - @Deprecated - void sendToJail(IUser user, String jail) throws Exception; - /** * Attempts to send the given user to the given jail * diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java index a0846e43d..acdfcfc8c 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbalancetop.java @@ -38,7 +38,7 @@ public class Commandbalancetop extends EssentialsCommand { new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender); }; if (sender.getSender() instanceof BlockCommandSender) { - ess.scheduleSyncDelayedTask(runnable); + ess.scheduleGlobalDelayedTask(runnable); } else { runnable.run(); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbeezooka.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbeezooka.java index bc55ef47d..f06679d73 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbeezooka.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandbeezooka.java @@ -25,7 +25,7 @@ public class Commandbeezooka extends EssentialsCommand { final Entity bee = Mob.BEE.spawn(user.getWorld(), server, user.getBase().getEyeLocation()); bee.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2)); - ess.scheduleSyncDelayedTask(() -> { + ess.scheduleEntityDelayedTask(bee, () -> { final Location loc = bee.getLocation(); bee.remove(); loc.getWorld().createExplosion(loc, 0F); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgc.java index 5f7392cde..4569bcef3 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgc.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgc.java @@ -21,7 +21,7 @@ public class Commandgc extends EssentialsCommand { @Override protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { - final double tps = ess.getTimer().getAverageTPS(); + final double tps = 20d; //TODO final ChatColor color; if (tps >= 18.0) { color = ChatColor.GREEN; diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandkittycannon.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandkittycannon.java index e40234f52..6356fe6d0 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandkittycannon.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandkittycannon.java @@ -42,7 +42,7 @@ public class Commandkittycannon extends EssentialsCommand { @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { final Entity ocelot = Mob.CAT.getType() == null ? spawnOcelot(server, user) : spawnCat(server, user); - ess.scheduleSyncDelayedTask(() -> { + ess.scheduleEntityDelayedTask(ocelot, () -> { final Location loc = ocelot.getLocation(); ocelot.remove(); loc.getWorld().createExplosion(loc, 0F); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java index f6c3e2d00..ba992ba87 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java @@ -59,7 +59,7 @@ public class Commandseen extends EssentialsCommand { return; } } - ess.getScheduler().runTaskAsynchronously(ess, new Runnable() { + ess.runTaskAsynchronously(new Runnable() { @Override public void run() { final User userFromBukkit = ess.getUsers().getUser(args[0]); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java index 4e1065548..dfd79d32d 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java @@ -64,7 +64,7 @@ public class Commandskull extends EssentialsCommand { skullMeta.setDisplayName("§fSkull of " + owner); //noinspection deprecation skullMeta.setOwner(owner); - ess.scheduleSyncDelayedTask(() -> { + ess.scheduleEntityDelayedTask(user.getBase(), () -> { stack.setItemMeta(skullMeta); if (spawn) { Inventories.addItem(user.getBase(), stack); diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsudo.java index df264f4dd..ebdcd7900 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsudo.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsudo.java @@ -55,7 +55,7 @@ public class Commandsudo extends EssentialsLoopCommand { } } - ess.scheduleSyncDelayedTask(new SudoCommandTask()); + ess.scheduleEntityDelayedTask(user.getBase(), new SudoCommandTask()); } } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/economy/EconomyLayers.java b/Essentials/src/main/java/com/earth2me/essentials/economy/EconomyLayers.java index a4184e558..e1ebf5d66 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/economy/EconomyLayers.java +++ b/Essentials/src/main/java/com/earth2me/essentials/economy/EconomyLayers.java @@ -32,7 +32,7 @@ public final class EconomyLayers { } public static void onEnable(final Essentials ess) { - ess.scheduleSyncDelayedTask(() -> { + ess.scheduleInitTask(() -> { serverStarted = true; for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { if (!plugin.isEnabled()) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java index f53d62940..87db4347c 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -341,7 +341,7 @@ public class KeywordReplacer implements IText { } break; case TPS: - replacer = NumberUtil.formatDouble(ess.getTimer().getAverageTPS()); + replacer = NumberUtil.formatDouble(20d); //todo break; case UPTIME: replacer = DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime()); diff --git a/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java b/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java index e61786346..576ffe3a7 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java @@ -42,10 +42,20 @@ public final class VersionUtil { private static final Set supportedVersions = ImmutableSet.of(v1_8_8_R01, v1_9_4_R01, v1_10_2_R01, v1_11_2_R01, v1_12_2_R01, v1_13_2_R01, v1_14_4_R01, v1_15_2_R01, v1_16_5_R01, v1_17_1_R01, v1_18_2_R01, v1_19_4_R01); public static final boolean PRE_FLATTENING = VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01); + public static final boolean FOLIA; private static final Map unsupportedServerClasses; static { + boolean isFolia; + try { + Class.forName("io.papermc.paper.threadedregions.scheduler.AsyncScheduler"); + isFolia = true; + } catch (Throwable ignored) { + isFolia = false; + } + FOLIA = isFolia; + final ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); // Yatopia - Extremely volatile patch set; diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index 3faa7e5bb..79c668edb 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -8,6 +8,7 @@ description: Provides an essential, core set of commands for Bukkit. softdepend: [Vault, LuckPerms] authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Iaccidentally, drtshock, vemacs, SupaHam, mdcfe, JRoy, pop4959] api-version: "1.13" +folia-supported: true commands: afk: description: Marks you as away-from-keyboard. diff --git a/EssentialsAntiBuild/src/main/resources/plugin.yml b/EssentialsAntiBuild/src/main/resources/plugin.yml index f7dac0e89..1558a519c 100644 --- a/EssentialsAntiBuild/src/main/resources/plugin.yml +++ b/EssentialsAntiBuild/src/main/resources/plugin.yml @@ -8,7 +8,7 @@ description: Provides build protection. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Iaccidentally, drtshock, mdcfe] depend: [Essentials] api-version: "1.13" - +folia-supported: true permissions: essentials.exempt.protect: default: false diff --git a/EssentialsChat/src/main/resources/plugin.yml b/EssentialsChat/src/main/resources/plugin.yml index ab1d85c5a..7fa9d802c 100644 --- a/EssentialsChat/src/main/resources/plugin.yml +++ b/EssentialsChat/src/main/resources/plugin.yml @@ -8,6 +8,7 @@ description: Provides chat control features for Essentials. Requires Permission authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy, Iaccidentally, mdcfe, JRoy, triagonal] depend: [Essentials] api-version: 1.13 +folia-supported: true commands: toggleshout: description: Toggles whether you are talking in shout mode diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/EssentialsDiscord.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/EssentialsDiscord.java index ca288a580..a1f47d1ec 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/EssentialsDiscord.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/EssentialsDiscord.java @@ -57,7 +57,7 @@ public class EssentialsDiscord extends JavaPlugin implements IEssentialsModule { jda = new JDADiscordService(this); try { jda.startup(); - ess.scheduleSyncDelayedTask(() -> ((InteractionControllerImpl) jda.getInteractionController()).processBatchRegistration()); + ess.scheduleInitTask(() -> ((InteractionControllerImpl) jda.getInteractionController()).processBatchRegistration()); } catch (Exception e) { getLogger().log(Level.SEVERE, tl("discordErrorLogin", e.getMessage())); if (ess.getSettings().isDebug()) { diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java index 9ce07b6fe..31dbf7946 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java @@ -229,7 +229,7 @@ public class JDADiscordService implements DiscordService, IEssentialsModule { logger.log(Level.WARNING, "Error while loading the achievement/advancement listener. You will not receive achievement/advancement notifications on Discord.", e); } - getPlugin().getEss().scheduleSyncDelayedTask(() -> DiscordUtil.dispatchDiscordMessage(JDADiscordService.this, MessageType.DefaultTypes.SERVER_START, getSettings().getStartMessage(), true, null, null, null)); + getPlugin().getEss().scheduleInitTask(() -> DiscordUtil.dispatchDiscordMessage(JDADiscordService.this, MessageType.DefaultTypes.SERVER_START, getSettings().getStartMessage(), true, null, null, null)); Bukkit.getServicesManager().register(DiscordService.class, this, plugin, ServicePriority.Normal); } diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/interactions/InteractionControllerImpl.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/interactions/InteractionControllerImpl.java index 28bb8c960..0cea35a9f 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/interactions/InteractionControllerImpl.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/interactions/InteractionControllerImpl.java @@ -61,7 +61,7 @@ public class InteractionControllerImpl extends ListenerAdapter implements Intera interactionEvent.reply(tl("noAccessCommand")); return; } - jda.getPlugin().getEss().scheduleSyncDelayedTask(() -> command.onCommand(interactionEvent)); + //jda.getPlugin().getEss().scheduleSyncDelayedTask(() -> command.onCommand(interactionEvent)); //todo } @Override diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordCommandSender.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordCommandSender.java index f8389c9e4..c65f375c6 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordCommandSender.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordCommandSender.java @@ -2,17 +2,16 @@ package net.essentialsx.discord.util; import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.VersionUtil; +import net.ess3.provider.SchedulingProvider; import net.ess3.provider.providers.BukkitSenderProvider; import net.ess3.provider.providers.PaperCommandSender; import net.essentialsx.discord.JDADiscordService; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.scheduler.BukkitTask; public class DiscordCommandSender { private final CommandSender sender; - private BukkitTask task; + private SchedulingProvider.EssentialsTask task; private String responseBuffer = ""; private long lastTime = System.currentTimeMillis(); @@ -23,7 +22,7 @@ public class DiscordCommandSender { }; this.sender = getCustomSender(sender, hook); - task = Bukkit.getScheduler().runTaskTimerAsynchronously(jda.getPlugin(), () -> { + task = jda.getPlugin().getEss().runTaskTimerAsynchronously(() -> { if (!responseBuffer.isEmpty() && System.currentTimeMillis() - lastTime >= 1000) { callback.onMessage(responseBuffer); responseBuffer = ""; diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java index dfe953662..baf4052ff 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java @@ -214,10 +214,6 @@ public final class DiscordUtil { return; } - if (Bukkit.getServer().isPrimaryThread()) { - Bukkit.getPluginManager().callEvent(event); - } else { - Bukkit.getScheduler().runTask(jda.getPlugin(), () -> Bukkit.getPluginManager().callEvent(event)); - } + jda.getPlugin().getEss().scheduleGlobalDelayedTask(() -> Bukkit.getPluginManager().callEvent(event)); } } diff --git a/EssentialsDiscord/src/main/resources/plugin.yml b/EssentialsDiscord/src/main/resources/plugin.yml index fad076db5..93e6c56b8 100644 --- a/EssentialsDiscord/src/main/resources/plugin.yml +++ b/EssentialsDiscord/src/main/resources/plugin.yml @@ -8,6 +8,7 @@ authors: [mdcfe, JRoy, pop4959, Glare] depend: [Essentials] softdepend: [EssentialsChat, PlaceholderAPI] api-version: 1.13 +folia-supported: true commands: discordbroadcast: description: Broadcasts a message to the specified Discord channel. diff --git a/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java b/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java index 10b33d9d5..bc98d4464 100644 --- a/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java +++ b/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java @@ -139,7 +139,7 @@ public class AccountLinkManager implements IEssentialsModule, DiscordLinkService runnable.run(); return; } - ess.getEss().scheduleSyncDelayedTask(runnable); + ess.getEss().scheduleGlobalDelayedTask(runnable); } private void ensureAsync(final Runnable runnable) { diff --git a/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/listeners/LinkBukkitListener.java b/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/listeners/LinkBukkitListener.java index 4ea071ff6..8a1450e2a 100644 --- a/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/listeners/LinkBukkitListener.java +++ b/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/listeners/LinkBukkitListener.java @@ -156,7 +156,7 @@ public class LinkBukkitListener implements Listener { if (Bukkit.isPrimaryThread()) { kickTask.run(); } else { - ess.getEss().scheduleSyncDelayedTask(kickTask); + ess.getEss().scheduleEntityDelayedTask(event.getUser().getBase(), kickTask); } break; } diff --git a/EssentialsDiscordLink/src/main/resources/plugin.yml b/EssentialsDiscordLink/src/main/resources/plugin.yml index 49df5f7f3..aa0568eab 100644 --- a/EssentialsDiscordLink/src/main/resources/plugin.yml +++ b/EssentialsDiscordLink/src/main/resources/plugin.yml @@ -7,6 +7,7 @@ description: EssentialsX Discord addon which allows you link your Minecraft and authors: [JRoy] depend: [EssentialsDiscord] api-version: 1.13 +folia-supported: true commands: link: description: Generates a code to link your Minecraft account to Discord. diff --git a/EssentialsGeoIP/src/main/resources/plugin.yml b/EssentialsGeoIP/src/main/resources/plugin.yml index 2ddee7b12..6a52547ff 100644 --- a/EssentialsGeoIP/src/main/resources/plugin.yml +++ b/EssentialsGeoIP/src/main/resources/plugin.yml @@ -8,3 +8,4 @@ description: Shows the country or city of a user on login and /whois. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, kjiang, pop4959] depend: [Essentials] api-version: 1.13 +folia-supported: true diff --git a/EssentialsProtect/src/main/resources/plugin.yml b/EssentialsProtect/src/main/resources/plugin.yml index 65764be4a..253403326 100644 --- a/EssentialsProtect/src/main/resources/plugin.yml +++ b/EssentialsProtect/src/main/resources/plugin.yml @@ -8,3 +8,4 @@ description: Provides protection for various parts of the world. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, drtshock] softdepend: [Essentials] api-version: 1.13 +folia-supported: true diff --git a/EssentialsSpawn/src/main/java/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/main/java/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index 59d8b4efe..a1d8d72ac 100644 --- a/EssentialsSpawn/src/main/java/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/main/java/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -83,7 +83,7 @@ class EssentialsSpawnPlayerListener implements Listener { final User user = ess.getUser(player); if (ess.getSettings().isUserInSpawnOnJoinGroup(user) && !user.isAuthorized("essentials.spawn-on-join.exempt")) { - ess.scheduleSyncDelayedTask(() -> { + ess.scheduleEntityDelayedTask(player, () -> { final Location spawn = spawns.getSpawn(user.getGroup()); if (spawn == null) { return; @@ -104,10 +104,10 @@ class EssentialsSpawnPlayerListener implements Listener { final User user = ess.getUser(player); if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn())) { - ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L); + ess.scheduleEntityDelayedTask(player, new NewPlayerTeleport(user), 1L); } - ess.scheduleSyncDelayedTask(() -> { + ess.scheduleEntityDelayedTask(player, () -> { if (!user.getBase().isOnline()) { return; } diff --git a/EssentialsSpawn/src/main/resources/plugin.yml b/EssentialsSpawn/src/main/resources/plugin.yml index e0a7b770d..3746812f4 100644 --- a/EssentialsSpawn/src/main/resources/plugin.yml +++ b/EssentialsSpawn/src/main/resources/plugin.yml @@ -8,6 +8,7 @@ description: Provides spawn control commands, utilizing Essentials. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, SupaHam, mdcfe, DoNotSpamPls, JRoy] depend: [Essentials] api-version: 1.13 +folia-supported: true commands: setspawn: description: Sets the spawn point to your current position.