diff --git a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ActionBarSign.java b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ActionBarSign.java index 38f4fbd2..ac3b8e92 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ActionBarSign.java +++ b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ActionBarSign.java @@ -43,9 +43,8 @@ public class ActionBarSign extends MessageSign { } @Override - public boolean push(Player player) { + public void sendMessage(Player player) { MessageUtil.sendActionBarMessage(player, text); - return true; } } diff --git a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ChatMessageSign.java b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ChatMessageSign.java index b47caeda..6666671d 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ChatMessageSign.java +++ b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ChatMessageSign.java @@ -20,8 +20,6 @@ import de.erethon.commons.chat.MessageUtil; import de.erethon.dungeonsxl.api.DungeonsAPI; import de.erethon.dungeonsxl.api.world.InstanceWorld; import de.erethon.dungeonsxl.player.DPermission; -import java.util.ArrayList; -import java.util.List; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -30,8 +28,6 @@ import org.bukkit.entity.Player; */ public class ChatMessageSign extends MessageSign { - private List done = new ArrayList<>(); - public ChatMessageSign(DungeonsAPI api, Sign sign, String[] lines, InstanceWorld instance) { super(api, sign, lines, instance); } @@ -47,25 +43,8 @@ public class ChatMessageSign extends MessageSign { } @Override - public boolean push(Player player) { - if (!done.contains(player)) { - MessageUtil.sendMessage(player, text); - done.add(player); - } - - if (done.size() >= getGameWorld().getWorld().getPlayers().size()) { - getGameWorld().removeDungeonSign(this); - } - - return true; - } - - @Override - public void push() { - for (Player player : getGameWorld().getWorld().getPlayers()) { - MessageUtil.sendMessage(player, text); - } - getGameWorld().removeDungeonSign(this); + public void sendMessage(Player player) { + MessageUtil.sendMessage(player, text); } } diff --git a/core/src/main/java/de/erethon/dungeonsxl/sign/button/MessageSign.java b/core/src/main/java/de/erethon/dungeonsxl/sign/button/MessageSign.java index a8e13669..3d3c2e71 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/sign/button/MessageSign.java +++ b/core/src/main/java/de/erethon/dungeonsxl/sign/button/MessageSign.java @@ -21,14 +21,18 @@ import de.erethon.dungeonsxl.api.DungeonsAPI; import de.erethon.dungeonsxl.api.dungeon.GameRule; import de.erethon.dungeonsxl.api.sign.Button; import de.erethon.dungeonsxl.api.world.InstanceWorld; +import java.util.ArrayList; +import java.util.List; import org.bukkit.block.Sign; +import org.bukkit.entity.Player; /** * @author Daniel Saukel */ public abstract class MessageSign extends Button { - protected String text; + protected String text = "UNKNOWN MESSAGE"; + private List done = new ArrayList<>(); public MessageSign(DungeonsAPI api, Sign sign, String[] lines, InstanceWorld instance) { super(api, sign, lines, instance); @@ -67,7 +71,33 @@ public abstract class MessageSign extends Button { String text = getGameWorld().getDungeon().getRules().getState(GameRule.MESSAGES).get(NumberUtil.parseInt(getLine(1))); if (text != null) { this.text = text; + } else { + markAsErroneous("Unknown message, ID: " + getLine(1)); } } + @Override + public boolean push(Player player) { + if (!done.contains(player)) { + sendMessage(player); + done.add(player); + } + + if (done.size() >= getGameWorld().getWorld().getPlayers().size()) { + getGameWorld().removeDungeonSign(this); + } + + return true; + } + + @Override + public void push() { + for (Player player : getGameWorld().getWorld().getPlayers()) { + sendMessage(player); + } + getGameWorld().removeDungeonSign(this); + } + + public abstract void sendMessage(Player player); + } diff --git a/core/src/main/java/de/erethon/dungeonsxl/sign/button/TitleSign.java b/core/src/main/java/de/erethon/dungeonsxl/sign/button/TitleSign.java index 66496b77..0ee4cca1 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/sign/button/TitleSign.java +++ b/core/src/main/java/de/erethon/dungeonsxl/sign/button/TitleSign.java @@ -55,11 +55,16 @@ public class TitleSign extends MessageSign { int id0 = NumberUtil.parseInt(line1[0], -1); title = messages.get(id0); if (title == null) { - title = ""; + markAsErroneous("Unknown message, ID: " + getLine(1)); + return; } if (line1.length > 1) { int id1 = NumberUtil.parseInt(line1[1], -1); subtitle = messages.get(id1); + if (subtitle == null) { + markAsErroneous("Unknown message, ID: " + getLine(1)); + return; + } } if (subtitle == null) { subtitle = ""; @@ -78,9 +83,8 @@ public class TitleSign extends MessageSign { } @Override - public boolean push(Player player) { + public void sendMessage(Player player) { MessageUtil.sendTitleMessage(player, title, subtitle, fadeIn, stay, fadeOut); - return true; } }