diff --git a/Changelog.txt b/Changelog.txt
index a978b22455..eb779a4f18 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,3 +1,7 @@
+Version 2.1.223
+ Folia Support added (Thanks to HSGamer, TechnicallyCoded, Rockyers, and Yomamaeatstoes)
+
+ NOTES: This update brings mcMMO to Folia, not all features are guaranteed to work but from limited testing it appears to be working well.
Version 2.1.222
Fixed dupe exploit
Glow Lichen default XP changed from 200 to 5
diff --git a/README.md b/README.md
index 64ac625162..9b1d9e046c 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,12 @@ In December 2018, the original author and creator of mcMMO (nossr50) returned an
#### Classic Maintainer
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)
+#### Folia Inquisitors
+[](https://github.com/HSGamer)
+[](https://github.com/TechnicallyCoded)
+[](https://github.com/Yomamaeatstoes)
+[](https://github.com/Rockyers)
+
## Former Team Members
### Former Lead & Awesome guy
diff --git a/pom.xml b/pom.xml
index b1ff21b22e..82174ac73e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.1.222
+ 2.1.223
mcMMO
https://github.com/mcMMO-Dev/mcMMO
@@ -154,6 +154,7 @@
net.kyori:adventure-text-serializer-craftbukkit
net.kyori:adventure-text-serializer-gson-legacy-impl
co.aikar:acf-bukkit
+ com.tcoded:FoliaLib
@@ -189,6 +190,10 @@
org.bstats
com.gmail.nossr50.mcmmo.metrics.bstats
+
+ com.tcoded.folialib
+ com.gmail.nossr50.mcmmo.folialib
+
@@ -245,6 +250,10 @@
placeholderapi
https://repo.extendedclip.com/content/repositories/placeholderapi/
+
+ devmart-other
+ https://nexuslite.gcnt.net/repos/other/
+
@@ -310,7 +319,7 @@
org.spigotmc
spigot-api
- 1.19.2-R0.1-SNAPSHOT
+ 1.20.1-R0.1-SNAPSHOT
provided
@@ -372,5 +381,11 @@
32.1.1-jre
compile
+
+ com.tcoded
+ FoliaLib
+ 0.3.0
+ compile
+
diff --git a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java
index 8642bc9225..571f1ae350 100644
--- a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java
@@ -64,10 +64,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
mcMMO.getDatabaseManager().saveUser(profile);
}
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
- new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAsync(new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()));
return true;
}
return false;
diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java
index cf5fce21c3..9263ebca5d 100644
--- a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java
@@ -36,10 +36,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
UserManager.saveAll();
UserManager.clearAll();
- new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runLater(new FormulaConversionTask(sender, newType), 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
return true;
diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java
index c892fa7e0e..48276c723c 100644
--- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java
@@ -250,7 +250,7 @@ protected static void handleTeleportWarmup(Player teleportingPlayer, Player targ
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
- new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(teleportingPlayer, new TeleportationWarmup(mcMMOPlayer, mcMMOTarget), 20 * warmup);
}
else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java
index 080be4e08a..dcfcdcdbeb 100644
--- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java
@@ -111,7 +111,7 @@ private void display(CommandSender sender, String playerName) {
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
- new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAsync(new McrankCommandAsyncTask(playerName, sender, useBoard, useChat));
}
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {
diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java
index aaf660bc12..86b1757e9b 100644
--- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java
@@ -115,7 +115,7 @@ private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
- new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAsync(new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat));
}
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {
diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
index 111b5d7f5d..0be013e7e4 100644
--- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
+++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
@@ -18,7 +18,6 @@
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;
@@ -1356,7 +1355,7 @@ private void checkUpgradeAddUUIDs(final Statement statement) {
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); // wait until after first purge
}
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
@@ -1369,7 +1368,7 @@ private void checkUpgradeAddUUIDs(final Statement statement) {
}
}
- 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/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java
index 69245f0806..e96cd56685 100644
--- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java
+++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java
@@ -951,7 +951,7 @@ public void checkAbilityActivation(PrimarySkillType primarySkillType) {
}
setToolPreparationMode(tool, false);
- new AbilityDisableTask(this, superAbilityType).runTaskLater(mcMMO.p, (long) ticks * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new AbilityDisableTask(this, superAbilityType), (long) ticks * Misc.TICK_CONVERSION_FACTOR);
}
public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
@@ -1013,7 +1013,7 @@ public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType)
}
setToolPreparationMode(tool, true);
- new ToolLowerTask(this, tool).runTaskLater(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ToolLowerTask(this, tool), 4 * Misc.TICK_CONVERSION_FACTOR);
}
}
diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java
index 432e96e651..387172c6da 100644
--- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java
+++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java
@@ -102,16 +102,16 @@ public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid, Map {
for (final Block block : event.getBlocks()) {
- final Block movedBlock = block.getRelative(direction);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocation(block.getLocation(), t -> {
+ final Block movedBlock = block.getRelative(direction);
- if(BlockUtils.isWithinWorldBounds(movedBlock)) {
- BlockUtils.setUnnaturalBlock(movedBlock);
- }
- }});
+ if (BlockUtils.isWithinWorldBounds(movedBlock)) {
+ BlockUtils.setUnnaturalBlock(movedBlock);
+ }
+ });
+ }
}
/**
diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
index 50df709e8d..34eaa21131 100644
--- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
@@ -242,7 +242,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
entity.setMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, MetadataConstants.MCMMO_METADATA_VALUE);
TravelingBlockMetaCleanup metaCleanupTask = new TravelingBlockMetaCleanup(entity, pluginRef);
- metaCleanupTask.runTaskTimer(pluginRef, 20, 20*60); //6000 ticks is 5 minutes
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(entity, metaCleanupTask, 20, 20*60); //6000 ticks is 5 minutes
}
else if (isTracked) {
BlockUtils.setUnnaturalBlock(block);
diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
index 6be0eb3574..4467ff723d 100644
--- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
@@ -439,7 +439,7 @@ public void onCraftItem(CraftItemEvent event) {
return;
}
- new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(whoClicked, new PlayerUpdateInventoryTask((Player) whoClicked));
}
}
diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
index 116fbf85f1..a63b7650ea 100644
--- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
@@ -49,7 +49,6 @@
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Locale;
@@ -149,12 +148,7 @@ else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDama
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), 1);
}
/**
@@ -595,7 +589,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
//Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60);
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 60);
if (mcMMO.p.getGeneralConfig().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java
index d8553f80e1..4c24930c62 100644
--- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java
@@ -2,7 +2,6 @@
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.mcMMO;
-import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
@@ -30,7 +29,8 @@ public void onStructureGrow(StructureGrowEvent event) {
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;
- Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
+ // Using 50 ms later as I do not know of a way to run one tick later (safely)
+ plugin.getFoliaLib().getImpl().runLater(() -> {
for (BlockState blockState : event.getBlocks()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java
index 04f93e96c0..bba793be64 100644
--- a/src/main/java/com/gmail/nossr50/mcMMO.java
+++ b/src/main/java/com/gmail/nossr50/mcMMO.java
@@ -54,6 +54,7 @@
import com.gmail.nossr50.util.skills.SmeltingTracker;
import com.gmail.nossr50.util.upgrade.UpgradeManager;
import com.gmail.nossr50.worldguard.WorldGuardManager;
+import com.tcoded.folialib.FoliaLib;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bstats.bukkit.Metrics;
@@ -140,6 +141,18 @@ public class mcMMO extends JavaPlugin {
private GeneralConfig generalConfig;
private AdvancedConfig advancedConfig;
+ private FoliaLib foliaLib;
+
+// private RepairConfig repairConfig;
+// private SalvageConfig salvageConfig;
+// private PersistentDataConfig persistentDataConfig;
+// private ChatConfig chatConfig;
+// private CoreSkillsConfig coreSkillsConfig;
+// private RankConfig rankConfig;
+// private TreasureConfig treasureConfig;
+// private FishingTreasureConfig fishingTreasureConfig;
+// private SoundConfig soundConfig;
+
private CommandOnLevelUpConfig commandOnLevelUpConfig;
public mcMMO() {
@@ -162,6 +175,9 @@ public void onEnable() {
//Filter out any debug messages (if debug/verbose logging is not enabled)
getLogger().setFilter(new LogFilter(this));
+ //Folia lib plugin instance
+ foliaLib = new FoliaLib(this);
+
setupFilePaths();
generalConfig = new GeneralConfig(getDataFolder()); //Load before skillTools
skillTools = new SkillTools(this); //Load after general config
@@ -226,18 +242,21 @@ public void onEnable() {
if(serverAPIOutdated)
{
- Bukkit
- .getScheduler()
- .scheduleSyncRepeatingTask(this,
+ foliaLib
+ .getImpl()
+ .runTimer(
() -> getLogger().severe("You are running an outdated version of "+platformManager.getServerSoftware()+", mcMMO will not work unless you update to a newer version!"),
- 20, 20*60*30);
+ 20, 20*60*30
+ );
if(platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT)
{
- Bukkit.getScheduler()
- .scheduleSyncRepeatingTask(this,
+ foliaLib
+ .getImpl()
+ .runTimer(
() -> getLogger().severe("We have detected you are using incompatible server software, our best guess is that you are using CraftBukkit. mcMMO requires Spigot or Paper, if you are not using CraftBukkit, you will still need to update your custom server software before mcMMO will work."),
- 20, 20*60*30);
+ 20, 20*60*30
+ );
}
} else {
registerEvents();
@@ -249,7 +268,7 @@ public void onEnable() {
formulaManager = new FormulaManager();
for (Player player : getServer().getOnlinePlayers()) {
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
LogUtils.debug(mcMMO.p.getLogger(), "Version " + getDescription().getVersion() + " is enabled!");
@@ -388,7 +407,7 @@ public void onDisable() {
}
LogUtils.debug(mcMMO.p.getLogger(), "Canceling all tasks...");
- getServer().getScheduler().cancelTasks(this); // This removes our tasks
+ getFoliaLib().getImpl().cancelAllTasks(); // This removes our tasks
LogUtils.debug(mcMMO.p.getLogger(), "Unregister all events...");
HandlerList.unregisterAll(this); // Cancel event registrations
@@ -618,7 +637,7 @@ private void registerCoreSkills() {
}
private void registerCustomRecipes() {
- getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
+ getFoliaLib().getImpl().runLater(() -> {
if (generalConfig.getChimaeraEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
}
@@ -632,42 +651,42 @@ private void scheduleTasks() {
long saveIntervalTicks = Math.max(minute, generalConfig.getSaveInterval() * minute);
- new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
+ getFoliaLib().getImpl().runTimer(new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks);
// Cleanup the backups folder
- new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
+ getFoliaLib().getImpl().runAsync(new CleanBackupsTask());
// Old & Powerless User remover
long purgeIntervalTicks = generalConfig.getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (purgeIntervalTicks == 0) {
- new UserPurgeTask().runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
+ getFoliaLib().getImpl().runLaterAsync(new UserPurgeTask(), 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
}
else if (purgeIntervalTicks > 0) {
- new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks);
+ getFoliaLib().getImpl().runTimerAsync(new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
}
// Automatically remove old members from parties
long kickIntervalTicks = generalConfig.getAutoPartyKickInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (kickIntervalTicks == 0) {
- new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
+ getFoliaLib().getImpl().runLater(new PartyAutoKickTask(), 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
}
else if (kickIntervalTicks > 0) {
- new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
+ getFoliaLib().getImpl().runTimer(new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks);
}
// Update power level tag scoreboards
- new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
+ getFoliaLib().getImpl().runTimer(new PowerLevelUpdatingTask(), 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
// Clear the registered XP data so players can earn XP again
if (ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
- new ClearRegisteredXPGainTask().runTaskTimer(this, 60, 60);
+ getFoliaLib().getImpl().runTimer(new ClearRegisteredXPGainTask(), 60, 60);
}
if(mcMMO.p.getAdvancedConfig().allowPlayerTips())
{
- new NotifySquelchReminderTask().runTaskTimer(this, 60, ((20 * 60) * 60));
+ getFoliaLib().getImpl().runTimer(new NotifySquelchReminderTask(), 60, ((20 * 60) * 60));
}
}
@@ -768,6 +787,10 @@ public long getPurgeTime() {
return advancedConfig;
}
+ public @NotNull FoliaLib getFoliaLib() {
+ return foliaLib;
+ }
+
public @NotNull CommandOnLevelUpConfig getCommandOnLevelUpConfig() {
return commandOnLevelUpConfig;
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
index 9f52ed5bfd..e52cb2c25b 100644
--- a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
@@ -3,9 +3,9 @@
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.runnables.skills.AprilTask;
//import com.gmail.nossr50.util.Misc;
-//import org.bukkit.scheduler.BukkitRunnable;
+//import com.gmail.nossr50.util.CancellableRunnable;
//
-//public class CheckDateTask extends BukkitRunnable {
+//public class CheckDateTask extends CancellableRunnable {
//
// @Override
// public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java b/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java
index 43e2a2e4b3..8087d3c658 100644
--- a/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.entity.Mob;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class MobDodgeMetaCleanup extends BukkitRunnable {
+public class MobDodgeMetaCleanup extends CancellableRunnable {
private final @NotNull Mob mob;
private final @NotNull mcMMO pluginRef;
diff --git a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java
index a48375727b..8e59fcb5bc 100644
--- a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java
@@ -1,11 +1,11 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.entity.LivingEntity;
-import org.bukkit.scheduler.BukkitRunnable;
-public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
+public class MobHealthDisplayUpdaterTask extends CancellableRunnable {
private final LivingEntity target;
public MobHealthDisplayUpdaterTask(LivingEntity target) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java
index 1dc0d4ea61..d4e69c5bcf 100644
--- a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java
@@ -2,14 +2,14 @@
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
-public class PistonTrackerTask extends BukkitRunnable {
+public class PistonTrackerTask extends CancellableRunnable {
private final List blocks;
private final BlockFace direction;
private final Block futureEmptyBlock;
diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java
index d42eb6b2f8..e109cce985 100644
--- a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java
@@ -4,11 +4,11 @@
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.player.UserManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class SaveTimerTask extends BukkitRunnable {
+public class SaveTimerTask extends CancellableRunnable {
@Override
public void run() {
LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving...");
@@ -16,7 +16,7 @@ public void run() {
int count = 1;
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
- new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count);
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false), count);
count++;
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java
index 40e21b71ba..d8f52ae306 100644
--- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java
@@ -2,11 +2,11 @@
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
-import org.bukkit.scheduler.BukkitRunnable;
-public class StickyPistonTrackerTask extends BukkitRunnable {
+public class StickyPistonTrackerTask extends CancellableRunnable {
private final BlockFace direction;
private final Block block;
private final Block movedBlock;
diff --git a/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java b/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java
index 2b4dc57ae9..366fb29679 100644
--- a/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.entity.Entity;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class TravelingBlockMetaCleanup extends BukkitRunnable {
+public class TravelingBlockMetaCleanup extends CancellableRunnable {
private final @NotNull Entity entity;
private final @NotNull mcMMO pluginRef;
diff --git a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java
index e907059965..c4de1183d0 100644
--- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java
@@ -1,8 +1,8 @@
package com.gmail.nossr50.runnables.backups;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.LogUtils;
-import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.text.ParseException;
@@ -10,7 +10,7 @@
import java.util.*;
import java.util.concurrent.TimeUnit;
-public class CleanBackupsTask extends BukkitRunnable {
+public class CleanBackupsTask extends CancellableRunnable {
private static final String BACKUP_DIRECTORY = mcMMO.getMainDirectory() + "backup" + File.separator;
private static final File BACKUP_DIR = new File(BACKUP_DIRECTORY);
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java
index a5d02c1dcd..2a9243b0c1 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java
@@ -1,10 +1,10 @@
package com.gmail.nossr50.runnables.commands;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class McScoreboardKeepTask extends BukkitRunnable {
+public class McScoreboardKeepTask extends CancellableRunnable {
private final Player player;
public McScoreboardKeepTask(Player player) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java
index 7311b50bfc..2897b43885 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java
@@ -2,14 +2,14 @@
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map;
-public class McrankCommandAsyncTask extends BukkitRunnable {
+public class McrankCommandAsyncTask extends CancellableRunnable {
private final String playerName;
private final CommandSender sender;
private final boolean useBoard, useChat;
@@ -32,7 +32,7 @@ public McrankCommandAsyncTask(String playerName, CommandSender sender, boolean u
public void run() {
Map skills = mcMMO.getDatabaseManager().readRank(playerName);
- new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat));
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java
index 76a68345df..c1067ecf10 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java
@@ -3,19 +3,19 @@
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.SkillTools;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map;
/**
* Display the results of McrankCommandAsyncTask to the sender.
*/
-public class McrankCommandDisplayTask extends BukkitRunnable {
+public class McrankCommandDisplayTask extends CancellableRunnable {
private final Map skills;
private final CommandSender sender;
private final String playerName;
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java
index 387175cf75..a343bc8107 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java
@@ -3,14 +3,14 @@
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
-public class MctopCommandAsyncTask extends BukkitRunnable {
+public class MctopCommandAsyncTask extends CancellableRunnable {
private final CommandSender sender;
private final PrimarySkillType skill;
private final int page;
@@ -35,6 +35,6 @@ public MctopCommandAsyncTask(int page, PrimarySkillType skill, CommandSender sen
public void run() {
final List userStats = mcMMO.getDatabaseManager().readLeaderboard(skill, page, 10);
- new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat));
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java
index f105faa424..ed1a2f73cb 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java
@@ -4,19 +4,19 @@
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
/**
* Display the results of {@link MctopCommandAsyncTask} to the sender.
*/
-public class MctopCommandDisplayTask extends BukkitRunnable {
+public class MctopCommandDisplayTask extends CancellableRunnable {
private final List userStats;
private final CommandSender sender;
private final PrimarySkillType skill;
diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java
index 4d7b11fc64..9b9fcd6fec 100644
--- a/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.locale.LocaleLoader;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class NotifySquelchReminderTask extends BukkitRunnable {
+public class NotifySquelchReminderTask extends CancellableRunnable {
@Override
public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java
index 0089ee677b..4e59a01fb3 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java
@@ -3,10 +3,10 @@
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.command.CommandSender;
-import org.bukkit.scheduler.BukkitRunnable;
-public class DatabaseConversionTask extends BukkitRunnable {
+public class DatabaseConversionTask extends CancellableRunnable {
private final DatabaseManager sourceDatabase;
private final CommandSender sender;
private final String message;
@@ -21,6 +21,6 @@ public DatabaseConversionTask(DatabaseManager sourceDatabase, CommandSender send
public void run() {
sourceDatabase.convertUsers(mcMMO.getDatabaseManager());
- mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, () -> sender.sendMessage(message));
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> sender.sendMessage(message));
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java
index 2fe1d180a6..68adf8e7f1 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java
@@ -8,14 +8,14 @@
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillTools;
import org.bukkit.command.CommandSender;
-import org.bukkit.scheduler.BukkitRunnable;
-public class FormulaConversionTask extends BukkitRunnable {
+public class FormulaConversionTask extends CancellableRunnable {
private final CommandSender sender;
private final FormulaType formulaType;
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java
index fe7a029a73..44b7cf36f8 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java
@@ -2,6 +2,7 @@
import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.Misc;
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
@@ -20,7 +21,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
-public class UUIDUpdateAsyncTask implements Runnable {
+public class UUIDUpdateAsyncTask extends CancellableRunnable {
private static final Gson GSON = new Gson();
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
@@ -109,11 +110,11 @@ public void run() {
// Bukkit runnables don't let themselves reschedule themselves, so we are a pseudo bukkit runnable.
private void runTaskLaterAsynchronously(mcMMO plugin, int delay) {
- plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, this, delay);
+ plugin.getFoliaLib().getImpl().runLaterAsync(this, delay);
}
public void start() {
- plugin.getServer().getScheduler().runTaskAsynchronously(plugin, this);
+ plugin.getFoliaLib().getImpl().runAsync(this);
}
private static UUID toUUID(String id) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java
index cf570e3f2f..ab2b4cbea8 100644
--- a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java
@@ -1,11 +1,11 @@
package com.gmail.nossr50.runnables.database;
import com.gmail.nossr50.mcMMO;
-import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.util.CancellableRunnable;
import java.util.concurrent.locks.ReentrantLock;
-public class UserPurgeTask extends BukkitRunnable {
+public class UserPurgeTask extends CancellableRunnable {
private final ReentrantLock lock = new ReentrantLock();
@Override
public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java
index c7409b3ce0..bb0996b500 100644
--- a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java
@@ -3,6 +3,7 @@
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
@@ -10,9 +11,8 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ChimaeraWingWarmup extends BukkitRunnable {
+public class ChimaeraWingWarmup extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java
index 49ce24aad3..52d245227b 100644
--- a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java
+++ b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java
@@ -4,6 +4,7 @@
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@@ -11,9 +12,8 @@
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class TeleportationWarmup extends BukkitRunnable {
+public class TeleportationWarmup extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final McMMOPlayer mcMMOTarget;
diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java
index f66b003b64..18891155ca 100644
--- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java
@@ -3,8 +3,8 @@
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.OfflinePlayer;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -12,7 +12,7 @@
import java.util.Map.Entry;
import java.util.UUID;
-public class PartyAutoKickTask extends BukkitRunnable {
+public class PartyAutoKickTask extends CancellableRunnable {
private final static long KICK_TIME = 24L * 60L * 60L * 1000L * mcMMO.p.getGeneralConfig().getAutoPartyKickTime();
@Override
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java b/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java
index 2c281ee887..47923c7a43 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java
@@ -1,10 +1,10 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.UserManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ClearRegisteredXPGainTask extends BukkitRunnable {
+public class ClearRegisteredXPGainTask extends CancellableRunnable {
@Override
public void run() {
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java
index 986882bb85..6cd865055f 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java
@@ -5,6 +5,7 @@
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc;
@@ -12,9 +13,8 @@
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.Server;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class PlayerProfileLoadingTask extends BukkitRunnable {
+public class PlayerProfileLoadingTask extends CancellableRunnable {
private final Player player;
private int attempt = 0;
@@ -52,7 +52,7 @@ public void run() {
// If successful, schedule the apply
if (profile.isLoaded()) {
- new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, new ApplySuccessfulProfile(new McMMOPlayer(player, profile)));
EventUtils.callPlayerProfileLoadEvent(player, profile);
return;
}
@@ -74,10 +74,10 @@ public void run() {
// Increment attempt counter and try
attempt++;
- new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100L)));
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player, attempt), (100 + (attempt * 100L)));
}
- private class ApplySuccessfulProfile extends BukkitRunnable {
+ private class ApplySuccessfulProfile extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private ApplySuccessfulProfile(McMMOPlayer mcMMOPlayer) {
@@ -104,7 +104,7 @@ public void run() {
if (mcMMO.p.getGeneralConfig().getShowStatsAfterLogin()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
- new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new McScoreboardKeepTask(player), Misc.TICK_CONVERSION_FACTOR);
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java
index 2a6d30c69e..9868c3898c 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java
@@ -1,9 +1,9 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
-import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.util.CancellableRunnable;
-public class PlayerProfileSaveTask extends BukkitRunnable {
+public class PlayerProfileSaveTask extends CancellableRunnable {
private final PlayerProfile playerProfile;
private final boolean isSync;
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java
index cdfb17d881..d5361e7ce0 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java
@@ -1,10 +1,10 @@
package com.gmail.nossr50.runnables.player;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
@SuppressWarnings("deprecation")
-public class PlayerUpdateInventoryTask extends BukkitRunnable {
+public class PlayerUpdateInventoryTask extends CancellableRunnable {
private final Player player;
public PlayerUpdateInventoryTask(Player player) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java
index 3f50bce892..da72172610 100644
--- a/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java
@@ -1,9 +1,9 @@
package com.gmail.nossr50.runnables.player;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class PowerLevelUpdatingTask extends BukkitRunnable {
+public class PowerLevelUpdatingTask extends CancellableRunnable {
@Override
public void run() {
if (!ScoreboardManager.powerLevelHeartbeat()) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java
index 56c772a842..69e080972e 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java
@@ -3,10 +3,10 @@
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.NotificationManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AbilityCooldownTask extends BukkitRunnable {
+public class AbilityCooldownTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final SuperAbilityType ability;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java
index 7265b386b1..a789171e0f 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java
@@ -4,6 +4,7 @@
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.NotificationManager;
@@ -12,9 +13,8 @@
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AbilityDisableTask extends BukkitRunnable {
+public class AbilityDisableTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final SuperAbilityType ability;
@@ -63,7 +63,7 @@ public void run() {
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
}
if(!mcMMO.isServerShutdownExecuted()) {
- new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, (long) PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new AbilityCooldownTask(mcMMOPlayer, ability), (long) PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
}
}
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java
index e81804ac89..68de298f5e 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java
@@ -2,15 +2,15 @@
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.Location;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Arrays;
-public class AlchemyBrewCheckTask extends BukkitRunnable {
+public class AlchemyBrewCheckTask extends CancellableRunnable {
private final Player player;
private final BrewingStand brewingStand;
private final ItemStack[] oldInventory;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java
index 7a615bd96f..de5ea2adb0 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java
@@ -7,6 +7,7 @@
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@@ -15,9 +16,8 @@
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AlchemyBrewTask extends BukkitRunnable {
+public class AlchemyBrewTask extends CancellableRunnable {
private static final double DEFAULT_BREW_SPEED = 1.0;
private static final int DEFAULT_BREW_TICKS = 400;
@@ -62,7 +62,7 @@ public AlchemyBrewTask(BlockState brewingStand, Player player) {
fuel--;
Alchemy.brewingStandMap.put(location, this);
- this.runTaskTimer(mcMMO.p, 1, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationTimer(location, this, 1, 1);
}
@Override
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java
index 86fd6b819b..9b4aa61a43 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java
@@ -8,9 +8,9 @@
//import org.bukkit.ChatColor;
//import org.bukkit.Statistic;
//import org.bukkit.entity.Player;
-//import org.bukkit.scheduler.BukkitRunnable;
+//import com.gmail.nossr50.util.CancellableRunnable;
//
-//public class AprilTask extends BukkitRunnable {
+//public class AprilTask extends CancellableRunnable {
//
// @Override
// public void run() {
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java
index 02e01ed1e8..6ced4c66a0 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java
@@ -5,10 +5,10 @@
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity;
-import org.bukkit.scheduler.BukkitRunnable;
-public class AwardCombatXpTask extends BukkitRunnable {
+public class AwardCombatXpTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final double baseXp;
private final PrimarySkillType primarySkillType;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java
index 839358afdd..0cb4d3d13f 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java
@@ -15,7 +15,7 @@
//import org.bukkit.entity.Player;
//import org.bukkit.event.entity.EntityDamageEvent;
//import org.bukkit.inventory.ItemStack;
-//import org.bukkit.scheduler.BukkitRunnable;
+//import com.gmail.nossr50.util.CancellableRunnable;
//import org.jetbrains.annotations.NotNull;
//
//import java.util.HashMap;
@@ -23,7 +23,7 @@
//import java.util.Map;
//import java.util.Map.Entry;
//
-//public class BleedTimerTask extends BukkitRunnable {
+//public class BleedTimerTask extends CancellableRunnable {
// private static final @NotNull Map bleedList = new HashMap<>();
// private static boolean isIterating = false;
//
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java
index 31f19fada4..927e9a3f8d 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java
@@ -2,6 +2,7 @@
import com.gmail.nossr50.datatypes.meta.RecentlyReplantedCropMeta;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import org.bukkit.Location;
@@ -14,11 +15,10 @@
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Cocoa;
import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class DelayedCropReplant extends BukkitRunnable {
+public class DelayedCropReplant extends CancellableRunnable {
private final int desiredCropAge;
private final Location cropLocation;
@@ -54,7 +54,7 @@ public void run() {
PlantAnchorType plantAnchorType = PlantAnchorType.NORMAL;
//Remove the metadata marking the block as recently replanted
- new markPlantAsOld(blockBreakEvent.getBlock().getLocation()).runTaskLater(mcMMO.p, 10);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockBreakEvent.getBlock().getLocation(), new markPlantAsOld(blockBreakEvent.getBlock().getLocation()), 10);
if(blockBreakEvent.isCancelled()) {
wasImmaturePlant = true;
@@ -101,7 +101,7 @@ public void run() {
//Play an effect
ParticleEffectUtils.playGreenThumbEffect(cropLocation);
- new PhysicsBlockUpdate(newState.getBlock(), cropFace, plantAnchorType).runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(newState.getLocation(), new PhysicsBlockUpdate(newState.getBlock(), cropFace, plantAnchorType), 1);
}
}
@@ -110,7 +110,7 @@ private enum PlantAnchorType {
COCOA
}
- private static class PhysicsBlockUpdate extends BukkitRunnable {
+ private static class PhysicsBlockUpdate extends CancellableRunnable {
private final Block plantBlock;
private final PlantAnchorType plantAnchorType;
private BlockFace plantFace;
@@ -160,7 +160,7 @@ private void checkPlantIntegrity(@NotNull BlockFace blockFace) {
- private static class markPlantAsOld extends BukkitRunnable {
+ private static class markPlantAsOld extends CancellableRunnable {
private final Location cropLoc;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java
index 3ecc037477..dcc583f023 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java
@@ -2,11 +2,11 @@
import com.gmail.nossr50.datatypes.BlockSnapshot;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
-import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.util.CancellableRunnable;
import java.util.ArrayList;
-public class DelayedHerbalismXPCheckTask extends BukkitRunnable {
+public class DelayedHerbalismXPCheckTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final ArrayList chorusBlocks;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java
index 23e78909c2..34c87b0d40 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java
@@ -2,10 +2,10 @@
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.experience.ExperienceBarManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ExperienceBarHideTask extends BukkitRunnable {
+public class ExperienceBarHideTask extends CancellableRunnable {
public final McMMOPlayer mcMMOPlayer;
public final PrimarySkillType primarySkillType;
public final ExperienceBarManager experienceBarManagerRef;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java
index 102c9b0b7c..e753957e39 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java
@@ -1,9 +1,9 @@
package com.gmail.nossr50.runnables.skills;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.block.BlockState;
-import org.bukkit.scheduler.BukkitRunnable;
-public class HerbalismBlockUpdaterTask extends BukkitRunnable {
+public class HerbalismBlockUpdaterTask extends CancellableRunnable {
private final BlockState blockState;
public HerbalismBlockUpdaterTask(BlockState blockState) {
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java
index 0f652e02cd..39a6c01b4e 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java
@@ -1,11 +1,11 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.skills.fishing.FishingManager;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.FishHook;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class MasterAnglerTask extends BukkitRunnable {
+public class MasterAnglerTask extends CancellableRunnable {
private final @NotNull FishHook fishHook;
private final @NotNull FishingManager fishingManager;
private final int lureLevel;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java
index 4a93893cb6..32ecf72b20 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java
@@ -3,15 +3,15 @@
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.base.Objects;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class RuptureTask extends BukkitRunnable {
+public class RuptureTask extends CancellableRunnable {
public static final int DAMAGE_TICK_INTERVAL = 10;
public static final int ANIMATION_TICK_INTERVAL = 1;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java
index 342f771626..c9b6d87a55 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java
@@ -2,11 +2,11 @@
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.NotificationManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class SkillUnlockNotificationTask extends BukkitRunnable {
+public class SkillUnlockNotificationTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final SubSkillType subSkillType;
private final int rank;
diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java
index ef3cd05610..98f336e848 100644
--- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java
+++ b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java
@@ -4,10 +4,10 @@
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.player.NotificationManager;
-import org.bukkit.scheduler.BukkitRunnable;
-public class ToolLowerTask extends BukkitRunnable {
+public class ToolLowerTask extends CancellableRunnable {
private final McMMOPlayer mcMMOPlayer;
private final ToolType tool;
diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java
index b9c558d1ad..a0758baccb 100644
--- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java
@@ -113,7 +113,7 @@ public double dodgeCheck(Entity attacker, double damage) {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob, mcMMO.p);
- metaCleanupTask.runTaskTimer(mcMMO.p, 20, 20*60); //one minute
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(mob, metaCleanupTask, 20, 20*60); //one minute
}
} else {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java
index 116fe64e66..2a11b0159b 100644
--- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java
+++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java
@@ -259,13 +259,13 @@ else if (from.isSimilar(to)) {
}
public static void scheduleCheck(Player player, BrewingStand brewingStand) {
- new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, new AlchemyBrewCheckTask(player, brewingStand));
}
public static void scheduleUpdate(Inventory inventory) {
for (HumanEntity humanEntity : inventory.getViewers()) {
if (humanEntity instanceof Player) {
- new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(humanEntity, new PlayerUpdateInventoryTask((Player) humanEntity));
}
}
}
diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java
index 29b03457e4..56dd26aaa0 100644
--- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java
@@ -96,7 +96,8 @@ public double daze(Player defender) {
Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
- defender.teleport(dazedLocation);
+// defender.teleport(dazedLocation);
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(defender, dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java
index 8cc97cc290..613ddaf70e 100644
--- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java
+++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java
@@ -1,12 +1,12 @@
package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID;
-public class TrackedEntity extends BukkitRunnable {
+public class TrackedEntity extends CancellableRunnable {
private final LivingEntity livingEntity;
private final UUID id;
private int arrowCount;
@@ -15,7 +15,7 @@ protected TrackedEntity(LivingEntity livingEntity) {
this.livingEntity = livingEntity;
this.id = livingEntity.getUniqueId();
- this.runTaskTimer(mcMMO.p, 12000, 12000);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(livingEntity, this, 12000, 12000);
}
@Override
diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
index 4b3a03432c..7f37679863 100644
--- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
@@ -244,7 +244,7 @@ public void iceFishing(FishHook hook, Block block) {
}
public void masterAngler(@NotNull FishHook hook, int lureLevel) {
- new MasterAnglerTask(hook, this, lureLevel).runTaskLater(mcMMO.p, 0); //We run later to get the lure bonus applied
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(hook, new MasterAnglerTask(hook, this, lureLevel), 1); //We run later to get the lure bonus applied
}
/**
diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java
index 611e692325..e5fb8e0c4f 100644
--- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java
@@ -39,7 +39,6 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -107,12 +106,12 @@ public void processBerryBushHarvesting(@NotNull BlockState blockState) {
}
CheckBushAge checkBushAge = new CheckBushAge(blockState.getBlock(), mmoPlayer, xpReward);
- checkBushAge.runTaskLater(mcMMO.p, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockState.getLocation(), checkBushAge, 1);
}
}
}
- private class CheckBushAge extends BukkitRunnable {
+ private class CheckBushAge extends CancellableRunnable {
@NotNull Block block;
@NotNull McMMOPlayer mmoPlayer;
@@ -311,7 +310,7 @@ private void processHerbalismOnBlocksBroken(BlockBreakEvent blockBreakEvent, Has
DelayedHerbalismXPCheckTask delayedHerbalismXPCheckTask = new DelayedHerbalismXPCheckTask(mmoPlayer, delayedChorusBlocks);
//Large delay because the tree takes a while to break
- delayedHerbalismXPCheckTask.runTaskLater(mcMMO.p, 0); //Calculate Chorus XP + Bonus Drops 1 tick later
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(mmoPlayer.getPlayer(), delayedHerbalismXPCheckTask); //Calculate Chorus XP + Bonus Drops 1 tick later
}
}
@@ -742,7 +741,7 @@ public boolean processShroomThumb(BlockState blockState) {
*/
private void startReplantTask(int desiredCropAge, BlockBreakEvent blockBreakEvent, BlockState cropState, boolean isImmature) {
//Mark the plant as recently replanted to avoid accidental breakage
- new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature).runTaskLater(mcMMO.p, 20 * 2);
+ mcMMO.p.getFoliaLib().getImpl().runAtLocationLater(blockBreakEvent.getBlock().getLocation(), new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature), 2 * Misc.TICK_CONVERSION_FACTOR);
blockBreakEvent.getBlock().setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, true));
}
diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java
index 5b6336149c..030104d4f3 100644
--- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java
@@ -130,7 +130,7 @@ public void remoteDetonation() {
mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
mmoPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false);
- new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mmoPlayer.getPlayer(), new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING), (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
}
/**
diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java
index 5b34fcc34a..af542e6388 100644
--- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java
@@ -95,7 +95,7 @@ public void processRupture(@NotNull LivingEntity target) {
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
- ruptureTask.runTaskTimer(mcMMO.p, 0, 1);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(mmoPlayer.getPlayer(), ruptureTask, 0, 1);
target.setMetadata(MetadataConstants.METADATA_KEY_RUPTURE, ruptureTaskMeta);
// if (mmoPlayer.useChatNotifications()) {
diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java
index 79cd4802bb..8af370b9ea 100644
--- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java
+++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java
@@ -2,13 +2,13 @@
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.Misc;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
-public class TrackedTamingEntity extends BukkitRunnable {
+public class TrackedTamingEntity extends CancellableRunnable {
private final @NotNull LivingEntity livingEntity;
private final @NotNull CallOfTheWildType callOfTheWildType;
private final @NotNull Player player;
@@ -22,7 +22,7 @@ protected TrackedTamingEntity(@NotNull LivingEntity livingEntity, @NotNull CallO
if (tamingCOTWLength > 0) {
int length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;
- this.runTaskLater(mcMMO.p, length);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(livingEntity, this, length);
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/CancellableRunnable.java b/src/main/java/com/gmail/nossr50/util/CancellableRunnable.java
new file mode 100644
index 0000000000..a47cdcda39
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/util/CancellableRunnable.java
@@ -0,0 +1,28 @@
+package com.gmail.nossr50.util;
+
+import com.tcoded.folialib.wrapper.task.WrappedTask;
+
+import java.util.function.Consumer;
+
+public abstract class CancellableRunnable implements Consumer {
+ private boolean cancelled = false;
+
+ public void cancel() {
+ cancelled = true;
+ }
+
+ public abstract void run();
+
+ @Override
+ public void accept(WrappedTask wrappedTask) {
+ // Run the task if it hasn't been cancelled
+ if (!cancelled) {
+ run();
+ }
+
+ // Cancel the task if it has been cancelled after running
+ if (cancelled) {
+ wrappedTask.cancel();
+ }
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java
index 07bace1a5b..e6ea0582cd 100644
--- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java
+++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java
@@ -112,7 +112,7 @@ public static void activationCheck(Player player) {
if (warmup > 0) {
NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup));
- new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(mcMMO.p, 20 * warmup);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ChimaeraWingWarmup(mcMMOPlayer), 20 * warmup);
}
else {
chimaeraExecuteTeleport();
@@ -123,15 +123,18 @@ public static void chimaeraExecuteTeleport() {
Player player = mcMMOPlayer.getPlayer();
if (mcMMO.p.getGeneralConfig().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
- player.teleport(player.getBedSpawnLocation());
+// player.teleport(player.getBedSpawnLocation());
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, player.getBedSpawnLocation());
}
else {
Location spawnLocation = player.getWorld().getSpawnLocation();
if (spawnLocation.getBlock().getType() == Material.AIR) {
- player.teleport(spawnLocation);
+// player.teleport(spawnLocation);
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, spawnLocation);
}
else {
- player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
+// player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(player, player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java
index d5aff8b6bb..14de7a773c 100644
--- a/src/main/java/com/gmail/nossr50/util/EventUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java
@@ -366,7 +366,8 @@ public static void handlePartyTeleportEvent(Player teleportingPlayer, Player tar
return;
}
- teleportingPlayer.teleport(targetPlayer);
+// teleportingPlayer.teleport(targetPlayer);
+ mcMMO.p.getFoliaLib().getImpl().teleportAsync(teleportingPlayer, targetPlayer.getLocation());
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java
index 0e713a2e41..bbd9bb9990 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.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;
@@ -255,7 +254,7 @@ public static void profileCleanup(@NotNull String playerName) {
if (player != null) {
UserManager.remove(player);
- new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
+ mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
}
@@ -326,7 +325,7 @@ public static void spawnExperienceOrb(@NotNull Location location, int experience
experienceOrb.setExperience(experienceValue);
}
- private static class SpawnOrbTask extends BukkitRunnable {
+ private static class SpawnOrbTask implements Runnable {
private final Location location;
private int orbExpValue;
diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java
index 285d889818..d4a660ca1a 100644
--- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java
@@ -81,7 +81,7 @@ else if (!target.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME)) {
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, false));
}
- new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, (long) displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(target, new MobHealthDisplayUpdaterTask(target), (long) displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java
index e77641d322..c4617bd697 100644
--- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java
+++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java
@@ -5,6 +5,7 @@
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask;
+import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.NotificationManager;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
@@ -77,7 +78,7 @@ private void scheduleHideTask(PrimarySkillType primarySkillType, Plugin plugin)
return;
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mcMMOPlayer, primarySkillType);
- experienceBarHideTask.runTaskLater(plugin, 20L * delaySeconds);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mcMMOPlayer.getPlayer(), experienceBarHideTask, (long) delaySeconds * Misc.TICK_CONVERSION_FACTOR);
experienceBarHideTaskHashMap.put(primarySkillType, experienceBarHideTask);
}
diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java
index ac81bc679a..ff895c3a20 100644
--- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java
+++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java
@@ -296,7 +296,7 @@ public static void processLevelUpBroadcasting(@NotNull McMMOPlayer mmoPlayer, @N
String localeMessage = LocaleLoader.getString("Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level, mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
- Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> audience.sendMessage(Identity.nil(), message));
}
}
}
@@ -331,7 +331,7 @@ public static void processPowerLevelUpBroadcasting(@NotNull McMMOPlayer mmoPlaye
String localeMessage = LocaleLoader.getString("Broadcasts.PowerLevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), powerLevel);
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
- Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0);
+ mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> audience.sendMessage(Identity.nil(), message));
}
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java
index e0d3374132..1237ce086c 100644
--- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java
+++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java
@@ -18,12 +18,10 @@
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
import com.gmail.nossr50.util.skills.SkillTools;
+import com.tcoded.folialib.wrapper.task.WrappedTask;
import org.apache.commons.lang.Validate;
-import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-import org.bukkit.scheduler.BukkitTask;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
@@ -86,9 +84,9 @@ private void initBoard() {
}
}
- public BukkitTask updateTask = null;
+ public WrappedTask updateTask = null;
- private class ScoreboardQuickUpdate extends BukkitRunnable {
+ private class ScoreboardQuickUpdate implements Runnable {
@Override
public void run() {
updateSidebar();
@@ -96,9 +94,9 @@ public void run() {
}
}
- public BukkitTask revertTask = null;
+ public WrappedTask revertTask = null;
- private class ScoreboardChangeTask extends BukkitRunnable {
+ private class ScoreboardChangeTask implements Runnable {
@Override
public void run() {
tryRevertBoard();
@@ -106,9 +104,9 @@ public void run() {
}
}
- public BukkitTask cooldownTask = null;
+ public WrappedTask cooldownTask = null;
- private class ScoreboardCooldownTask extends BukkitRunnable {
+ private class ScoreboardCooldownTask implements Runnable {
@Override
public void run() {
// Stop updating if it's no longer something displaying cooldowns
@@ -125,7 +123,7 @@ public void run() {
public void doSidebarUpdateSoon() {
if (updateTask == null) {
// To avoid spamming the scheduler, store the instance and run 2 ticks later
- updateTask = new ScoreboardQuickUpdate().runTaskLater(mcMMO.p, 2L);
+ updateTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ScoreboardQuickUpdate(), 2L);
}
}
@@ -133,7 +131,7 @@ private void startCooldownUpdating() {
if (cooldownTask == null) {
// Repeat every 5 seconds.
// Cancels once all cooldowns are done, using stopCooldownUpdating().
- cooldownTask = new ScoreboardCooldownTask().runTaskTimer(mcMMO.p, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
+ cooldownTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(player, new ScoreboardCooldownTask(), 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR);
}
}
@@ -216,7 +214,7 @@ public void showBoardAndScheduleRevert(int ticks) {
}
player.setScoreboard(scoreboard);
- revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks);
+ revertTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ScoreboardChangeTask(), ticks);
// TODO is there any way to do the time that looks acceptable?
// player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase(Locale.ENGLISH)), ticks / 20F));
@@ -426,7 +424,7 @@ protected void loadObjective(String displayName) {
NotificationManager.sendPlayerInformationChatOnlyPrefixed(player, "Scoreboard.Recovery");
initBoard(); //Start over
- Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> ScoreboardManager.retryLastSkillBoard(player), 0);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, t -> ScoreboardManager.retryLastSkillBoard(player));
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
index ac9cc6388b..5f4c51ac5b 100644
--- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
@@ -23,7 +23,6 @@
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
-import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
@@ -807,7 +806,7 @@ else if (target instanceof Monster)
baseXP *= multiplier;
if (baseXP != 0) {
- new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason).runTaskLater(mcMMO.p, 0);
+ mcMMO.p.getFoliaLib().getImpl().runAtEntity(mcMMOPlayer.getPlayer(), new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason));
}
}
@@ -982,6 +981,6 @@ public static void cleanupArrowMetadata(@NotNull Projectile entity) {
* @param entity the projectile
*/
public static void delayArrowMetaCleanup(@NotNull Projectile entity) {
- Bukkit.getServer().getScheduler().runTaskLater(mcMMO.p, () -> cleanupArrowMetadata(entity), 20*60);
+ mcMMO.p.getFoliaLib().getImpl().runLater(() -> cleanupArrowMetadata(entity), 20*60);
}
}
diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java
index e53ec67d40..ae2f842ad6 100644
--- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java
+++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java
@@ -48,7 +48,7 @@ public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mc
{
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
- skillUnlockNotificationTask.runTaskLater(plugin, (count * 100L));
+ mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mcMMOPlayer.getPlayer(), skillUnlockNotificationTask, (count * 100L));
count++;
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index fec5c78c2b..a8b56712c8 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -16,6 +16,7 @@ website: https://www.mcmmo.org
main: com.gmail.nossr50.mcMMO
softdepend: [WorldGuard, CombatTag, HealthBar, PlaceholderAPI]
load: POSTWORLD
+folia-supported: true
api-version: 1.13
commands: