aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0036-Add-MetadataStoreBase.removeAll-Plugin.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/api/0036-Add-MetadataStoreBase.removeAll-Plugin.patch')
-rw-r--r--patches/api/0036-Add-MetadataStoreBase.removeAll-Plugin.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/patches/api/0036-Add-MetadataStoreBase.removeAll-Plugin.patch b/patches/api/0036-Add-MetadataStoreBase.removeAll-Plugin.patch
new file mode 100644
index 0000000000..2496de7423
--- /dev/null
+++ b/patches/api/0036-Add-MetadataStoreBase.removeAll-Plugin.patch
@@ -0,0 +1,46 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Tue, 16 Jul 2013 21:26:50 -0400
+Subject: [PATCH] Add MetadataStoreBase.removeAll(Plugin)
+
+So that on reload, metadata will be cleared
+
+diff --git a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
+index a0698522f01619c9d37474f4bd55a17de58fff89..a298baaa7a126515bb2802dd311f8487f3e5533f 100644
+--- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
++++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
+@@ -5,6 +5,7 @@ import java.util.ArrayList;
+ import java.util.Collection;
+ import java.util.Collections;
+ import java.util.HashMap;
++import java.util.Iterator; // Paper
+ import java.util.List;
+ import java.util.Map;
+ 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
+ * unique data from the subject with a metadataKey.