2020-05-01 22:03:47 +00:00
|
|
|
From 2b5c599b3684a15bdcd52ec6d182c9f5cef13ca1 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
|
2020-04-02 21:07:06 +00:00
|
|
|
index d363d517c..abbe545af 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
|
2019-04-23 04:47:07 +00:00
|
|
|
@@ -4,6 +4,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> {
|
2018-03-10 13:07:40 +00:00
|
|
|
}
|
2016-03-29 02:43:05 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 13:07:40 +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
|
|
|
|
+ */
|
2019-03-20 00:28:15 +00:00
|
|
|
+ public void removeAll(@NotNull Plugin owningPlugin) {
|
2016-03-29 02:43:05 +00:00
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2018-03-10 13:07:40 +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.
|
|
|
|
--
|
2020-05-01 22:03:47 +00:00
|
|
|
2.26.2
|
2016-03-29 02:43:05 +00:00
|
|
|
|