Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SubscribeEvent
- public void onPlayerTick(TickEvent.PlayerTickEvent event) {
- PlayerEntity player = (PlayerEntity)event.player.getEntity();
- if (event.phase == TickEvent.Phase.END) {
- for (Runnable runnable : delayedTasks) {
- runnable.run();
- delayedTasks.clear();
- }
- }
- }
- static final List<Runnable> delayedTasks = new ArrayList<>();
- delayedTasks.add(() -> {
- for (PlayerEntity players : player.getServer().getPlayerList().getPlayers()) {
- int lives = (int) (10 - (player.getMaxHealth() / 2));
- if (lives >= 2) {
- players.sendMessage(HealthMessages.getRemainingLives(player, player.getScoreboardName() + " has " + lives + "
- lives remaining . . ."), player.getUniqueID());
- } else if (lives == 1) {
- players.sendMessage(HealthMessages.getRemainingLives(player, player.getScoreboardName() + " has one life
- remaining!"), player.getUniqueID());
- } else {
- players.sendMessage(HealthMessages.getRemainingLives(player, player.getScoreboardName() + " has been
- eliminated!"), player.getUniqueID());
- }
- }
- });
Add Comment
Please, Sign In to add comment