From 0f38b9c89925771c04447e62412e669a661c964b Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 24 Jan 2020 17:27:37 +0100 Subject: [PATCH] More PlayerGroup APIs --- .../dungeonsxl/api/player/PlayerGroup.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java b/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java index f415baf3..99997480 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/player/PlayerGroup.java @@ -16,6 +16,7 @@ package de.erethon.dungeonsxl.api.player; import de.erethon.caliburn.item.ExItem; import de.erethon.caliburn.item.VanillaItem; +import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.compatibility.Version; import de.erethon.commons.player.PlayerCollection; import de.erethon.dungeonsxl.api.dungeon.Dungeon; @@ -308,6 +309,22 @@ public interface PlayerGroup { */ boolean isPlaying(); + /** + * Returns the initial amount of lives or -1 if group lives are not used. + * + * @return the initial amount of lives or -1 if group lives are not used + */ + int getInitialLives(); + + /** + * Sets the initial amount of lives. + *

+ * The value must be >=0 or -1, which means unlimited lives. + * + * @param lives the new amount of lives known as the initial amount + */ + void setInitialLives(int lives); + /** * Returns the amount of lives the group currently has left or -1 if group lives are not used. * @@ -324,4 +341,32 @@ public interface PlayerGroup { */ void setLives(int lives); + /** + * Disbands the group. + */ + void delete(); + + /** + * Sends a message to all players in the group. + *

+ * Supports color codes. + * + * @param message the message to sent + * @param except Players who shall not receive the message + */ + default void sendMessage(String message, Player... except) { + members: + for (Player player : getMembers().getOnlinePlayers()) { + if (!player.isOnline()) { + continue; + } + for (Player nope : except) { + if (player == nope) { + continue members; + } + } + MessageUtil.sendMessage(player, message); + } + } + }