Refactor to use FoliaLib scheduler for "Bukkit.getServer().getScheduler()"

This commit is contained in:
adabugra 2024-12-28 22:32:06 +03:00
parent 827f71f7d5
commit daf83be12a
No known key found for this signature in database
GPG Key ID: 5A1DF9EF3B167AA4
3 changed files with 6 additions and 11 deletions

View File

@ -116,14 +116,10 @@ private void debugSystem(final @NotNull CommandSender commandSender)
ItemStack slot = sender.getInventory().getItem(0);
if(slot == null || slot.getAmount() == 0 || slot.getType() == Material.AIR) sender.getInventory().setItem(0, new ItemStack(Material.ACACIA_BOAT));
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
sender.performCommand("backpack");
}, 5*20L);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
Bukkit.getPluginManager().callEvent(new ClickEvent(sender.getOpenInventory(), InventoryType.SlotType.QUICKBAR, InventoryUtils.getPlayerTopInventory(sender).getSize() + 27, ClickType.LEFT, InventoryAction.PICKUP_ALL));
}, 10*20L);
Bukkit.getServer().getScheduler().runTaskLater(plugin, sender::closeInventory, 20*20L);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
Minepacks.getScheduler().runAtEntityLater(sender, () -> sender.performCommand("backpack"), 5*20L);
Minepacks.getScheduler().runAtEntityLater(sender, () -> Bukkit.getPluginManager().callEvent(new ClickEvent(sender.getOpenInventory(), InventoryType.SlotType.QUICKBAR, InventoryUtils.getPlayerTopInventory(sender).getSize() + 27, ClickType.LEFT, InventoryAction.PICKUP_ALL)), 10*20L);
Minepacks.getScheduler().runAtEntityLater(sender, sender::closeInventory, 20*20L);
Minepacks.getScheduler().runLater(() -> {
try
{
writer.flush();

View File

@ -24,7 +24,6 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import at.pcgamingfreaks.Utils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -172,7 +171,7 @@ protected String replacePlaceholders(@Language("SQL") String query)
protected void runStatementAsync(final String query, final Object... args)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> runStatement(query, args));
Minepacks.getScheduler().runAsync(task -> runStatement(query, args));
}
protected void runStatement(final String query, final Object... args)

View File

@ -262,7 +262,7 @@ private void unload()
HandlerList.unregisterAll(this); // Stop the listeners
if(cooldownManager != null) cooldownManager.close();
cooldownManager = null;
getServer().getScheduler().cancelTasks(this); // Kill all running task
getScheduler().cancelAllTasks(); // Kill all running task
itemFilter = null;
}