Fix non-converted schedulers

This commit is contained in:
TechnicallyCoded 2023-08-14 11:47:11 +02:00
parent 34fefc1e70
commit 38e0810f93
No known key found for this signature in database
GPG Key ID: 258C4DBC0BF4AF73
6 changed files with 22 additions and 15 deletions

View File

@ -189,6 +189,10 @@
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.metrics.bstats</shadedPattern> <shadedPattern>com.gmail.nossr50.mcmmo.metrics.bstats</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.folialib</shadedPattern>
</relocation>
</relocations> </relocations>
</configuration> </configuration>
<executions> <executions>
@ -379,7 +383,7 @@
<dependency> <dependency>
<groupId>com.tcoded</groupId> <groupId>com.tcoded</groupId>
<artifactId>FoliaLib</artifactId> <artifactId>FoliaLib</artifactId>
<version>0.2.0</version> <version>0.2.4</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -136,14 +136,15 @@ public class BlockListener implements Listener {
final BlockFace direction = event.getDirection(); final BlockFace direction = event.getDirection();
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
for (final Block block : event.getBlocks()) { for (final Block block : event.getBlocks()) {
final Block movedBlock = block.getRelative(direction); mcMMO.p.getFoliaLib().getImpl().runAtLocation(block.getLocation(), () -> {
final Block movedBlock = block.getRelative(direction);
if(BlockUtils.isWithinWorldBounds(movedBlock)) { if (BlockUtils.isWithinWorldBounds(movedBlock)) {
BlockUtils.setUnnaturalBlock(movedBlock); BlockUtils.setUnnaturalBlock(movedBlock);
} }
}}); });
}
} }
/** /**

View File

@ -54,6 +54,7 @@ import com.gmail.nossr50.util.skills.SmeltingTracker;
import com.gmail.nossr50.util.upgrade.UpgradeManager; import com.gmail.nossr50.util.upgrade.UpgradeManager;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.tcoded.folialib.FoliaLib; import com.tcoded.folialib.FoliaLib;
import com.tcoded.folialib.impl.ServerImplementation;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.shatteredlands.shatt.backup.ZipLibrary; import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
@ -400,7 +401,7 @@ public class mcMMO extends JavaPlugin {
} }
LogUtils.debug(mcMMO.p.getLogger(), "Canceling all tasks..."); 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..."); LogUtils.debug(mcMMO.p.getLogger(), "Unregister all events...");
HandlerList.unregisterAll(this); // Cancel event registrations HandlerList.unregisterAll(this); // Cancel event registrations
@ -630,11 +631,11 @@ public class mcMMO extends JavaPlugin {
} }
private void registerCustomRecipes() { private void registerCustomRecipes() {
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { getFoliaLib().getImpl().runLater(() -> {
if (generalConfig.getChimaeraEnabled()) { if (generalConfig.getChimaeraEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe()); getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
} }
}, 40); }, 40 * 50, TimeUnit.MILLISECONDS);
} }
private void scheduleTasks() { private void scheduleTasks() {
@ -647,7 +648,7 @@ public class mcMMO extends JavaPlugin {
new SaveTimerTask().runTaskTimer(saveIntervalTicks, saveIntervalTicks); new SaveTimerTask().runTaskTimer(saveIntervalTicks, saveIntervalTicks);
// Cleanup the backups folder // Cleanup the backups folder
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p); getFoliaLib().getImpl().runAsync(new CleanBackupsTask());
// Old & Powerless User remover // Old & Powerless User remover
long purgeIntervalTicks = generalConfig.getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; long purgeIntervalTicks = generalConfig.getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;

View File

@ -7,7 +7,7 @@ import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
import com.gmail.nossr50.util.LogUtils; import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.tcoded.folialib.wrapper.WrappedTask; import com.tcoded.folialib.wrapper.task.WrappedTask;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;

View File

@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.concurrent.TimeUnit;
public class NotificationManager { public class NotificationManager {
@ -296,7 +297,7 @@ public class NotificationManager {
String localeMessage = LocaleLoader.getString("Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level, mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType)); String localeMessage = LocaleLoader.getString("Broadcasts.LevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), level, mcMMO.p.getSkillTools().getLocalizedSkillName(primarySkillType));
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover); Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0); mcMMO.p.getFoliaLib().getImpl().runNextTick(() -> audience.sendMessage(Identity.nil(), message));
} }
} }
} }
@ -331,7 +332,7 @@ public class NotificationManager {
String localeMessage = LocaleLoader.getString("Broadcasts.PowerLevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), powerLevel); String localeMessage = LocaleLoader.getString("Broadcasts.PowerLevelUpMilestone", mmoPlayer.getPlayer().getDisplayName(), powerLevel);
Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover); Component message = LegacyComponentSerializer.legacySection().deserialize(localeMessage).hoverEvent(levelMilestoneHover);
Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> audience.sendMessage(Identity.nil(), message), 0); mcMMO.p.getFoliaLib().getImpl().runNextTick(() -> audience.sendMessage(Identity.nil(), message));
} }
} }
} }

View File

@ -18,7 +18,7 @@ import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType; import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
import com.gmail.nossr50.util.skills.SkillTools; import com.gmail.nossr50.util.skills.SkillTools;
import com.tcoded.folialib.wrapper.WrappedTask; import com.tcoded.folialib.wrapper.task.WrappedTask;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;