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