minor change

This commit is contained in:
xGinko 2024-03-20 22:19:59 +01:00
parent 123c0d0787
commit 005f26b2d3

View File

@ -91,12 +91,12 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
if (!player.hasPermission(Permissions.Optimize.WORKSTATION.get())) return; if (!player.hasPermission(Permissions.Optimize.WORKSTATION.get())) return;
final Location workstationLoc = placed.getLocation(); final Location workstationLoc = placed.getLocation();
final AtomicBoolean done = new AtomicBoolean(false); final AtomicBoolean taskComplete = new AtomicBoolean();
final AtomicInteger taskAliveTicks = new AtomicInteger(check_duration_ticks); final AtomicInteger taskAliveTicks = new AtomicInteger();
scheduler.runAtLocationTimer(workstationLoc, lingeringRepeatingCheck -> { scheduler.runAtLocationTimer(workstationLoc, repeatingTask -> {
if (done.get() || taskAliveTicks.getAndAdd(-10) <= 0) { if (taskComplete.get() || taskAliveTicks.getAndAdd(10) > check_duration_ticks) {
lingeringRepeatingCheck.cancel(); repeatingTask.cancel();
return; return;
} }
@ -116,7 +116,7 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
VillagerOptimizer.getLang(player.locale()).nametag_on_optimize_cooldown VillagerOptimizer.getLang(player.locale()).nametag_on_optimize_cooldown
.forEach(line -> KyoriUtil.sendMessage(player, line.replaceText(timeLeft))); .forEach(line -> KyoriUtil.sendMessage(player, line.replaceText(timeLeft)));
} }
done.set(true); taskComplete.set(true);
return; return;
} }
@ -151,7 +151,7 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
GenericUtil.formatLocation(wrapped.villager().getLocation())).color(GenericUtil.COLOR)); GenericUtil.formatLocation(wrapped.villager().getLocation())).color(GenericUtil.COLOR));
} }
done.set(true); taskComplete.set(true);
return; return;
} }
}, 1L, 10L); }, 1L, 10L);