mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-27 22:38:11 +01:00
Add MetadataStoreBase.removeAll(Plugin)
So that on reload, metadata will be cleared
This commit is contained in:
parent
fc77a4d2d3
commit
542f830ebc
1 changed files with 21 additions and 0 deletions
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator; // Paper
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -130,6 +131,26 @@ public abstract class MetadataStoreBase<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all metadata in the metadata store that originates from the
|
||||||
|
* given plugin.
|
||||||
|
*
|
||||||
|
* @param owningPlugin the plugin requesting the invalidation.
|
||||||
|
* @throws IllegalArgumentException If plugin is null
|
||||||
|
*/
|
||||||
|
public void removeAll(@NotNull Plugin owningPlugin) {
|
||||||
|
Preconditions.checkNotNull(owningPlugin, "Plugin cannot be null");
|
||||||
|
for (Iterator<Map<Plugin, MetadataValue>> iterator = metadataMap.values().iterator(); iterator.hasNext(); ) {
|
||||||
|
Map<Plugin, MetadataValue> values = iterator.next();
|
||||||
|
if (values.containsKey(owningPlugin)) {
|
||||||
|
values.remove(owningPlugin);
|
||||||
|
}
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a unique name for the object receiving metadata by combining
|
* Creates a unique name for the object receiving metadata by combining
|
||||||
* unique data from the subject with a metadataKey.
|
* unique data from the subject with a metadataKey.
|
||||||
|
|
Loading…
Add table
Reference in a new issue