do more scheduling for folia
This commit is contained in:
parent
6fe1330038
commit
42a1bdec57
@ -92,14 +92,17 @@ public class OptimizeByWorkstation extends VillagerOptimizerModule implements Li
|
||||
}
|
||||
|
||||
for (Villager villager : workstationLoc.getNearbyEntitiesByType(Villager.class, search_radius)) {
|
||||
if (villager.getProfession() != workstationProfession) continue;
|
||||
villager.getScheduler().execute(plugin, () -> {
|
||||
if (villager.getProfession() != workstationProfession) return;
|
||||
WrappedVillager wrapped = wrapperCache.get(villager);
|
||||
if (wrapped.getJobSite() == null) continue;
|
||||
if (wrapped.getJobSite().getWorld().getUID() != workstationLoc.getWorld().getUID()) continue;
|
||||
if (LocationUtil.relDistance3DSquared(wrapped.getJobSite(), workstationLoc) > 1) continue;
|
||||
|
||||
Location jobSite = wrapped.getJobSite();
|
||||
if (jobSite == null || jobSite.getWorld().getUID() != workstationLoc.getWorld().getUID()) return;
|
||||
if (LocationUtil.relDistance3DSquared(jobSite, workstationLoc) > 1) return;
|
||||
|
||||
if (!wrapped.canOptimize(cooldown_millis) && !player.hasPermission(Permissions.Bypass.WORKSTATION_COOLDOWN.get())) {
|
||||
wrapped.sayNo();
|
||||
|
||||
if (notify_player) {
|
||||
final TextReplacementConfig timeLeft = TextReplacementConfig.builder()
|
||||
.matchLiteral("%time%")
|
||||
@ -108,6 +111,7 @@ public class OptimizeByWorkstation extends VillagerOptimizerModule implements Li
|
||||
VillagerOptimizer.getLang(player.locale()).nametag_on_optimize_cooldown
|
||||
.forEach(line -> KyoriUtil.sendMessage(player, line.replaceText(timeLeft)));
|
||||
}
|
||||
|
||||
taskComplete.set(true);
|
||||
return;
|
||||
}
|
||||
@ -143,7 +147,7 @@ public class OptimizeByWorkstation extends VillagerOptimizerModule implements Li
|
||||
}
|
||||
|
||||
taskComplete.set(true);
|
||||
return;
|
||||
}, null, 1L);
|
||||
}
|
||||
}, 1L, 10L);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user