2017-08-11 22:59:44 +00:00
|
|
|
From deead5d94a52ef9bf9f10ca6bb8771cdcabb587f Mon Sep 17 00:00:00 2001
|
2016-03-29 02:43:05 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
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
|
2017-04-22 14:32:06 +00:00
|
|
|
index 64c0f0a7..6da6abd8 100644
|
2016-03-29 02:43:05 +00:00
|
|
|
--- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
|
|
|
+++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
2017-08-11 22:59:44 +00:00
|
|
|
@@ -124,6 +124,26 @@ public abstract class MetadataStoreBase<T> {
|
|
|
|
}
|
2016-03-29 02:43:05 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 22:59:44 +00:00
|
|
|
+ /**
|
2016-03-29 02:43:05 +00:00
|
|
|
+ * 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(Plugin owningPlugin) {
|
|
|
|
+ Validate.notNull(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();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2017-08-11 22:59:44 +00:00
|
|
|
/**
|
2016-03-29 02:43:05 +00:00
|
|
|
* Creates a unique name for the object receiving metadata by combining
|
|
|
|
* unique data from the subject with a metadataKey.
|
|
|
|
--
|
2017-08-11 22:59:44 +00:00
|
|
|
2.14.1
|
2016-03-29 02:43:05 +00:00
|
|
|
|