mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Improve message signs
This commit is contained in:
parent
3d19e30287
commit
0212a865f8
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<Player> 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()) {
|
||||
public void sendMessage(Player player) {
|
||||
MessageUtil.sendMessage(player, text);
|
||||
}
|
||||
getGameWorld().removeDungeonSign(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<Player> 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);
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user