diff --git a/pom.xml b/pom.xml index c09b8c3..ed6e297 100644 --- a/pom.xml +++ b/pom.xml @@ -149,7 +149,7 @@ fr.xephi authme - 5.5.0-SNAPSHOT + 5.6.0-SNAPSHOT provided diff --git a/src/main/java/com/Acrobot/ChestShop/ChestShop.java b/src/main/java/com/Acrobot/ChestShop/ChestShop.java index ec68890..6afb1df 100644 --- a/src/main/java/com/Acrobot/ChestShop/ChestShop.java +++ b/src/main/java/com/Acrobot/ChestShop/ChestShop.java @@ -91,6 +91,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import java.util.jar.JarFile; import java.util.logging.FileHandler; import java.util.logging.Logger; @@ -105,6 +108,7 @@ public class ChestShop extends JavaPlugin { private static ChestShop plugin; private static Server server; private static PluginDescriptionFile description; + private static final ExecutorService executorService = Executors.newCachedThreadPool(); private static BukkitAudiences audiences; @@ -304,7 +308,9 @@ public class ChestShop extends JavaPlugin { } public void onDisable() { - getServer().getScheduler().cancelTasks(this); + try { + executorService.awaitTermination(15, TimeUnit.SECONDS); + } catch (InterruptedException ignored) {} Toggle.clearToggledPlayers(); @@ -613,4 +619,8 @@ public class ChestShop extends JavaPlugin { Bukkit.getOnlinePlayers().iterator().next().sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); } } + + public static void runInAsyncThread(Runnable runnable) { + executorService.submit(runnable); + } } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java index 8442452..3b101ad 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java @@ -1,6 +1,5 @@ package com.Acrobot.ChestShop.Listeners.Player; -import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -23,7 +22,7 @@ public class PlayerConnect implements Listener { final PlayerDTO playerDTO = new PlayerDTO(event.getPlayer()); - Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), () -> { + ChestShop.runInAsyncThread(() -> { if (NameManager.getAccount(playerDTO.getUniqueId()) != null) { NameManager.storeUsername(playerDTO); } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java index 96b51ac..93f585c 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PostShopCreation/ShopCreationLogger.java @@ -16,7 +16,7 @@ public class ShopCreationLogger implements Listener { @EventHandler(priority = EventPriority.MONITOR) public static void onShopCreation(final ShopCreatedEvent event) { - ChestShop.getBukkitServer().getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), () -> { + ChestShop.runInAsyncThread(() -> { String creator = event.getPlayer().getName(); String shopOwner = ChestShopSign.getOwner(event.getSignLines()); String typeOfShop = ChestShopSign.isAdminShop(shopOwner) ? "an Admin Shop" : "a shop" + (event.createdByOwner() ? "" : " for " + event.getOwnerAccount().getName()); diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java b/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java index e7a4d0d..ad0b04d 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRemovalLogger.java @@ -21,7 +21,7 @@ public class ShopRemovalLogger implements Listener { return; } - ChestShop.getBukkitServer().getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), () -> { + ChestShop.runInAsyncThread(() -> { String shopOwner = ChestShopSign.getOwner(event.getSign()); String typeOfShop = ChestShopSign.isAdminShop(shopOwner) ? "An Admin Shop" : "A shop belonging to " + shopOwner; diff --git a/src/main/java/com/Acrobot/ChestShop/Updater/JenkinsBuildsNotifier.java b/src/main/java/com/Acrobot/ChestShop/Updater/JenkinsBuildsNotifier.java index b5a736c..f9b4125 100644 --- a/src/main/java/com/Acrobot/ChestShop/Updater/JenkinsBuildsNotifier.java +++ b/src/main/java/com/Acrobot/ChestShop/Updater/JenkinsBuildsNotifier.java @@ -1,5 +1,6 @@ package com.Acrobot.ChestShop.Updater; +import com.Acrobot.ChestShop.ChestShop; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.bukkit.configuration.file.FileConfiguration; @@ -55,7 +56,7 @@ public class JenkinsBuildsNotifier implements Runnable { try { apiUrl = new URL(jenkinsJobUrl + "api/json"); - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, this); + ChestShop.runInAsyncThread(this); } catch (MalformedURLException e) { plugin.getLogger().log(Level.WARNING, "Can not check for new dev builds as " + jenkinsJobUrl + "api/json is not a valid url!", e); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3e4d6bd..d2103e2 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,6 +6,7 @@ authors: ['https://github.com/ChestShop-authors/ChestShop-3/contributors'] description: A chest shop for economy plugins. softdepend: [Vault, Reserve, LWC, Lockette, LockettePro, Deadbolt, BlockLocker, OddItem, WorldGuard, GriefPrevention, RedProtect, Heroes, SimpleChestLock, Residence, ShowItem, ItemBridge] api-version: '1.13' +folia-supported: true commands: iteminfo: