diff --git a/api/src/main/java/de/erethon/dungeonsxl/api/world/ResourceWorld.java b/api/src/main/java/de/erethon/dungeonsxl/api/world/ResourceWorld.java index 289b3883..ebbd6213 100644 --- a/api/src/main/java/de/erethon/dungeonsxl/api/world/ResourceWorld.java +++ b/api/src/main/java/de/erethon/dungeonsxl/api/world/ResourceWorld.java @@ -15,6 +15,7 @@ package de.erethon.dungeonsxl.api.world; import de.erethon.dungeonsxl.api.dungeon.Dungeon; +import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; import java.io.File; import org.bukkit.OfflinePlayer; @@ -120,22 +121,11 @@ public interface ResourceWorld { * Returns a new game instance of this resource. * * @see de.erethon.dungeonsxl.api.dungeon.Game#ensureWorldIsLoaded(boolean) + * @param game the game the instance belongs to * @param ignoreLimit if the instance limit set in the main config shall be ignored * @return a new game instance of this resource */ - default GameWorld instantiateGameWorld(boolean ignoreLimit) { - return instantiateGameWorld(getSingleFloorDungeon(), ignoreLimit); - } - - /** - * Returns a new game instance of this resource. - * - * @see de.erethon.dungeonsxl.api.dungeon.Game#ensureWorldIsLoaded(boolean) - * @param dungeon the dungeon this game world will be part of - * @param ignoreLimit if the instance limit set in the main config shall be ignored - * @return a new game instance of this resource - */ - GameWorld instantiateGameWorld(Dungeon dungeon, boolean ignoreLimit); + GameWorld instantiateGameWorld(Game game, boolean ignoreLimit); /** * Returns the single floor dungeon of this resource. diff --git a/core/src/main/java/de/erethon/dungeonsxl/dungeon/DGame.java b/core/src/main/java/de/erethon/dungeonsxl/dungeon/DGame.java index 32386746..48e8cad2 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/dungeon/DGame.java +++ b/core/src/main/java/de/erethon/dungeonsxl/dungeon/DGame.java @@ -291,7 +291,7 @@ public class DGame implements Game { if (world != null) { return world; } - world = dungeon.getMap().instantiateGameWorld(dungeon, ignoreLimit); + world = dungeon.getMap().instantiateGameWorld(this, ignoreLimit); return world; } @@ -305,6 +305,7 @@ public class DGame implements Game { continue; } if (!((DGroup) group).startGame(this, i++)) { + plugin.log("Could not start game for group " + group); return false; // TODO: State of groups that are OK has already been changed } } diff --git a/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java b/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java index 1103e809..d5b81e97 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java +++ b/core/src/main/java/de/erethon/dungeonsxl/player/DGamePlayer.java @@ -510,14 +510,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer { } ready = true; - - boolean start = true; - if (!game.start()) {// TODO: Start for every player??? - start = false; - } else { - respawn(); - } - return start; + return ready; } @Override diff --git a/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java b/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java index 9d1f3822..a1e1beb8 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java +++ b/core/src/main/java/de/erethon/dungeonsxl/player/DGroup.java @@ -515,7 +515,7 @@ public class DGroup implements PlayerGroup { return; } - GameWorld gameWorld = newFloor.instantiateGameWorld(true); + GameWorld gameWorld = newFloor.instantiateGameWorld(getGame(), true); gameWorld.setType(type); game.setWorld(gameWorld); @@ -561,7 +561,6 @@ public class DGroup implements PlayerGroup { color = plugin.getMainConfig().getGroupColorPriority(index); } - boolean ready = true; for (Player player : getMembers().getOnlinePlayers()) { GamePlayer gamePlayer = plugin.getPlayerCache().getGamePlayer(player); if (gamePlayer == null) { @@ -569,14 +568,10 @@ public class DGroup implements PlayerGroup { } if (!gamePlayer.isReady()) { - ready = false; + return false; } } - if (!ready) { - return false; - } - GroupStartFloorEvent event = new GroupStartFloorEvent(this, getGameWorld()); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java index 5226e140..71e1b2c6 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java +++ b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java @@ -170,8 +170,11 @@ public class ReadySign extends Button { boolean wasReady = player.isReady(); if (!getGameWorld().areClassesEnabled() || player.getPlayerClass() != null) { - if (player.ready() && bar != null) { - bar.cancel(); + if (player.ready()) { + getGame().start(); + if (bar != null) { + bar.cancel(); + } } } diff --git a/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java b/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java index e3727146..7e13eed5 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java +++ b/core/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java @@ -233,14 +233,14 @@ public class DResourceWorld implements ResourceWorld { } @Override - public GameWorld instantiateGameWorld(Dungeon dungeon, boolean ignoreLimit) { + public GameWorld instantiateGameWorld(Game game, boolean ignoreLimit) { if (plugin.isLoadingWorld()) { return null; } if (!ignoreLimit && plugin.getMainConfig().getMaxInstances() <= plugin.getInstanceCache().size()) { return null; } - return (DGameWorld) instantiate(new DGame(plugin, dungeon)); + return (DGameWorld) instantiate(game); } @Override