mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-03 16:36:00 +00:00
Post shutdown fixes
This commit is contained in:
parent
a09e77a17d
commit
059d5542c9
@ -75,7 +75,6 @@ import java.util.Map;
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
public class Iris extends VolmitPlugin implements Listener {
|
||||
private KMap<Class<? extends IrisService>, IrisService> services;
|
||||
public static KList<GroupedExecutor> executors = new KList<>();
|
||||
public static Iris instance;
|
||||
public static BukkitAudiences audiences;
|
||||
public static MultiverseCoreLink linkMultiverseCore;
|
||||
@ -85,6 +84,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
public static IrisCompat compat;
|
||||
public static FileWatcher configWatcher;
|
||||
private static VolmitSender sender;
|
||||
private final KList<Runnable> postShutdown = new KList<>();
|
||||
|
||||
@Permission
|
||||
public static PermissionIris perm;
|
||||
@ -126,6 +126,11 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
services.values().forEach(this::registerListener);
|
||||
}
|
||||
|
||||
public void postShutdown(Runnable r)
|
||||
{
|
||||
postShutdown.add(r);
|
||||
}
|
||||
|
||||
private void postEnable() {
|
||||
J.a(() -> PaperLib.suggestPaper(this));
|
||||
J.a(() -> IO.delete(getTemp()));
|
||||
@ -155,18 +160,10 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
for (GroupedExecutor i : executors) {
|
||||
Iris.debug("Closing Executor " + i.toString());
|
||||
i.closeNow();
|
||||
}
|
||||
|
||||
executors.clear();
|
||||
|
||||
services.values().forEach(IrisService::onDisable);
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
HandlerList.unregisterAll((Plugin) this);
|
||||
MultiBurst.burst.shutdown();
|
||||
|
||||
services.values().forEach(IrisService::onDisable);
|
||||
postShutdown.forEach(Runnable::run);
|
||||
services.clear();
|
||||
super.onDisable();
|
||||
}
|
||||
|
@ -159,16 +159,30 @@ public class MultiBurst {
|
||||
|
||||
public void shutdownLater() {
|
||||
if (service != null) {
|
||||
service.submit(() -> {
|
||||
J.sleep(3000);
|
||||
try
|
||||
{
|
||||
service.submit(() -> {
|
||||
J.sleep(3000);
|
||||
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
||||
|
||||
if (service != null) {
|
||||
service.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
heartbeat.interrupt();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.debug("Shutting down MultiBurst Pool " + heartbeat.getName() + ".");
|
||||
|
||||
if (service != null) {
|
||||
service.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
heartbeat.interrupt();
|
||||
heartbeat.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,16 @@
|
||||
|
||||
package com.volmit.iris.util.plugin;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public interface IrisService extends Listener {
|
||||
void onEnable();
|
||||
|
||||
void onDisable();
|
||||
|
||||
default void postShutdown(Runnable r)
|
||||
{
|
||||
Iris.instance.postShutdown(r);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user