Send error message when a player joins a game world without a ready sign

This commit is contained in:
Daniel Saukel 2020-04-01 19:56:29 +02:00
parent 2574a06b87
commit 432976712c
7 changed files with 28 additions and 8 deletions

View File

@ -117,6 +117,7 @@ public enum DMessage implements Message {
ERROR_NO_LEAVE_IN_TUTORIAL("error.noLeaveInTutorial"),
ERROR_NO_PERMISSIONS("error.noPermissions"),
ERROR_NO_PROTECTED_BLOCK("error.noProtectedBlock"),
ERROR_NO_READY_SIGN("error.noReadySign"),
ERROR_NO_REWARDS_TIME("error.noRewardsTime"),
ERROR_NO_SUCH_DUNGEON("error.noSuchDungeon"),
ERROR_NO_SUCH_GROUP("error.noSuchGroup"),

View File

@ -112,6 +112,10 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
} else {
PlayerUtil.secureTeleport(player, teleport);
}
if (!((DGameWorld) world).hasReadySign()) {
MessageUtil.sendMessage(player, DMessage.ERROR_NO_READY_SIGN.getMessage(world.getName()));
}
}
/* Getters and setters */

View File

@ -103,6 +103,8 @@ public class ReadySign extends Button {
getSign().setLine(2, "");
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
((DGameWorld) getGameWorld()).setReadySign(this);
}
@Override

View File

@ -33,7 +33,7 @@ import de.erethon.dungeonsxl.api.world.GameWorld;
import de.erethon.dungeonsxl.dungeon.DGame;
import de.erethon.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
import de.erethon.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
import de.erethon.dungeonsxl.sign.LocationSign;
import de.erethon.dungeonsxl.sign.button.ReadySign;
import de.erethon.dungeonsxl.sign.passive.StartSign;
import de.erethon.dungeonsxl.sign.windup.MobSign;
import de.erethon.dungeonsxl.trigger.FortuneTrigger;
@ -94,6 +94,8 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
private List<DungeonMob> mobs = new ArrayList<>();
private List<Trigger> triggers = new ArrayList<>();
private boolean readySign;
DGameWorld(DungeonsXL plugin, DResourceWorld resourceWorld, File folder, World world, int id) {
super(plugin, resourceWorld, folder, world, id);
caliburn = plugin.getCaliburn();
@ -132,19 +134,19 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
int index = getGame().getGroups().indexOf(dGroup);
// Try the matching location
StartSign anyStartSign = null;
for (DungeonSign sign : getDungeonSigns()) {
if (sign instanceof StartSign) {
if (((StartSign) sign).getId() == index) {
return ((LocationSign) sign).getLocation();
anyStartSign = (StartSign) sign;
if (anyStartSign.getId() == index) {
return anyStartSign.getLocation();
}
}
}
// Try any location
for (DungeonSign sign : getDungeonSigns()) {
if (sign instanceof StartSign) {
return ((LocationSign) sign).getLocation();
}
// Try any start sign
if (anyStartSign != null) {
return anyStartSign.getLocation();
}
// Lobby location as fallback
@ -389,6 +391,14 @@ public class DGameWorld extends DInstanceWorld implements GameWorld {
return null;
}
public boolean hasReadySign() {
return readySign;
}
public void setReadySign(ReadySign readySign) {
this.readySign = readySign != null;
}
/**
* Set up the instance for the game
*/

View File

@ -127,6 +127,7 @@ error:
noLeaveInTutorial: "&4You cannot use this command in the tutorial."
noPermissions: "&4You do not have permission to do this."
noProtectedBlock: "&4This is not a block protected by DungeonsXL."
noReadySign: "&4The world &6&v1 &4does not seem to have a ready sign. No game can be started and only lobby dungeon signs will be initialized."
noRewardsTime: "&4You cannot receive rewards before &6&v1&4."
noSuchDungeon: "&4This dungeon does not exist."
noSuchGroup: "&4The group &6&v1&4 does not exist."

View File

@ -127,6 +127,7 @@ error:
noLeaveInTutorial: "&4Vous ne pouvez utiliser cette commande dans le tutoriel."
noPermissions: "&4Vous n'avez pas la permission de faire ça."
noProtectedBlock: "&4Ce n'est pas un bloc protégé par DungeonsXL."
noReadySign: "&4La carte &6&v1 &4n'a pas de panneau \"ready\". On ne peut pas commencer des jeus et les panneaux de lobby ne sont que initialisés."
noRewardsTime: "&4Vous ne pouvez pas recevoir de récompense avant &6&v1&4."
noSuchDungeon: "&4Le donjon &6&v1&4 n'existe pas."
noSuchGroup: "&4Le groupe &6&v1&4 n'existe pas."

View File

@ -127,6 +127,7 @@ error:
noLeaveInTutorial: "&4Du kannst diesen Befehl im Tutorial nicht benutzen."
noPermissions: "&4Du hast nicht die nötigen Berechtigungen, um das zu tun."
noProtectedBlock: "&4Das ist kein von DungeonsXL geschützter Block."
noReadySign: "&4Die Welt &6&v1 &4hat kein Ready-Schild. Spiele können nicht begonnen werden und nur Lobby-Schilder werden geladen."
noRewardsTime: "&4Du kannst vor &6&v1&4 keine Belohnungen bekommen."
noSuchDungeon: "&4Dieser Dungeon existiert nicht."
noSuchGroup: "&4Die Gruppe &6&v1&4 gibt es nicht."