diff --git a/src/main/java/de/erethon/dungeonsxl/global/GameSign.java b/src/main/java/de/erethon/dungeonsxl/global/GameSign.java index 723fa146..45812f67 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/GameSign.java +++ b/src/main/java/de/erethon/dungeonsxl/global/GameSign.java @@ -16,8 +16,6 @@ */ package de.erethon.dungeonsxl.global; -import com.griefcraft.lwc.LWC; -import com.griefcraft.model.Protection; import de.erethon.caliburn.category.Category; import de.erethon.caliburn.item.VanillaItem; import de.erethon.commons.chat.MessageUtil; @@ -122,39 +120,46 @@ public class GameSign extends JoinSign { config.set(preString + ".x", startSign.getX()); config.set(preString + ".y", startSign.getY()); config.set(preString + ".z", startSign.getZ()); - config.set(preString + ".dungeon", dungeon.getName()); + if (dungeon != null) { + config.set(preString + ".dungeon", dungeon.getName()); + } config.set(preString + ".maxGroupsPerGame", maxElements); } - public boolean onPlayerInteract(Block block, Player player) { + public void onPlayerInteract(Block block, Player player) { if (DungeonsXL.getInstance().getDWorlds().getGameWorlds().size() >= DungeonsXL.getInstance().getMainConfig().getMaxInstances()) { MessageUtil.sendMessage(player, DMessage.ERROR_TOO_MANY_INSTANCES.getMessage()); - return true; + return; } DGroup dGroup = DGroup.getByPlayer(player); if (dGroup == null) { MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage()); - return true; + return; } if (!dGroup.getCaptain().equals(player)) { MessageUtil.sendMessage(player, DMessage.ERROR_NOT_CAPTAIN.getMessage()); - return true; + return; } if (Game.getByDGroup(dGroup) != null) { MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GAME.getMessage()); - return true; + return; } Block topBlock = block.getRelative(0, startSign.getY() - block.getY(), 0); if (!(topBlock.getState() instanceof Sign)) { - return true; + return; } Sign topSign = (Sign) topBlock.getState(); if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_NEW_GAME.getMessage())) { + if (dungeon == null) { + MessageUtil.sendMessage(player, DMessage.ERROR_SIGN_WRONG_FORMAT.getMessage()); + return; + } + game = new Game(dGroup); dGroup.setDungeon(dungeon); update(); @@ -163,8 +168,6 @@ public class GameSign extends JoinSign { game.addDGroup(dGroup); update(); } - - return true; } /* Statics */ diff --git a/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java b/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java index e347e904..4a0c96cc 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java +++ b/src/main/java/de/erethon/dungeonsxl/global/GlobalProtectionListener.java @@ -192,8 +192,6 @@ public class GlobalProtectionListener implements Listener { } } - /* SUBJECT TO CHANGE */ - @Deprecated @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); @@ -207,12 +205,14 @@ public class GlobalProtectionListener implements Listener { if (Category.SIGNS.containsBlock(clickedBlock)) { GroupSign groupSign = GroupSign.getByBlock(clickedBlock); - if (groupSign != null && groupSign.onPlayerInteract(clickedBlock, player)) { + if (groupSign != null) { + groupSign.onPlayerInteract(clickedBlock, player); event.setCancelled(true); } GameSign gameSign = GameSign.getByBlock(clickedBlock); - if (gameSign != null && gameSign.onPlayerInteract(clickedBlock, player)) { + if (gameSign != null) { + gameSign.onPlayerInteract(clickedBlock, player); event.setCancelled(true); } diff --git a/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java b/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java index fa2c578a..b861305e 100644 --- a/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java +++ b/src/main/java/de/erethon/dungeonsxl/global/GroupSign.java @@ -121,25 +121,32 @@ public class GroupSign extends JoinSign { config.set(preString + ".x", startSign.getX()); config.set(preString + ".y", startSign.getY()); config.set(preString + ".z", startSign.getZ()); - config.set(preString + ".dungeon", dungeon.getName()); + if (dungeon != null) { + config.set(preString + ".dungeon", dungeon.getName()); + } config.set(preString + ".groupName", groupName); config.set(preString + ".maxPlayersPerGroup", maxElements); } - public boolean onPlayerInteract(Block block, Player player) { + public void onPlayerInteract(Block block, Player player) { if (DGroup.getByPlayer(player) != null) { MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GROUP.getMessage()); - return true; + return; } Block topBlock = block.getRelative(0, startSign.getY() - block.getY(), 0); if (!(topBlock.getState() instanceof Sign)) { - return true; + return; } Sign topSign = (Sign) topBlock.getState(); if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_NEW_GROUP.getMessage())) { + if (dungeon == null) { + MessageUtil.sendMessage(player, DMessage.ERROR_SIGN_WRONG_FORMAT.getMessage()); + return; + } + if (groupName != null) { group = new DGroup(groupName, player, dungeon); } else { @@ -151,8 +158,6 @@ public class GroupSign extends JoinSign { group.addPlayer(player); update(); } - - return true; } /* Statics */