improve readability

This commit is contained in:
xGinko 2024-02-08 22:24:59 +01:00
parent 5c6bba5c2d
commit b07490f9b4

View File

@ -124,7 +124,20 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
WrappedVillager finalToOptimize = toOptimize; WrappedVillager finalToOptimize = toOptimize;
pending_optimizations.put(placed.getLocation(), scheduler.runAtLocationLater(workstationLoc, () -> { pending_optimizations.put(placed.getLocation(), scheduler.runAtLocationLater(workstationLoc, () -> {
if (finalToOptimize.canOptimize(cooldown_millis) || player.hasPermission(Bypass.WORKSTATION_COOLDOWN.get())) { if (!finalToOptimize.canOptimize(cooldown_millis) && !player.hasPermission(Bypass.WORKSTATION_COOLDOWN.get())) {
CommonUtil.shakeHead(finalToOptimize.villager());
if (notify_player) {
final TextReplacementConfig timeLeft = TextReplacementConfig.builder()
.matchLiteral("%time%")
.replacement(CommonUtil.formatTime(finalToOptimize.getOptimizeCooldownMillis(cooldown_millis)))
.build();
VillagerOptimizer.getLang(player.locale()).nametag_on_optimize_cooldown.forEach(line -> player.sendMessage(line
.replaceText(timeLeft)
));
}
return;
}
VillagerOptimizeEvent optimizeEvent = new VillagerOptimizeEvent(finalToOptimize, OptimizationType.WORKSTATION, player, event.isAsynchronous()); VillagerOptimizeEvent optimizeEvent = new VillagerOptimizeEvent(finalToOptimize, OptimizationType.WORKSTATION, player, event.isAsynchronous());
if (!optimizeEvent.callEvent()) return; if (!optimizeEvent.callEvent()) return;
@ -146,21 +159,8 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
)); ));
} }
if (log_enabled) if (log_enabled) VillagerOptimizer.getLog().info(player.getName() + " optimized a villager using workstation: '" +
VillagerOptimizer.getLog().info(player.getName() + " optimized a villager using workstation: '" +
placed.getType().toString().toLowerCase() + "'"); placed.getType().toString().toLowerCase() + "'");
} else {
CommonUtil.shakeHead(finalToOptimize.villager());
if (notify_player) {
final TextReplacementConfig timeLeft = TextReplacementConfig.builder()
.matchLiteral("%time%")
.replacement(CommonUtil.formatTime(finalToOptimize.getOptimizeCooldownMillis(cooldown_millis)))
.build();
VillagerOptimizer.getLang(player.locale()).nametag_on_optimize_cooldown.forEach(line -> player.sendMessage(line
.replaceText(timeLeft)
));
}
}
}, toOptimize.canLooseProfession() ? resettable_delay_millis : delay_millis, TimeUnit.MILLISECONDS)); }, toOptimize.canLooseProfession() ? resettable_delay_millis : delay_millis, TimeUnit.MILLISECONDS));
} }