PaperMC/Spigot-API-Patches/0031-Add-MetadataStoreBase.removeAll-Plugin.patch
Shane Freeder 0976d52bbd Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Please note that this build includes changes to meet upstreams
requirements for nullability annotations. While we aim for a level of
accuracy, these might not be 100% correct, if there are any issues,
please speak to us on discord, or open an issue on the tracker to
discuss.

Bukkit Changes:
9a6a1de3 Remove nullability annotations from enum constructors
3f0591ea SPIGOT-2540: Add nullability annotations to entire Bukkit API

CraftBukkit Changes:
8d8475fc SPIGOT-4666: Force parameter in HumanEntity#sleep
8b1588e2 Fix ExplosionPrimeEvent#setFire not working with EnderCrystals
39a287b7 Don't ignore newlines in PlayerListHeader/Footer

Spigot Changes:
cf694d87 Add nullability annotations
2019-03-20 00:31:18 +00:00

41 lines
1.5 KiB
Diff

From 0ae676c5ab5d5819d3e94e9ec554162a34fffa28 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 32728628e..b634b124e 100644
--- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
+++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
@@ -126,6 +126,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) {
+ 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.
--
2.21.0