make whitelist work like a whitelist

This commit is contained in:
xGinko 2024-07-30 02:33:34 +02:00
parent 0ff37cbd7d
commit 0a3cd80f9c

View File

@ -19,6 +19,7 @@ import space.arim.morepaperlib.scheduling.ScheduledTask;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -66,10 +67,8 @@ public class VillagerChunkLimit extends VillagerOptimizerModule implements Runna
}).collect(Collectors.toList()); }).collect(Collectors.toList());
this.use_whitelist = config.getBoolean(configPath + ".whitelist.enable", false, this.use_whitelist = config.getBoolean(configPath + ".whitelist.enable", false,
"Enable if you only want to manage villager counts for certain profession types."); "Enable if you only want to manage villager counts for certain profession types.");
this.profession_whitelist = config.getList(configPath + ".whitelist.professions", defaults.stream() this.profession_whitelist = config.getList(configPath + ".whitelist.professions", Arrays.asList("NONE", "NITWIT"),
.filter(prof -> !prof.equalsIgnoreCase("NONE") && !prof.equalsIgnoreCase("NITWIT")) "Professions in this list will not be touched by the chunk limit.")
.collect(Collectors.toList()),
"Only professions in this list will count for the cap.")
.stream() .stream()
.map(configuredProfession -> { .map(configuredProfession -> {
try { try {
@ -182,7 +181,7 @@ public class VillagerChunkLimit extends VillagerOptimizerModule implements Runna
Villager villager = (Villager) entity; Villager villager = (Villager) entity;
// Ignore villager if profession is not in the whitelist // Ignore villager if profession is not in the whitelist
if (use_whitelist && !profession_whitelist.contains(villager.getProfession())) continue; if (use_whitelist && profession_whitelist.contains(villager.getProfession())) continue;
if (wrapperCache.get(villager).isOptimized()) { if (wrapperCache.get(villager).isOptimized()) {
optimized_villagers.add(villager); optimized_villagers.add(villager);