mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 11:10:05 +01:00
Cleanup for all added components, reorder cleanup on disable.
This commit is contained in:
parent
9bd7745690
commit
53756f7145
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -245,6 +246,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||||||
|
|
||||||
protected final List<PermStateReceiver> permStateReceivers = new ArrayList<PermStateReceiver>();
|
protected final List<PermStateReceiver> permStateReceivers = new ArrayList<PermStateReceiver>();
|
||||||
|
|
||||||
|
/** All registered components. */
|
||||||
|
protected Set<Object> allComponents = new LinkedHashSet<Object>(50);
|
||||||
|
|
||||||
protected Metrics metrics = null;
|
protected Metrics metrics = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,6 +256,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addComponent(final Object obj) {
|
public void addComponent(final Object obj) {
|
||||||
|
allComponents.add(obj);
|
||||||
if (obj instanceof Listener) {
|
if (obj instanceof Listener) {
|
||||||
addListener((Listener) obj);
|
addListener((Listener) obj);
|
||||||
}
|
}
|
||||||
@ -363,6 +368,22 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Stop all remaining tasks...");
|
if (verbose) LogUtil.logInfo("[NoCheatPlus] Stop all remaining tasks...");
|
||||||
getServer().getScheduler().cancelTasks(this);
|
getServer().getScheduler().cancelTasks(this);
|
||||||
|
|
||||||
|
// Exemptions cleanup.
|
||||||
|
NCPExemptionManager.clear();
|
||||||
|
|
||||||
|
// Data cleanup.
|
||||||
|
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup DataManager...");
|
||||||
|
dataMan.onDisable();
|
||||||
|
|
||||||
|
// Hooks:
|
||||||
|
// (Expect external plugins to unregister their hooks on their own.)
|
||||||
|
// (No native hooks present, yet.)
|
||||||
|
|
||||||
|
// Unregister all added components explicitly.
|
||||||
|
for (Object obj : allComponents){
|
||||||
|
removeComponent(obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup some mappings...");
|
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup some mappings...");
|
||||||
// Remove listeners.
|
// Remove listeners.
|
||||||
listeners.clear();
|
listeners.clear();
|
||||||
@ -371,17 +392,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||||||
// World specific permissions.
|
// World specific permissions.
|
||||||
permStateReceivers.clear();
|
permStateReceivers.clear();
|
||||||
|
|
||||||
// Data cleanup.
|
|
||||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup DataManager...");
|
|
||||||
dataMan.onDisable();
|
|
||||||
|
|
||||||
// Exemptions cleanup.
|
|
||||||
NCPExemptionManager.clear();
|
|
||||||
|
|
||||||
// Hooks:
|
|
||||||
// (Expect external plugins to unregister their hooks on their own.)
|
|
||||||
// (No native hooks present, yet.)
|
|
||||||
|
|
||||||
// Clear command changes list (compatibility issues with NPCs, leads to recalculation of perms).
|
// Clear command changes list (compatibility issues with NPCs, leads to recalculation of perms).
|
||||||
if (changedCommands != null){
|
if (changedCommands != null){
|
||||||
changedCommands.clear();
|
changedCommands.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user