diff --git a/common/pom.xml b/common/pom.xml
index 0007a6a9..f4ee3647 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -71,6 +71,10 @@
false
false
+
+ com.tcoded.folialib
+ com.loohp.interactivechat.libs.com.tcoded.folialib
+
net.kyori
com.loohp.interactivechat.libs.net.kyori
@@ -318,6 +322,12 @@
+
+ com.github.technicallycoded
+ FoliaLib
+ 0.4.3
+ compile
+
com.github.Carleslc.Simple-YAML
Simple-Yaml
diff --git a/common/src/main/java/com/loohp/interactivechat/Commands.java b/common/src/main/java/com/loohp/interactivechat/Commands.java
index d86c3bbd..34c6a406 100644
--- a/common/src/main/java/com/loohp/interactivechat/Commands.java
+++ b/common/src/main/java/com/loohp/interactivechat/Commands.java
@@ -87,7 +87,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
ConfigManager.reloadConfig();
InteractiveChat.placeholderCooldownManager.reloadPlaceholders();
PlayerUtils.resetAllPermissionCache();
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> InteractiveChat.playerDataManager.reload());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> InteractiveChat.playerDataManager.reload());
if (InteractiveChat.bungeecordMode) {
try {
BungeeMessageSender.reloadBungeeConfig(System.currentTimeMillis());
@@ -107,7 +107,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (sender.hasPermission("interactivechat.update")) {
sender.sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat written by LOOHP!");
sender.sendMessage(ChatColor.GOLD + "[InteractiveChat] You are running InteractiveChat version: " + InteractiveChat.plugin.getDescription().getVersion());
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> {
UpdaterResponse version = Updater.checkUpdate();
if (version.getResult().equals("latest")) {
if (version.isDevBuildLatest()) {
@@ -133,11 +133,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
PlayerData pd = InteractiveChat.playerDataManager.getPlayerData(player);
if (pd.isMentionDisabled()) {
pd.setMentionDisabled(false);
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> pd.save());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> pd.save());
sender.sendMessage(InteractiveChat.mentionEnable);
} else {
pd.setMentionDisabled(true);
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> pd.save());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> pd.save());
sender.sendMessage(InteractiveChat.mentionDisable);
}
if (InteractiveChat.bungeecordMode) {
@@ -157,11 +157,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
PlayerData pd = InteractiveChat.playerDataManager.getPlayerData(player);
if (pd.isMentionDisabled()) {
pd.setMentionDisabled(false);
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> pd.save());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> pd.save());
sender.sendMessage(InteractiveChat.mentionEnable);
} else {
pd.setMentionDisabled(true);
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> pd.save());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> pd.save());
sender.sendMessage(InteractiveChat.mentionDisable);
}
if (InteractiveChat.bungeecordMode) {
@@ -198,7 +198,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
Player player = (Player) sender;
PlayerData pd = InteractiveChat.playerDataManager.getPlayerData(player);
pd.setInventoryDisplayLayout(layout);
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> pd.save());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> pd.save());
sender.sendMessage(InteractiveChat.setInvDisplayLayout.replace("{Layout}", layout + ""));
if (InteractiveChat.bungeecordMode) {
try {
@@ -220,7 +220,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
PlayerData pd = InteractiveChat.playerDataManager.getPlayerData(player);
pd.setInventoryDisplayLayout(layout);
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> pd.save());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> pd.save());
sender.sendMessage(InteractiveChat.setInvDisplayLayout.replace("{Layout}", layout + ""));
if (InteractiveChat.bungeecordMode) {
try {
@@ -302,7 +302,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
String str = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
Player player = (Player) sender;
Optional icplayer = Optional.of(ICPlayerFactory.getICPlayer(player));
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> {
String text = str;
try {
long unix = System.currentTimeMillis();
@@ -359,7 +359,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (args.length > 1) {
if (sender instanceof Player) {
String message = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runNextTick((task) -> {
((Player) sender).chat(message);
});
} else {
@@ -375,7 +375,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (InteractiveChat.floodgateHook && args[0].equalsIgnoreCase("events")) {
if (sender.hasPermission("interactivechat.bedrock.events")) {
if (sender instanceof Player) {
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> {
UUID uuid = ((Player) sender).getUniqueId();
if (FloodgateHook.isFloodgatePlayer(uuid)) {
FloodgateHook.sendRecentChatMessagesForm(uuid);
@@ -425,7 +425,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (data == null || data.getInventoryDisplayLayout() == 0) {
Inventory inv = InteractiveChat.inventoryDisplay.get(hash);
if (inv != null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> player.openInventory(inv));
+ InteractiveChat.plugin.getScheduler().runAtEntity(player, (task) -> player.openInventory(inv));
} else {
player.sendMessage(PlaceholderAPI.setPlaceholders(player, InteractiveChat.invExpiredMessage));
}
@@ -433,7 +433,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
Inventory inv = InteractiveChat.inventoryDisplay1Upper.get(hash);
Inventory inv2 = InteractiveChat.inventoryDisplay1Lower.get(hash);
if (inv != null && inv2 != null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAtEntity(player, (task) -> {
player.openInventory(inv);
InventoryUtils.sendFakePlayerInventory(player, inv2, true, false);
InteractiveChat.viewingInv1.put(player.getUniqueId(), hash);
@@ -447,7 +447,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
case "viewender": {
Inventory inv = InteractiveChat.enderDisplay.get(args[1]);
if (inv != null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> player.openInventory(inv));
+ InteractiveChat.plugin.getScheduler().runAtEntity(player, (task) -> player.openInventory(inv));
} else {
player.sendMessage(PlaceholderAPI.setPlaceholders(player, InteractiveChat.invExpiredMessage));
}
@@ -456,7 +456,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
case "viewitem": {
Inventory inv = InteractiveChat.itemDisplay.get(args[1]);
if (inv != null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> player.openInventory(inv));
+ InteractiveChat.plugin.getScheduler().runAtEntity(player, (task) -> player.openInventory(inv));
} else {
player.sendMessage(PlaceholderAPI.setPlaceholders(player, InteractiveChat.invExpiredMessage));
}
@@ -465,7 +465,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
case "viewmap":
ItemStack map = InteractiveChat.mapDisplay.get(args[1]);
if (map != null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> MapViewer.showMap(player, map));
+ InteractiveChat.plugin.getScheduler().runAtEntity(player, (task) -> MapViewer.showMap(player, map));
} else {
player.sendMessage(PlaceholderAPI.setPlaceholders(player, InteractiveChat.invExpiredMessage));
}
diff --git a/common/src/main/java/com/loohp/interactivechat/InteractiveChat.java b/common/src/main/java/com/loohp/interactivechat/InteractiveChat.java
index dfd14331..47f0fc67 100644
--- a/common/src/main/java/com/loohp/interactivechat/InteractiveChat.java
+++ b/common/src/main/java/com/loohp/interactivechat/InteractiveChat.java
@@ -20,6 +20,8 @@
package com.loohp.interactivechat;
+import com.tcoded.folialib.FoliaLib;
+import com.tcoded.folialib.impl.PlatformScheduler;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.utility.MinecraftVersion;
@@ -372,13 +374,15 @@ public static void closeSharedInventoryViews() {
public static void closeInventoryViews(Inventory inventory) {
for (Player player : Bukkit.getOnlinePlayers()) {
- Inventory topInventory = player.getOpenInventory().getTopInventory();
- if (topInventory.equals(inventory)) {
- player.closeInventory();
- if (InteractiveChat.viewingInv1.remove(player.getUniqueId()) != null) {
- InventoryUtils.restorePlayerInventory(player);
+ plugin.getScheduler().runAtEntity(player, (task) -> {
+ Inventory topInventory = player.getOpenInventory().getTopInventory();
+ if (topInventory.equals(inventory)) {
+ player.closeInventory();
+ if (InteractiveChat.viewingInv1.remove(player.getUniqueId()) != null) {
+ InventoryUtils.restorePlayerInventory(player);
+ }
}
- }
+ });
}
}
@@ -413,6 +417,9 @@ public static boolean hasChatSigning() {
public ProcessExternalMessage externalProcessor;
+ public FoliaLib foliaLib = new FoliaLib(this);
+ public PlatformScheduler platformScheduler = foliaLib.getScheduler();
+
@Override
public void onEnable() {
plugin = this;
@@ -454,9 +461,9 @@ public void onEnable() {
getServer().getPluginManager().registerEvents(new ServerPingListener(), this);
ServerPingListener.listen();
- Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runTimerAsync((outer) -> {
if (parsePAPIOnMainThread) {
- Bukkit.getScheduler().runTask(plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runNextTick((task) -> {
for (Player player : Bukkit.getOnlinePlayers()) {
PlaceholderParser.parse(ICPlayerFactory.getICPlayer(player), usePlayerNameHoverText);
PlaceholderParser.parse(ICPlayerFactory.getICPlayer(player), usePlayerNameClickValue);
@@ -470,14 +477,14 @@ public void onEnable() {
}
}, 0, 100);
- Bukkit.getScheduler().runTaskTimer(plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runTimer(() -> {
Map vanishStates = new HashMap<>();
for (ICPlayer player : ICPlayerFactory.getOnlineICPlayers()) {
if (player.isLocal()) {
vanishStates.put(player.getUniqueId(), player.isVanished());
}
}
- Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAsync((inner) -> {
try {
BungeeMessageSender.updatePlayersVanished(System.currentTimeMillis(), vanishStates);
} catch (Exception e) {
@@ -488,7 +495,7 @@ public void onEnable() {
}
BiConsumer inventoryRemovalListener = (hash, inv) -> {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> closeInventoryViews(inv));
+ InteractiveChat.plugin.getScheduler().runNextTick((task) -> closeInventoryViews(inv));
};
itemDisplay.registerRemovalListener(inventoryRemovalListener);
inventoryDisplay.registerRemovalListener(inventoryRemovalListener);
@@ -497,7 +504,7 @@ public void onEnable() {
enderDisplay.registerRemovalListener(inventoryRemovalListener);
mapDisplay.registerRemovalListener((hash, item) -> {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runNextTick((task) -> {
for (Player player : Bukkit.getOnlinePlayers()) {
boolean removed = MapViewer.MAP_VIEWERS.remove(player, item);
if (removed) {
@@ -661,7 +668,7 @@ public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[InteractiveChat] InteractiveChat has been Enabled!");
- Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
+ InteractiveChat.plugin.getScheduler().runTimerAsync(() -> {
if (queueRemoteUpdate && Bukkit.getOnlinePlayers().size() > 0) {
try {
if (BungeeMessageSender.resetAndForwardPlaceholderList(System.currentTimeMillis(), InteractiveChat.placeholderList.values())) {
@@ -695,11 +702,12 @@ public void onDisable() {
OutMessagePacket.getAsyncChatSendingExecutor().close();
} catch (Exception ignored) {
}
+ platformScheduler.cancelAllTasks();
getServer().getConsoleSender().sendMessage(ChatColor.RED + "[InteractiveChat] InteractiveChat has been Disabled!");
}
private void gc() {
- Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
+ InteractiveChat.plugin.getScheduler().runTimerAsync(() -> {
itemDisplay.cleanUp();
inventoryDisplay.cleanUp();
inventoryDisplay1Upper.cleanUp();
@@ -709,4 +717,7 @@ private void gc() {
}, 0, 1200);
}
+ public PlatformScheduler getScheduler() {
+ return platformScheduler;
+ }
}
diff --git a/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageListener.java b/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageListener.java
index af581d9b..75a7abd0 100644
--- a/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageListener.java
+++ b/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageListener.java
@@ -88,7 +88,7 @@ public BungeeMessageListener(InteractiveChat instance) {
public void addToComplete(UUID uuid, CompletableFuture> future) {
toComplete.put(uuid, future);
- Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLaterAsync(() -> {
CompletableFuture> f = toComplete.remove(uuid);
if (f != null && !f.isDone() && !f.isCompletedExceptionally() && !f.isCancelled()) {
f.completeExceptionally(new TimeoutException("The proxy did not respond in time"));
@@ -103,7 +103,7 @@ public void onPluginMessageReceived(String channel, Player pluginMessagingPlayer
return;
}
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> {
try {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
@@ -252,7 +252,7 @@ public void onPluginMessageReceived(String channel, Player pluginMessagingPlayer
break;
}
InteractiveChat.messages.put(message, uuid3);
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> InteractiveChat.messages.remove(message), 60);
+ InteractiveChat.plugin.getScheduler().runLater((inner) -> InteractiveChat.messages.remove(message), 60);
break;
case 0x07:
int cooldownType = input.readByte();
@@ -430,7 +430,7 @@ public void onPluginMessageReceived(String channel, Player pluginMessagingPlayer
String command = DataTypeIO.readString(input, StandardCharsets.UTF_8);
Player player4 = Bukkit.getPlayer(playerUUID5);
if (player4 != null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> PlayerUtils.dispatchCommandAsPlayer(player4, command));
+ InteractiveChat.plugin.getScheduler().runNextTick((inner) -> PlayerUtils.dispatchCommandAsPlayer(player4, command));
}
break;
case 0xFF:
diff --git a/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageSender.java b/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageSender.java
index 38c4a722..4212dabb 100644
--- a/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageSender.java
+++ b/common/src/main/java/com/loohp/interactivechat/bungeemessaging/BungeeMessageSender.java
@@ -61,7 +61,7 @@ public class BungeeMessageSender {
protected static short inventoryScheme = 0;
static {
- Bukkit.getScheduler().runTaskTimerAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runTimerAsync((task) -> {
int size = sent.size();
for (int i = size; i > 500; i--) {
sent.remove(sent.firstKey());
diff --git a/common/src/main/java/com/loohp/interactivechat/bungeemessaging/ServerPingListener.java b/common/src/main/java/com/loohp/interactivechat/bungeemessaging/ServerPingListener.java
index 065dcb92..359a0add 100644
--- a/common/src/main/java/com/loohp/interactivechat/bungeemessaging/ServerPingListener.java
+++ b/common/src/main/java/com/loohp/interactivechat/bungeemessaging/ServerPingListener.java
@@ -74,7 +74,7 @@ public void onPacketSending(PacketEvent event) {
}
});
- Bukkit.getScheduler().runTaskTimerAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runTimerAsync((task) -> {
REQUESTS.entrySet().removeIf(entry -> System.currentTimeMillis() > entry.getValue());
}, 0, 20);
}
diff --git a/common/src/main/java/com/loohp/interactivechat/config/ConfigManager.java b/common/src/main/java/com/loohp/interactivechat/config/ConfigManager.java
index 03c4c0ef..6fe12e5f 100644
--- a/common/src/main/java/com/loohp/interactivechat/config/ConfigManager.java
+++ b/common/src/main/java/com/loohp/interactivechat/config/ConfigManager.java
@@ -422,7 +422,7 @@ public static void loadConfig() {
InteractiveChat.language = getConfig().getString("Settings.Language");
- Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> {
LanguageUtils.loadTranslations(InteractiveChat.language);
if (WebData.getInstance() == null) {
WebData.newInstance();
diff --git a/common/src/main/java/com/loohp/interactivechat/data/PlayerDataManager.java b/common/src/main/java/com/loohp/interactivechat/data/PlayerDataManager.java
index f7202ea0..b8812f8c 100644
--- a/common/src/main/java/com/loohp/interactivechat/data/PlayerDataManager.java
+++ b/common/src/main/java/com/loohp/interactivechat/data/PlayerDataManager.java
@@ -69,7 +69,7 @@ public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
UUID playerUUID = player.getUniqueId();
- Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> {
if (!database.playerExists(playerUUID)) {
database.createPlayer(playerUUID, player.getName());
}
@@ -82,7 +82,7 @@ public void onJoin(PlayerJoinEvent event) {
public void onLeave(PlayerQuitEvent event) {
PlayerData pd = data.remove(event.getPlayer().getUniqueId());
if (pd != null) {
- Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> pd.save());
+ InteractiveChat.plugin.getScheduler().runAsync((task) -> pd.save());
}
}
diff --git a/common/src/main/java/com/loohp/interactivechat/hooks/dynmap/DynmapListener.java b/common/src/main/java/com/loohp/interactivechat/hooks/dynmap/DynmapListener.java
index b3f3abd9..3f99e8e9 100644
--- a/common/src/main/java/com/loohp/interactivechat/hooks/dynmap/DynmapListener.java
+++ b/common/src/main/java/com/loohp/interactivechat/hooks/dynmap/DynmapListener.java
@@ -66,7 +66,7 @@ public static void _init_() {
public void onPluginEnable(PluginEnableEvent event) {
if (init) {
if (event.getPlugin().getName().equalsIgnoreCase("dynmap")) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
_init_();
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE + "[InteractiveChat] InteractiveChat has injected into Dynmap!");
}, 100);
diff --git a/common/src/main/java/com/loohp/interactivechat/hooks/eco/EcoHook.java b/common/src/main/java/com/loohp/interactivechat/hooks/eco/EcoHook.java
index 53af192b..53993354 100644
--- a/common/src/main/java/com/loohp/interactivechat/hooks/eco/EcoHook.java
+++ b/common/src/main/java/com/loohp/interactivechat/hooks/eco/EcoHook.java
@@ -67,10 +67,16 @@ public static Future setEcoLore(ItemStack itemStack) {
}
public static Future setEcoLore(ItemStack itemStack, Player player) {
- if (!InteractiveChat.ecoSetLoreOnMainThread || Bukkit.isPrimaryThread()) {
+ InteractiveChat plugin = InteractiveChat.getPlugin(InteractiveChat.class);
+ if (!InteractiveChat.ecoSetLoreOnMainThread || plugin.getScheduler().isGlobalTickThread()) {
return CompletableFuture.completedFuture(setEcoLore0(itemStack.clone(), player));
} else {
- return Bukkit.getScheduler().callSyncMethod(InteractiveChat.plugin, () -> setEcoLore0(itemStack.clone(), player));
+ CompletableFuture future = new CompletableFuture<>();
+ plugin.getScheduler().runAtEntity(player, (task) -> {
+ setEcoLore0(itemStack.clone(), player);
+ future.complete(itemStack);
+ });
+ return future;
}
}
diff --git a/common/src/main/java/com/loohp/interactivechat/hooks/essentials/EssentialsNicknames.java b/common/src/main/java/com/loohp/interactivechat/hooks/essentials/EssentialsNicknames.java
index 5ed275c0..4d55bc31 100644
--- a/common/src/main/java/com/loohp/interactivechat/hooks/essentials/EssentialsNicknames.java
+++ b/common/src/main/java/com/loohp/interactivechat/hooks/essentials/EssentialsNicknames.java
@@ -60,7 +60,7 @@ public static void init() {
}
});
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
for (Player player : Bukkit.getOnlinePlayers()) {
loadNicks(player);
}
@@ -80,7 +80,7 @@ public static void loadNicks(Player player) {
public void onEssentialsReload(PlayerCommandPreprocessEvent event) {
if (event.getMessage().equalsIgnoreCase("/essentials reload")) {
if (event.getPlayer().hasPermission("essentials.essentials")) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
prefix = essen.getConfig().getString("nickname-prefix");
}, 40);
}
@@ -100,7 +100,7 @@ public void onEssentialsNickChange(NickChangeEvent event) {
@EventHandler
public void onEssentialsJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
loadNicks(player);
}, 100);
}
diff --git a/common/src/main/java/com/loohp/interactivechat/hooks/floodgate/FloodgateHook.java b/common/src/main/java/com/loohp/interactivechat/hooks/floodgate/FloodgateHook.java
index bc865c3c..693d5b30 100644
--- a/common/src/main/java/com/loohp/interactivechat/hooks/floodgate/FloodgateHook.java
+++ b/common/src/main/java/com/loohp/interactivechat/hooks/floodgate/FloodgateHook.java
@@ -162,7 +162,7 @@ private static void handleRunCommand(UUID uuid, String command) {
} else {
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> PlayerUtils.dispatchCommandAsPlayer(player, command));
+ InteractiveChat.plugin.getScheduler().runNextTick((task) -> PlayerUtils.dispatchCommandAsPlayer(player, command));
}
}
}
diff --git a/common/src/main/java/com/loohp/interactivechat/hooks/luckperms/LuckPermsEvents.java b/common/src/main/java/com/loohp/interactivechat/hooks/luckperms/LuckPermsEvents.java
index 4db65af0..28a5dbc6 100644
--- a/common/src/main/java/com/loohp/interactivechat/hooks/luckperms/LuckPermsEvents.java
+++ b/common/src/main/java/com/loohp/interactivechat/hooks/luckperms/LuckPermsEvents.java
@@ -41,7 +41,7 @@ public LuckPermsEvents(InteractiveChat plugin) {
UUID uuid = event.getUser().getUniqueId();
if (!scheduledReset.contains(uuid)) {
scheduledReset.add(uuid);
- Bukkit.getScheduler().runTaskLater(plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater(() -> {
PlayerUtils.resetPermissionCache(uuid);
scheduledReset.remove(uuid);
}, 1);
diff --git a/common/src/main/java/com/loohp/interactivechat/hooks/venturechat/VentureChatInjection.java b/common/src/main/java/com/loohp/interactivechat/hooks/venturechat/VentureChatInjection.java
index 1e453114..18d4862f 100644
--- a/common/src/main/java/com/loohp/interactivechat/hooks/venturechat/VentureChatInjection.java
+++ b/common/src/main/java/com/loohp/interactivechat/hooks/venturechat/VentureChatInjection.java
@@ -62,7 +62,7 @@ public static void firePacketListener(PacketEvent event) {
public void onPluginEnable(PluginEnableEvent event) {
if (init) {
if (event.getPlugin().getName().equalsIgnoreCase("VentureChat")) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
_init_();
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE + "[InteractiveChat] InteractiveChat has injected into VentureChat!");
}, 100);
diff --git a/common/src/main/java/com/loohp/interactivechat/listeners/ChatEvents.java b/common/src/main/java/com/loohp/interactivechat/listeners/ChatEvents.java
index 401b4c86..e906a547 100644
--- a/common/src/main/java/com/loohp/interactivechat/listeners/ChatEvents.java
+++ b/common/src/main/java/com/loohp/interactivechat/listeners/ChatEvents.java
@@ -358,7 +358,7 @@ public static void checkChatMessage(AsyncPlayerChatEvent event) {
String mapKey = ChatColorUtils.stripColor(ChatColorUtils.translateAlternateColorCodes('&', event.getMessage()));
InteractiveChat.messages.put(mapKey, player.getUniqueId());
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> InteractiveChat.messages.remove(mapKey), 60);
+ InteractiveChat.plugin.getScheduler().runLater((task) -> InteractiveChat.messages.remove(mapKey), 60);
if (InteractiveChat.bungeecordMode) {
try {
diff --git a/common/src/main/java/com/loohp/interactivechat/listeners/ClientSettingPacket.java b/common/src/main/java/com/loohp/interactivechat/listeners/ClientSettingPacket.java
index 88856caa..c280d5d2 100644
--- a/common/src/main/java/com/loohp/interactivechat/listeners/ClientSettingPacket.java
+++ b/common/src/main/java/com/loohp/interactivechat/listeners/ClientSettingPacket.java
@@ -73,9 +73,9 @@ public static void handlePacketReceiving(PacketEvent event) {
boolean colorSettings = NMS.getInstance().getColorSettingsFromClientInformationPacket(packet);
boolean originalColorSettings = PlayerUtils.canChatColor(player);
if (originalColorSettings && !colorSettings) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> player.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', ConfigManager.getConfig().getString("Messages.ColorsDisabled"))), 5);
+ InteractiveChat.plugin.getScheduler().runLater((task) -> player.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', ConfigManager.getConfig().getString("Messages.ColorsDisabled"))), 5);
} else if (!originalColorSettings && colorSettings) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> player.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', ConfigManager.getConfig().getString("Messages.ColorsReEnabled"))), 5);
+ InteractiveChat.plugin.getScheduler().runLater((task) -> player.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', ConfigManager.getConfig().getString("Messages.ColorsReEnabled"))), 5);
}
}
diff --git a/common/src/main/java/com/loohp/interactivechat/listeners/InventoryEvents.java b/common/src/main/java/com/loohp/interactivechat/listeners/InventoryEvents.java
index 31c51c7c..0b6da5c1 100644
--- a/common/src/main/java/com/loohp/interactivechat/listeners/InventoryEvents.java
+++ b/common/src/main/java/com/loohp/interactivechat/listeners/InventoryEvents.java
@@ -67,9 +67,9 @@ public void onInventoryClick(InventoryClickEvent event) {
if (hash != null) {
Inventory fakeInv = InteractiveChat.inventoryDisplay1Lower.get(hash);
if (fakeInv == null) {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> player.closeInventory());
+ InteractiveChat.plugin.getScheduler().runNextTick((task) -> player.closeInventory());
} else {
- Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> InventoryUtils.sendFakePlayerInventory(player, fakeInv, true, false));
+ InteractiveChat.plugin.getScheduler().runNextTick((task) -> InventoryUtils.sendFakePlayerInventory(player, fakeInv, true, false));
}
}
if (event.getView().getTopInventory() == null) {
@@ -157,7 +157,7 @@ private void inventoryAction(ItemStack item, Player player, Inventory topInvento
displayInventory.setItem(i + 9, containerItem == null ? null : containerItem.clone());
}
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAtEntityLater(player, (task) -> {
ValuePairs opened;
String hash = InteractiveChat.viewingInv1.remove(player.getUniqueId());
if (hash != null) {
@@ -179,7 +179,7 @@ private void inventoryAction(ItemStack item, Player player, Inventory topInvento
public void onInventoryClickHighest(InventoryClickEvent event) {
if (CANCELLED_INVENTORY.remove(event)) {
event.setCancelled(true);
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> ((Player) event.getWhoClicked()).updateInventory(), 5);
+ InteractiveChat.plugin.getScheduler().runAtEntityLater(event.getWhoClicked(), (task) -> ((Player) event.getWhoClicked()).updateInventory(), 5);
}
}
@@ -193,7 +193,7 @@ public void onInventoryClose(InventoryCloseEvent event) {
if (topInventory != null) {
ValuePairs opened = InteractiveChat.containerDisplay.remove(topInventory);
if (opened != null) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runAtEntityLater(player, (task) -> {
player.openInventory(opened.getFirst());
String hash = opened.getSecond();
if (hash != null) {
diff --git a/common/src/main/java/com/loohp/interactivechat/listeners/MapViewer.java b/common/src/main/java/com/loohp/interactivechat/listeners/MapViewer.java
index d84318c7..fa49d275 100644
--- a/common/src/main/java/com/loohp/interactivechat/listeners/MapViewer.java
+++ b/common/src/main/java/com/loohp/interactivechat/listeners/MapViewer.java
@@ -23,7 +23,6 @@
import com.loohp.interactivechat.InteractiveChat;
import com.loohp.interactivechat.nms.NMS;
import com.loohp.interactivechat.utils.FilledMapUtils;
-import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@@ -42,7 +41,6 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapCursor;
import org.bukkit.map.MapView;
-import org.bukkit.scheduler.BukkitRunnable;
import java.util.Iterator;
import java.util.List;
@@ -66,30 +64,27 @@ public static void showMap(Player player, ItemStack item) {
NMS.getInstance().sendFakeMainHandSlot(player, item);
MAP_VIEWERS.put(player, item);
-
- new BukkitRunnable() {
- @Override
- public void run() {
- ItemStack itemStack = MAP_VIEWERS.get(player);
- if (itemStack != null && itemStack.equals(item)) {
- if (!player.getInventory().containsAtLeast(itemStack, 1)) {
- byte[] colors = FilledMapUtils.getColors(mapView, player);
- List mapCursors = FilledMapUtils.getCursors(mapView, player);
- Iterator itr = mapCursors.iterator();
- while (itr.hasNext()) {
- MapCursor mapCursor = itr.next();
- int type = mapCursor.getRawType();
- if (type == 0 || type == 6 || type == 7) {
- itr.remove();
- }
+
+ InteractiveChat.plugin.getScheduler().runTimer((outer) -> {
+ ItemStack itemStack = MAP_VIEWERS.get(player);
+ if (itemStack != null && itemStack.equals(item)) {
+ if (!player.getInventory().containsAtLeast(itemStack, 1)) {
+ byte[] colors = FilledMapUtils.getColors(mapView, player);
+ List mapCursors = FilledMapUtils.getCursors(mapView, player);
+ Iterator itr = mapCursors.iterator();
+ while (itr.hasNext()) {
+ MapCursor mapCursor = itr.next();
+ int type = mapCursor.getRawType();
+ if (type == 0 || type == 6 || type == 7) {
+ itr.remove();
}
- NMS.getInstance().sendFakeMapUpdate(player, mapId, mapCursors, colors);
}
- } else {
- this.cancel();
+ NMS.getInstance().sendFakeMapUpdate(player, mapId, mapCursors, colors);
}
+ } else {
+ outer.cancel();
}
- }.runTaskTimer(InteractiveChat.plugin, 0, 1);
+ }, 0, 1);
} catch (Exception e) {
e.printStackTrace();
}
@@ -111,7 +106,7 @@ public void onInventory(InventoryOpenEvent event) {
public void onInventory(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (player.getGameMode().equals(GameMode.CREATIVE)) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
boolean removed = MAP_VIEWERS.remove(player) != null;
if (removed) {
@@ -141,7 +136,7 @@ public void onInventory(InventoryCreativeEvent event) {
if (removed) {
if (player.getInventory().equals(event.getClickedInventory()) && slot >= 9) {
ItemStack item = player.getInventory().getItem(slot);
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> player.getInventory().setItem(slot, item), 1);
+ InteractiveChat.plugin.getScheduler().runLater((task) -> player.getInventory().setItem(slot, item), 1);
} else {
event.setCursor(null);
}
@@ -167,7 +162,7 @@ public void onSlotChange(PlayerItemHeldEvent event) {
if (removed) {
player.getInventory().setHeldItemSlot(lastSlot);
NMS.getInstance().sendFakeMainHandSlot(player, player.getInventory().getItemInHand());
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> player.getInventory().setHeldItemSlot(slot), 1);
+ InteractiveChat.plugin.getScheduler().runLater((task) -> player.getInventory().setHeldItemSlot(slot), 1);
}
}
@@ -180,7 +175,7 @@ public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (player.getGameMode().equals(GameMode.CREATIVE)) {
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
boolean removed = MAP_VIEWERS.remove(player) != null;
if (removed) {
diff --git a/common/src/main/java/com/loohp/interactivechat/listeners/OutMessagePacket.java b/common/src/main/java/com/loohp/interactivechat/listeners/OutMessagePacket.java
index ea31d603..e99b7523 100644
--- a/common/src/main/java/com/loohp/interactivechat/listeners/OutMessagePacket.java
+++ b/common/src/main/java/com/loohp/interactivechat/listeners/OutMessagePacket.java
@@ -575,7 +575,7 @@ private static void processPacket(Player receiver, ICPlayer determinedSender, Pa
if (sender.isPresent() && !sender.get().isLocal()) {
if (isFiltered) {
- Bukkit.getScheduler().runTaskLaterAsynchronously(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLaterAsync((task) -> {
SERVICE.execute(() -> {
processPacket(receiver, determinedSender, packet, messageUUID, false, packetHandler);
}, receiver, messageUUID);
@@ -673,7 +673,7 @@ private static void processPacket(Player receiver, ICPlayer determinedSender, Pa
PreChatPacketSendEvent sendEvent = new PreChatPacketSendEvent(true, receiver, packet, component, postEventSenderUUID, originalPacket, InteractiveChat.sendOriginalIfTooLong, longerThanMaxLength);
Bukkit.getPluginManager().callEvent(sendEvent);
- Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> {
+ InteractiveChat.plugin.getScheduler().runLater((task) -> {
InteractiveChat.keyTime.remove(rawMessageKey);
InteractiveChat.keyPlayer.remove(rawMessageKey);
}, 10);
diff --git a/common/src/main/java/com/loohp/interactivechat/listeners/OutTabCompletePacket.java b/common/src/main/java/com/loohp/interactivechat/listeners/OutTabCompletePacket.java
index 23948a78..eba19c09 100644
--- a/common/src/main/java/com/loohp/interactivechat/listeners/OutTabCompletePacket.java
+++ b/common/src/main/java/com/loohp/interactivechat/listeners/OutTabCompletePacket.java
@@ -59,7 +59,7 @@ public class OutTabCompletePacket {
private static AtomicReference