use EntitySpecificScheduler instead of runSync()

This commit is contained in:
adabugra
2024-08-04 18:23:02 +03:00
parent 85e075c9b3
commit 0f972187a0
4 changed files with 9 additions and 10 deletions

View File

@@ -65,7 +65,7 @@ public class ClaimInvCommand implements CommandExecutor {
if (target instanceof Player play
&& play.getOpenInventory().getTopInventory().getHolder() instanceof Pane pane) {
pane.cancel();
plugin.runSync(play::closeInventory);
AuxProtectSpigot.getMorePaperLib().scheduling().entitySpecificScheduler(play).run(play::closeInventory, null);
break out;
}
sender.sendMessage(L.COMMAND__CLAIMINV__OTHERHASNONE.translate());

View File

@@ -41,7 +41,6 @@ import org.bukkit.inventory.ItemStack;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -53,7 +52,7 @@ public class InvCommand extends Command {
}
public static void openSync(IAuxProtect plugin, Player player, Inventory inventory) {
plugin.runSync(() -> player.openInventory(inventory));
AuxProtectSpigot.getMorePaperLib().scheduling().entitySpecificScheduler(player).run(() -> player.openInventory(inventory), null);
}
public static Inventory makeInventory(IAuxProtect plugin_, Player player, OfflinePlayer target,
@@ -84,7 +83,7 @@ public class InvCommand extends Command {
}
if (closed.get()) return;
closed.set(true);
plugin.runSync(player::closeInventory);
AuxProtectSpigot.getMorePaperLib().scheduling().entitySpecificScheduler(player).run(player::closeInventory, null);
player.sendMessage(L.COMMAND__LOOKUP__LOOKING.translate());
try {
update(plugin, player, when);
@@ -96,7 +95,7 @@ public class InvCommand extends Command {
player.sendMessage(L.ERROR.translate());
return;
}
plugin.runSync(() -> {
AuxProtectSpigot.getMorePaperLib().scheduling().entitySpecificScheduler(player).run(() -> {
PlayerInventoryRecord inv_;
inv_ = InvDiffManager.listToPlayerInv(Arrays.asList(mainInv.getContents()), inv.exp());
@@ -114,8 +113,8 @@ public class InvCommand extends Command {
targetO.sendMessage(L.COMMAND__INV__NOTIFY_PLAYER.translate(player.getName(), TimeUtil.millisToString(System.currentTimeMillis() - when)));
targetO.playSound(targetO.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1, 1);
plugin.add(new DbEntry(AuxProtectSpigot.getLabel(player), EntryAction.RECOVER, false, player.getLocation(), AuxProtectSpigot.getLabel(target), "force"));
});
}, null);
}), L.INV_RECOVER_MENU__BUTTON__FORCE__LABEL.translate(), L.INV_RECOVER_MENU__BUTTON__FORCE__HOVER.translateList());
} else {
pane.addButton(49, Material.GRAY_STAINED_GLASS_PANE, null,
@@ -124,7 +123,7 @@ public class InvCommand extends Command {
pane.addButton(50, Material.GREEN_STAINED_GLASS_PANE, () -> plugin.runAsync(() -> {
if (closed.get()) return;
closed.set(true);
plugin.runSync(player::closeInventory);
AuxProtectSpigot.getMorePaperLib().scheduling().entitySpecificScheduler(player).run(player::closeInventory, null);
ItemStack[] output = new ItemStack[45];
for (int i = 0; i < output.length; i++) {
output[i] = mainInv.getItem(i);

View File

@@ -5,6 +5,7 @@ import dev.heliosares.auxprotect.core.*;
import dev.heliosares.auxprotect.database.EntryAction;
import dev.heliosares.auxprotect.database.InvDiffManager.DiffInventoryRecord;
import dev.heliosares.auxprotect.exceptions.*;
import dev.heliosares.auxprotect.spigot.AuxProtectSpigot;
import dev.heliosares.auxprotect.utils.TimeUtil;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@@ -105,7 +106,7 @@ public class InventoryCommand extends Command {
TimeUtil.millisToString(System.currentTimeMillis() - inv.basetime()),
inv.basetime() + "e", inv.numdiff()));
plugin.runSync(() -> player.openInventory(output));
AuxProtectSpigot.getMorePaperLib().scheduling().entitySpecificScheduler(player).run(() -> player.openInventory(output), null);
}
@Override

View File

@@ -26,7 +26,7 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotati.NotNull;
import space.arim.morepaperlib.MorePaperLib;
import javax.annotation.Nullable;
@@ -669,7 +669,6 @@ public final class AuxProtectSpigot extends JavaPlugin implements IAuxProtect {
@Override
public void runSync(Runnable run) {
AuxProtectSpigot.getMorePaperLib().scheduling().globalRegionalScheduler().run((run));
}
public int queueSize() {