mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Merge pull request #1 from HSGamer/replace-bukkit-schedulers
Finish all
This commit is contained in:
commit
3d2524580e
3
pom.xml
3
pom.xml
@ -154,6 +154,7 @@
|
||||
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
|
||||
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
|
||||
<include>co.aikar:acf-bukkit</include>
|
||||
<include>com.tcoded:FoliaLib</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
@ -383,7 +384,7 @@
|
||||
<dependency>
|
||||
<groupId>com.tcoded</groupId>
|
||||
<artifactId>FoliaLib</artifactId>
|
||||
<version>0.2.4</version>
|
||||
<version>0.3.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -64,10 +64,10 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
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;
|
||||
|
@ -36,10 +36,10 @@ public class ConvertExperienceCommand implements CommandExecutor {
|
||||
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;
|
||||
|
@ -250,7 +250,7 @@ public class PtpCommand implements TabExecutor {
|
||||
|
||||
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);
|
||||
|
@ -111,7 +111,7 @@ public class McrankCommand implements TabExecutor {
|
||||
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) {
|
||||
|
@ -115,7 +115,7 @@ public class MctopCommand implements TabExecutor {
|
||||
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) {
|
||||
|
@ -18,7 +18,6 @@ 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;
|
||||
|
||||
@ -1356,7 +1355,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); // wait until after first purge
|
||||
}
|
||||
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
|
||||
@ -1369,7 +1368,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private class GetUUIDUpdatesRequired extends BukkitRunnable {
|
||||
private class GetUUIDUpdatesRequired implements Runnable {
|
||||
public void run() {
|
||||
massUpdateLock.lock();
|
||||
List<String> names = new ArrayList<>();
|
||||
|
@ -951,7 +951,7 @@ public class McMMOPlayer implements Identified {
|
||||
}
|
||||
|
||||
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 class McMMOPlayer implements Identified {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,16 +102,16 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void scheduleAsyncSave() {
|
||||
new PlayerProfileSaveTask(this, false).runTaskAsynchronously(mcMMO.p);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAsync(new PlayerProfileSaveTask(this, false));
|
||||
}
|
||||
|
||||
public void scheduleAsyncSaveDelay() {
|
||||
new PlayerProfileSaveTask(this, false).runTaskLaterAsynchronously(mcMMO.p, 20);
|
||||
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileSaveTask(this, false), 20);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void scheduleSyncSaveDelay() {
|
||||
new PlayerProfileSaveTask(this, true).runTaskLater(mcMMO.p, 20);
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(new PlayerProfileSaveTask(this, true), 20);
|
||||
}
|
||||
|
||||
public void save(boolean useSync) {
|
||||
@ -138,7 +138,7 @@ public class PlayerProfile {
|
||||
|
||||
//Back out of async saving if we detect a server shutdown, this is not always going to be caught
|
||||
if(mcMMO.isServerShutdownExecuted() || useSync)
|
||||
new PlayerProfileSaveTask(this, true).runTask(mcMMO.p);
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(new PlayerProfileSaveTask(this, true));
|
||||
else
|
||||
scheduleAsyncSave();
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class BlockListener implements Listener {
|
||||
final BlockFace direction = event.getDirection();
|
||||
|
||||
for (final Block block : event.getBlocks()) {
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtLocation(block.getLocation(), () -> {
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtLocation(block.getLocation(), t -> {
|
||||
final Block movedBlock = block.getRelative(direction);
|
||||
|
||||
if (BlockUtils.isWithinWorldBounds(movedBlock)) {
|
||||
|
@ -242,7 +242,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
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);
|
||||
|
@ -439,7 +439,7 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntity(whoClicked, new PlayerUpdateInventoryTask((Player) whoClicked));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ 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;
|
||||
|
||||
@ -149,12 +148,7 @@ 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), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -595,7 +589,7 @@ public class PlayerListener implements Listener {
|
||||
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);
|
||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.listeners;
|
||||
|
||||
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;
|
||||
@ -12,8 +11,6 @@ import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
@ -37,7 +34,7 @@ public class WorldListener implements Listener {
|
||||
for (BlockState blockState : event.getBlocks()) {
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
}, 50, TimeUnit.MILLISECONDS);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,6 @@ 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 com.tcoded.folialib.impl.ServerImplementation;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@ -76,7 +75,6 @@ import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
|
||||
@ -242,7 +240,8 @@ public class mcMMO extends JavaPlugin {
|
||||
.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 * 50L, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
20, 20*60*30
|
||||
);
|
||||
|
||||
if(platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT)
|
||||
{
|
||||
@ -250,7 +249,8 @@ public class mcMMO extends JavaPlugin {
|
||||
.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 * 50L, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
20, 20*60*30
|
||||
);
|
||||
}
|
||||
} else {
|
||||
registerEvents();
|
||||
@ -262,7 +262,7 @@ public class mcMMO extends JavaPlugin {
|
||||
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!");
|
||||
@ -635,7 +635,7 @@ public class mcMMO extends JavaPlugin {
|
||||
if (generalConfig.getChimaeraEnabled()) {
|
||||
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
||||
}
|
||||
}, 40 * 50, TimeUnit.MILLISECONDS);
|
||||
}, 40);
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
@ -645,7 +645,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
long saveIntervalTicks = Math.max(minute, generalConfig.getSaveInterval() * minute);
|
||||
|
||||
new SaveTimerTask().runTaskTimer(saveIntervalTicks, saveIntervalTicks);
|
||||
getFoliaLib().getImpl().runTimer(new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks);
|
||||
|
||||
// Cleanup the backups folder
|
||||
getFoliaLib().getImpl().runAsync(new CleanBackupsTask());
|
||||
@ -654,33 +654,33 @@ public class mcMMO extends JavaPlugin {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -2,14 +2,14 @@ package com.gmail.nossr50.runnables;
|
||||
|
||||
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<Block> blocks;
|
||||
private final BlockFace direction;
|
||||
private final Block futureEmptyBlock;
|
||||
|
@ -4,27 +4,23 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
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.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
public class SaveTimerTask extends CancellableRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving...");
|
||||
// All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
|
||||
public class SaveTimerTask {
|
||||
public WrappedTask runTaskTimer(long delay, long period) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runTimer(() -> {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving...");
|
||||
// All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count);
|
||||
count++;
|
||||
}
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false), count);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
PartyManager.saveParties();
|
||||
}, delay * Misc.TICK_CONVERSION_FACTOR, period * Misc.TICK_CONVERSION_FACTOR, TimeUnit.MILLISECONDS);
|
||||
PartyManager.saveParties();
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ package com.gmail.nossr50.runnables;
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.text.SimpleDateFormat;
|
||||
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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -2,14 +2,14 @@ package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
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 class McrankCommandAsyncTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
Map<PrimarySkillType, Integer> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,19 +3,19 @@ package com.gmail.nossr50.runnables.commands;
|
||||
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<PrimarySkillType, Integer> skills;
|
||||
private final CommandSender sender;
|
||||
private final String playerName;
|
||||
|
@ -3,14 +3,14 @@ package com.gmail.nossr50.runnables.commands;
|
||||
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 class MctopCommandAsyncTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
final List<PlayerStat> 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));
|
||||
}
|
||||
}
|
||||
|
@ -4,19 +4,19 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
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<PlayerStat> userStats;
|
||||
private final CommandSender sender;
|
||||
private final PrimarySkillType skill;
|
||||
|
@ -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() {
|
||||
|
@ -3,10 +3,10 @@ package com.gmail.nossr50.runnables.database;
|
||||
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 class DatabaseConversionTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
sourceDatabase.convertUsers(mcMMO.getDatabaseManager());
|
||||
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(() -> sender.sendMessage(message));
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> sender.sendMessage(message));
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
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;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.database;
|
||||
|
||||
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;
|
||||
@ -18,10 +19,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
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";
|
||||
|
||||
@ -110,7 +110,7 @@ public class UUIDUpdateAsyncTask implements Runnable {
|
||||
|
||||
// Bukkit runnables don't let themselves reschedule themselves, so we are a pseudo bukkit runnable.
|
||||
private void runTaskLaterAsynchronously(mcMMO plugin, int delay) {
|
||||
plugin.getFoliaLib().getImpl().runLaterAsync(this, delay, TimeUnit.MILLISECONDS);
|
||||
plugin.getFoliaLib().getImpl().runLaterAsync(this, delay);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
@ -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() {
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.items;
|
||||
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 com.gmail.nossr50.util.skills.SkillUtils;
|
||||
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) {
|
||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
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 com.gmail.nossr50.util.skills.SkillUtils;
|
||||
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;
|
||||
|
||||
|
@ -3,8 +3,8 @@ package com.gmail.nossr50.runnables.party;
|
||||
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.List;
|
||||
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
|
||||
|
@ -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()) {
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
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.player.UserManager;
|
||||
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 class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
|
||||
// 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 class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
// 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 class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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()) {
|
||||
|
@ -3,10 +3,10 @@ package com.gmail.nossr50.runnables.skills;
|
||||
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;
|
||||
|
||||
|
@ -4,6 +4,7 @@ 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.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 com.gmail.nossr50.util.skills.SkillUtils;
|
||||
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 class AbilityDisableTask extends BukkitRunnable {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,15 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
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;
|
||||
|
@ -7,6 +7,7 @@ import com.gmail.nossr50.events.skills.alchemy.McMMOPlayerCatalysisEvent;
|
||||
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.Material;
|
||||
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 class AlchemyBrewTask extends BukkitRunnable {
|
||||
fuel--;
|
||||
|
||||
Alchemy.brewingStandMap.put(location, this);
|
||||
this.runTaskTimer(mcMMO.p, 1, 1);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtLocationTimer(location, this, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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() {
|
||||
|
@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
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;
|
||||
|
@ -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<LivingEntity, BleedContainer> bleedList = new HashMap<>();
|
||||
// private static boolean isIterating = false;
|
||||
//
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
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.BlockData;
|
||||
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 class DelayedCropReplant extends BukkitRunnable {
|
||||
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 class DelayedCropReplant extends BukkitRunnable {
|
||||
|
||||
//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 @@ public class DelayedCropReplant extends BukkitRunnable {
|
||||
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 @@ public class DelayedCropReplant extends BukkitRunnable {
|
||||
|
||||
|
||||
|
||||
private static class markPlantAsOld extends BukkitRunnable {
|
||||
private static class markPlantAsOld extends CancellableRunnable {
|
||||
|
||||
private final Location cropLoc;
|
||||
|
||||
|
@ -2,11 +2,11 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
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<BlockSnapshot> chorusBlocks;
|
||||
|
@ -2,10 +2,10 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
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;
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -3,15 +3,15 @@ package com.gmail.nossr50.runnables.skills;
|
||||
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;
|
||||
|
@ -2,11 +2,11 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
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;
|
||||
|
@ -4,10 +4,10 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
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;
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
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);
|
||||
|
@ -259,13 +259,13 @@ public final class AlchemyPotionBrewer {
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,8 @@ public class ArcheryManager extends SkillManager {
|
||||
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));
|
||||
|
||||
|
||||
|
@ -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 @@ public class TrackedEntity extends BukkitRunnable {
|
||||
this.livingEntity = livingEntity;
|
||||
this.id = livingEntity.getUniqueId();
|
||||
|
||||
this.runTaskTimer(mcMMO.p, 12000, 12000);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(livingEntity, this, 12000, 12000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -244,7 +244,7 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,6 @@ import org.bukkit.entity.Player;
|
||||
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 class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
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 @@ public class HerbalismManager extends SkillManager {
|
||||
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 class HerbalismManager extends SkillManager {
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class MiningManager extends SkillManager {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ public class SwordsManager extends SkillManager {
|
||||
|
||||
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()) {
|
||||
|
@ -2,13 +2,13 @@ package com.gmail.nossr50.skills.taming;
|
||||
|
||||
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 @@ public class TrackedTamingEntity extends BukkitRunnable {
|
||||
|
||||
if (tamingCOTWLength > 0) {
|
||||
int length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;
|
||||
this.runTaskLater(mcMMO.p, length);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(livingEntity, this, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<WrappedTask> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -112,7 +112,7 @@ public final class ChimaeraWing {
|
||||
|
||||
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 final class ChimaeraWing {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,8 @@ public final class EventUtils {
|
||||
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()));
|
||||
|
@ -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;
|
||||
@ -27,7 +26,6 @@ public final class Misc {
|
||||
|
||||
public static final int TIME_CONVERSION_FACTOR = 1000;
|
||||
public static final int TICK_CONVERSION_FACTOR = 20;
|
||||
public static final int TICK_MS_CONVERSION_FACTOR = 50;
|
||||
|
||||
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
||||
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
||||
@ -256,7 +254,7 @@ public final class Misc {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,7 +325,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;
|
||||
|
||||
|
@ -81,7 +81,7 @@ public final class MobHealthbarUtils {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
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 @@ public class ExperienceBarManager {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class NotificationManager {
|
||||
|
||||
@ -297,7 +296,7 @@ public class NotificationManager {
|
||||
String localeMessage = LocaleLoader.getString("Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level, mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
|
||||
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
|
||||
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(() -> audience.sendMessage(Identity.nil(), message));
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> audience.sendMessage(Identity.nil(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -332,7 +331,7 @@ public class NotificationManager {
|
||||
String localeMessage = LocaleLoader.getString("Broadcasts.PowerLevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), powerLevel);
|
||||
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
|
||||
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(() -> audience.sendMessage(Identity.nil(), message));
|
||||
mcMMO.p.getFoliaLib().getImpl().runNextTick(t -> audience.sendMessage(Identity.nil(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ScoreboardWrapper {
|
||||
public static final String SIDE_OBJECTIVE = "mcMMO_sideObjective";
|
||||
@ -87,38 +86,36 @@ public class ScoreboardWrapper {
|
||||
|
||||
public WrappedTask updateTask = null;
|
||||
|
||||
private class ScoreboardQuickUpdate {
|
||||
public WrappedTask runTaskLater(long delay) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runLater(() -> {
|
||||
updateSidebar();
|
||||
updateTask = null;
|
||||
}, delay * Misc.TICK_CONVERSION_FACTOR, TimeUnit.MILLISECONDS);
|
||||
private class ScoreboardQuickUpdate implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
updateSidebar();
|
||||
updateTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedTask revertTask = null;
|
||||
|
||||
private class ScoreboardChangeTask {
|
||||
public WrappedTask runTaskLater(long delay) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runLater(() -> {
|
||||
tryRevertBoard();
|
||||
revertTask = null;
|
||||
}, delay * Misc.TICK_CONVERSION_FACTOR, TimeUnit.MILLISECONDS);
|
||||
private class ScoreboardChangeTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
tryRevertBoard();
|
||||
revertTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedTask cooldownTask = null;
|
||||
|
||||
private class ScoreboardCooldownTask {
|
||||
public WrappedTask runTaskTimer(long delay, long period) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runTimer(() -> {
|
||||
// Stop updating if it's no longer something displaying cooldowns
|
||||
if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
|
||||
doSidebarUpdateSoon();
|
||||
} else {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
}, delay, period, TimeUnit.MILLISECONDS);
|
||||
private class ScoreboardCooldownTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
// Stop updating if it's no longer something displaying cooldowns
|
||||
if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
|
||||
doSidebarUpdateSoon();
|
||||
}
|
||||
else {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +123,7 @@ public class ScoreboardWrapper {
|
||||
public void doSidebarUpdateSoon() {
|
||||
if (updateTask == null) {
|
||||
// To avoid spamming the scheduler, store the instance and run 2 ticks later
|
||||
updateTask = new ScoreboardQuickUpdate().runTaskLater(2L);
|
||||
updateTask = mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new ScoreboardQuickUpdate(), 2L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +131,7 @@ public class ScoreboardWrapper {
|
||||
if (cooldownTask == null) {
|
||||
// Repeat every 5 seconds.
|
||||
// Cancels once all cooldowns are done, using stopCooldownUpdating().
|
||||
cooldownTask = new ScoreboardCooldownTask().runTaskTimer(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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +214,7 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
player.setScoreboard(scoreboard);
|
||||
revertTask = new ScoreboardChangeTask().runTaskLater(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));
|
||||
@ -427,7 +424,7 @@ public class ScoreboardWrapper {
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(player, "Scoreboard.Recovery");
|
||||
|
||||
initBoard(); //Start over
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(() -> ScoreboardManager.retryLastSkillBoard(player), 0, TimeUnit.MILLISECONDS);
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntity(player, t -> ScoreboardManager.retryLastSkillBoard(player));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
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;
|
||||
@ -40,7 +39,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class CombatUtils {
|
||||
|
||||
@ -808,7 +806,7 @@ public final class CombatUtils {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -983,6 +981,6 @@ public final class CombatUtils {
|
||||
* @param entity the projectile
|
||||
*/
|
||||
public static void delayArrowMetaCleanup(@NotNull Projectile entity) {
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(() -> cleanupArrowMetadata(entity), 1000 * 60, TimeUnit.MILLISECONDS);
|
||||
mcMMO.p.getFoliaLib().getImpl().runLater(() -> cleanupArrowMetadata(entity), 20*60);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class RankUtils {
|
||||
{
|
||||
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
|
||||
|
||||
skillUnlockNotificationTask.runTaskLater(plugin, (count * 100L));
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mcMMOPlayer.getPlayer(), skillUnlockNotificationTask, (count * 100L));
|
||||
|
||||
count++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user