From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Wed, 14 Apr 2021 16:30:43 +0200 Subject: [PATCH] Load Plugins async paper diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 568aefdf698facfc36edacc9332e83196c0d80bc..4b2fdf80d94698b45e79b5d9547e091c73cf4074 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -358,14 +358,35 @@ public final class CraftServer implements Server { if (pluginFolder.exists()) { Plugin[] plugins = pluginManager.loadPlugins(pluginFolder); + List threads = new ArrayList<>(); //Steamwar for (Plugin plugin : plugins) { - try { + //Steamwar Start + /*try { String message = String.format("Loading %s", plugin.getDescription().getFullName()); plugin.getLogger().info(message); plugin.onLoad(); } catch (Throwable ex) { Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); + }*/ + Thread thread = new Thread(() -> { + try { + String message = String.format("Loading %s", plugin.getDescription().getFullName()); + plugin.getLogger().info(message); + plugin.onLoad(); + } catch (Throwable ex) { + Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); + } + }); + thread.start(); + threads.add(thread); + } + for (Thread thread : threads) { + try { + thread.join(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } + //Steamwar End } } else { pluginFolder.mkdir();