From f4808846531d732df485ff638b162851c289b1bc Mon Sep 17 00:00:00 2001 From: HSGamer Date: Fri, 18 Aug 2023 17:26:16 +0700 Subject: [PATCH] Misc, PlayerListener & SQLDatabaseManager --- .../gmail/nossr50/database/SQLDatabaseManager.java | 6 +++--- .../com/gmail/nossr50/listeners/PlayerListener.java | 12 +++++------- src/main/java/com/gmail/nossr50/util/Misc.java | 3 +-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 111b5d7f5..fd18015bb 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -18,12 +18,12 @@ import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.sql.*; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; public final class SQLDatabaseManager implements DatabaseManager { @@ -1356,7 +1356,7 @@ public final class SQLDatabaseManager implements DatabaseManager { statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD `uuid` varchar(36) NULL DEFAULT NULL"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD UNIQUE INDEX `uuid` (`uuid`) USING BTREE"); - new GetUUIDUpdatesRequired().runTaskLaterAsynchronously(mcMMO.p, 100); // wait until after first purge + mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new GetUUIDUpdatesRequired(), 100 * Misc.TICK_MS_CONVERSION_FACTOR, TimeUnit.MILLISECONDS); // wait until after first purge } mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); @@ -1369,7 +1369,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } } - private class GetUUIDUpdatesRequired extends BukkitRunnable { + private class GetUUIDUpdatesRequired implements Runnable { public void run() { massUpdateLock.lock(); List names = new ArrayList<>(); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 116fbf85f..261f01718 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -49,9 +49,9 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.*; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; import java.util.Locale; +import java.util.concurrent.TimeUnit; public class PlayerListener implements Listener { private final mcMMO plugin; @@ -149,12 +149,10 @@ public class PlayerListener implements Listener { new MobHealthDisplayUpdaterTask(attacker).run(); // set the name back - new BukkitRunnable() { - @Override - public void run() { - MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p); - } - }.runTaskLater(mcMMO.p, 1); + mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(attacker, + () -> MobHealthbarUtils.handleMobHealthbars(attacker, 0, mcMMO.p), + Misc.TICK_MS_CONVERSION_FACTOR, TimeUnit.MILLISECONDS + ); } /** diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index adaecc8f9..cc6d28289 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -12,7 +12,6 @@ import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -327,7 +326,7 @@ public final class Misc { experienceOrb.setExperience(experienceValue); } - private static class SpawnOrbTask extends BukkitRunnable { + private static class SpawnOrbTask implements Runnable { private final Location location; private int orbExpValue;