Save to disk on dependent plugin disable

This commit is contained in:
fullwall 2021-07-25 08:52:03 +08:00
parent 9904e034fd
commit 1ef3e6b56b

View File

@ -277,6 +277,12 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
return commands.executeSafe(command, args, sender, methodArgs); return commands.executeSafe(command, args, sender, methodArgs);
} }
public void onDependentPluginDisable() {
storeNPCs();
saves.saveToDiskImmediate();
saveOnDisable = false;
}
@Override @Override
public void onDisable() { public void onDisable() {
if (!enabled) if (!enabled)
@ -286,9 +292,9 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
despawnNPCs(saveOnDisable); despawnNPCs(saveOnDisable);
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
npcRegistry = null; npcRegistry = null;
NMS.shutdown();
enabled = false; enabled = false;
saveOnDisable = true; saveOnDisable = true;
NMS.shutdown();
CitizensAPI.shutdown(); CitizensAPI.shutdown();
} }
@ -351,11 +357,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);
} }
public void onDependentPluginDisable() {
storeNPCs();
saveOnDisable = false;
}
public void registerCommandClass(Class<?> clazz) { public void registerCommandClass(Class<?> clazz) {
try { try {
commands.register(clazz); commands.register(clazz);