use Collections' factory method instead of static field

this resolves some unchecked generics warning
This commit is contained in:
Kisaragi 2021-12-31 00:46:21 +09:00
parent ac6fcf5ed6
commit 5868ad64b4
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());