Merge pull request #2747 from KisaragiEffective/feature/use-collections-static-methods

use Collections' factory method instead of static field
This commit is contained in:
Ben Woo 2022-01-17 16:42:18 +08:00 committed by GitHub
commit 5d6bc806f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -356,7 +356,7 @@ public class MVWorld implements MultiverseWorld {
@Override
public Map<String, Object> serialize() {
return Collections.EMPTY_MAP;
return Collections.emptyMap();
}
/**

View File

@ -534,7 +534,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
} else if (entry.getValue() instanceof ConfigurationSection) {
Logging.fine("Migrating: " + entry.getKey());
// we have to migrate this
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
WorldProperties world = new WorldProperties(Collections.emptyMap());
ConfigurationSection section = (ConfigurationSection) entry.getValue();
// migrate animals and monsters

View File

@ -101,42 +101,42 @@ public class TestEntitySpawnRules {
@Test
public void test() {
// test 1: no spawning at all allowed
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(false, false, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(true);
// test 2: only monsters
adjustSettings(false, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(false, true, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 3: all spawning allowed
adjustSettings(true, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(true, true, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(false);
verify(zombieEvent).setCancelled(false);
// test 4: no spawning with zombie exception
adjustSettings(false, false, Collections.EMPTY_LIST, Arrays.asList("ZOMBIE"));
adjustSettings(false, false, Collections.emptyList(), Arrays.asList("ZOMBIE"));
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 5: all spawning with sheep exception
adjustSettings(true, true, Arrays.asList("SHEEP"), Collections.EMPTY_LIST);
adjustSettings(true, true, Arrays.asList("SHEEP"), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 6: eggs
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(false, false, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAll(SpawnReason.SPAWNER_EGG);
verify(sheepEvent, never()).setCancelled(anyBoolean());