improve readability
This commit is contained in:
parent
5c6bba5c2d
commit
b07490f9b4
@ -124,32 +124,7 @@ 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())) {
|
||||||
VillagerOptimizeEvent optimizeEvent = new VillagerOptimizeEvent(finalToOptimize, OptimizationType.WORKSTATION, player, event.isAsynchronous());
|
|
||||||
if (!optimizeEvent.callEvent()) return;
|
|
||||||
|
|
||||||
finalToOptimize.setOptimizationType(optimizeEvent.getOptimizationType());
|
|
||||||
finalToOptimize.saveOptimizeTime();
|
|
||||||
|
|
||||||
if (notify_player) {
|
|
||||||
final TextReplacementConfig vilProfession = TextReplacementConfig.builder()
|
|
||||||
.matchLiteral("%vil_profession%")
|
|
||||||
.replacement(finalToOptimize.villager().getProfession().toString().toLowerCase())
|
|
||||||
.build();
|
|
||||||
final TextReplacementConfig placedWorkstation = TextReplacementConfig.builder()
|
|
||||||
.matchLiteral("%workstation%")
|
|
||||||
.replacement(placed.getType().toString().toLowerCase())
|
|
||||||
.build();
|
|
||||||
VillagerOptimizer.getLang(player.locale()).workstation_optimize_success.forEach(line -> player.sendMessage(line
|
|
||||||
.replaceText(vilProfession)
|
|
||||||
.replaceText(placedWorkstation)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (log_enabled)
|
|
||||||
VillagerOptimizer.getLog().info(player.getName() + " optimized a villager using workstation: '" +
|
|
||||||
placed.getType().toString().toLowerCase() + "'");
|
|
||||||
} else {
|
|
||||||
CommonUtil.shakeHead(finalToOptimize.villager());
|
CommonUtil.shakeHead(finalToOptimize.villager());
|
||||||
if (notify_player) {
|
if (notify_player) {
|
||||||
final TextReplacementConfig timeLeft = TextReplacementConfig.builder()
|
final TextReplacementConfig timeLeft = TextReplacementConfig.builder()
|
||||||
@ -160,7 +135,32 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
|
|||||||
.replaceText(timeLeft)
|
.replaceText(timeLeft)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VillagerOptimizeEvent optimizeEvent = new VillagerOptimizeEvent(finalToOptimize, OptimizationType.WORKSTATION, player, event.isAsynchronous());
|
||||||
|
if (!optimizeEvent.callEvent()) return;
|
||||||
|
|
||||||
|
finalToOptimize.setOptimizationType(optimizeEvent.getOptimizationType());
|
||||||
|
finalToOptimize.saveOptimizeTime();
|
||||||
|
|
||||||
|
if (notify_player) {
|
||||||
|
final TextReplacementConfig vilProfession = TextReplacementConfig.builder()
|
||||||
|
.matchLiteral("%vil_profession%")
|
||||||
|
.replacement(finalToOptimize.villager().getProfession().toString().toLowerCase())
|
||||||
|
.build();
|
||||||
|
final TextReplacementConfig placedWorkstation = TextReplacementConfig.builder()
|
||||||
|
.matchLiteral("%workstation%")
|
||||||
|
.replacement(placed.getType().toString().toLowerCase())
|
||||||
|
.build();
|
||||||
|
VillagerOptimizer.getLang(player.locale()).workstation_optimize_success.forEach(line -> player.sendMessage(line
|
||||||
|
.replaceText(vilProfession)
|
||||||
|
.replaceText(placedWorkstation)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log_enabled) VillagerOptimizer.getLog().info(player.getName() + " optimized a villager using workstation: '" +
|
||||||
|
placed.getType().toString().toLowerCase() + "'");
|
||||||
}, toOptimize.canLooseProfession() ? resettable_delay_millis : delay_millis, TimeUnit.MILLISECONDS));
|
}, toOptimize.canLooseProfession() ? resettable_delay_millis : delay_millis, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user