Finalized ColorJump #13
+19
-19
@@ -14,6 +14,7 @@ import net.minestom.server.event.player.PlayerSwapItemEvent;
|
|||||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
|
import net.minestom.server.timer.Scheduler;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -97,30 +98,29 @@ public class ColorJump extends StatelessGame {
|
|||||||
if(this.roundTime <= 1) this.roundTime = 1;
|
if(this.roundTime <= 1) this.roundTime = 1;
|
||||||
|
|
||||||
long totalTicks = (long) (this.roundTime * 20);
|
long totalTicks = (long) (this.roundTime * 20);
|
||||||
|
MineTec marked this conversation as resolved
|
|||||||
final long[] remainingTicks = { totalTicks };
|
this.scheduleExpUpdate(scheduler, totalTicks, totalTicks);
|
||||||
|
}
|
||||||
|
|
||||||
scheduler.scheduleTask(() -> {
|
private void scheduleExpUpdate(Scheduler scheduler, long remainingTicks, long totalTicks) {
|
||||||
|
if (!this.isRunning) return;
|
||||||
if (!this.isRunning)
|
|
||||||
return stop;
|
|
||||||
|
|
||||||
if (remainingTicks[0] <= 0) {
|
|
||||||
this.getPlayers().forEach(player -> {
|
|
||||||
player.setExp(0f);
|
|
||||||
player.setLevel(0);
|
|
||||||
});
|
|
||||||
return stop;
|
|
||||||
}
|
|
||||||
|
|
||||||
float progress = (float) remainingTicks[0] / totalTicks;
|
|
||||||
|
|
||||||
|
if (remainingTicks <= 0) {
|
||||||
this.getPlayers().forEach(player -> {
|
this.getPlayers().forEach(player -> {
|
||||||
player.setExp(progress);
|
player.setExp(0f);
|
||||||
player.setLevel((int) Math.ceil(remainingTicks[0] / 20.0));
|
player.setLevel(0);
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
remainingTicks[0]--;
|
float progress = (float) remainingTicks / totalTicks;
|
||||||
return TaskSchedule.tick(1);
|
|
||||||
|
this.getPlayers().forEach(player -> {
|
||||||
|
player.setExp(progress);
|
||||||
|
player.setLevel((int) Math.ceil(remainingTicks / 20.0));
|
||||||
|
});
|
||||||
|
scheduler.scheduleTask(() -> {
|
||||||
|
this.scheduleExpUpdate(scheduler, remainingTicks -1, totalTicks);
|
||||||
|
return TaskSchedule.stop();
|
||||||
}, TaskSchedule.tick(1));
|
}, TaskSchedule.tick(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user
andere Lösung für das effective-final wär schön
passt so?