Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-17 13:30:06 +01:00
48dff29f31
Objects loaded over different class loaders are not the same. Nasty dragons lie here. Also clean up the previous patch to no longer butcher imports.
42 Zeilen
1.5 KiB
Diff
42 Zeilen
1.5 KiB
Diff
From 9bfe42cfc7f02966926c3dccc68b7dc85e3c25cc Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 64c0f0a..6da6abd 100644
|
|
--- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
|
+++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
|
@@ -125,6 +125,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(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();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /**
|
|
* Creates a unique name for the object receiving metadata by combining
|
|
* unique data from the subject with a metadataKey.
|
|
* <p>
|
|
--
|
|
2.7.4
|
|
|