geforkt von Mirrors/Paper
[Bleeding] Removing the last metadata item for a key now sets hasMetadata(key) to false. Addresses BUKKIT-1380
By: rmichela <deltahat@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
853f14f0dc
Commit
cc95e9f5ef
@ -86,6 +86,9 @@ public abstract class MetadataStoreBase<T> {
|
|||||||
for (int i = 0; i < metadataList.size(); i++) {
|
for (int i = 0; i < metadataList.size(); i++) {
|
||||||
if (metadataList.get(i).getOwningPlugin().equals(owningPlugin)) {
|
if (metadataList.get(i).getOwningPlugin().equals(owningPlugin)) {
|
||||||
metadataList.remove(i);
|
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());
|
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
|
@Test
|
||||||
public void testMetadataRemoveForNonExistingPlugin() {
|
public void testMetadataRemoveForNonExistingPlugin() {
|
||||||
subject.setMetadata("subject", "key", new FixedMetadataValue(pluginX, 10));
|
subject.setMetadata("subject", "key", new FixedMetadataValue(pluginX, 10));
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren