mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-03 17:29:56 +01:00
36f34f01c0
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 Bukkit Changes: da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots 3abebc9f #492: Let Tameable extend Animals rather than Entity 941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent 4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME CraftBukkit Changes:933e9094
#664: Add methods to get/set ItemStacks in EquipmentSlots18722312
#662: Expose ItemStack and hand used in PlayerShearEntityEvent
47 lines
1.8 KiB
Diff
47 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 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 d363d517c05b3335101d829ce4ec22d049059c24..abbe545af572687a0399c2387434863cd2b70f68 100644
|
|
--- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
|
+++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
|
@@ -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> {
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
+ * 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.
|