mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
[Bleeding] Removing the last metadata item for a key now sets hasMetadata(key) to false. Addresses BUKKIT-1380
By: rmichela <deltahat@gmail.com>
This commit is contained in:
parent
853f14f0dc
commit
cc95e9f5ef
@ -86,6 +86,9 @@ public abstract class MetadataStoreBase<T> {
|
||||
for (int i = 0; i < metadataList.size(); i++) {
|
||||
if (metadataList.get(i).getOwningPlugin().equals(owningPlugin)) {
|
||||
metadataList.remove(i);
|
||||
if (metadataList.isEmpty()) {
|
||||
metadataMap.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,15 @@ public class MetadataStoreTest {
|
||||
assertEquals(20, subject.getMetadata("subject", "key").get(0).value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetadataRemoveLast() {
|
||||
subject.setMetadata("subject", "key", new FixedMetadataValue(pluginX, 10));
|
||||
subject.removeMetadata("subject", "key", pluginX);
|
||||
|
||||
assertFalse(subject.hasMetadata("subject", "key"));
|
||||
assertEquals(0, subject.getMetadata("subject", "key").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetadataRemoveForNonExistingPlugin() {
|
||||
subject.setMetadata("subject", "key", new FixedMetadataValue(pluginX, 10));
|
||||
|
Loading…
Reference in New Issue
Block a user