mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-02 17:00:19 +01:00
Fix getting game from group; resolves #896
This commit is contained in:
parent
7e79b52091
commit
6bedccb29f
@ -287,9 +287,7 @@ public interface PlayerGroup {
|
||||
*
|
||||
* @return the game of the game world the group is in.
|
||||
*/
|
||||
default Game getGame() {
|
||||
return getGameWorld() != null ? getGameWorld().getGame() : null;
|
||||
}
|
||||
Game getGame();
|
||||
|
||||
/**
|
||||
* Returns the game world the group is in.
|
||||
|
@ -63,11 +63,7 @@ public class DGame implements Game {
|
||||
tutorial = false;
|
||||
started = false;
|
||||
|
||||
groups.add(group);
|
||||
group.setGameWorld(world);
|
||||
group.setInitialLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
||||
group.setLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
||||
group.setScore(getRules().getState(GameRule.INITIAL_SCORE));
|
||||
addGroup(group);
|
||||
}
|
||||
|
||||
public DGame(DungeonsXL plugin, PlayerGroup group, GameWorld world) {
|
||||
@ -112,6 +108,7 @@ public class DGame implements Game {
|
||||
public void addGroup(PlayerGroup group) {
|
||||
groups.add(group);
|
||||
|
||||
((DGroup) group).setGame(this);
|
||||
group.setGameWorld(world);
|
||||
group.setInitialLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
||||
group.setLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
||||
|
@ -74,6 +74,7 @@ public class DGroup implements PlayerGroup {
|
||||
private PlayerCollection invitedPlayers = new PlayerCollection();
|
||||
private Dungeon dungeon;
|
||||
private List<ResourceWorld> unplayedFloors = new ArrayList<>();
|
||||
private Game game;
|
||||
private GameWorld gameWorld;
|
||||
private boolean playing;
|
||||
private int floorCount;
|
||||
@ -334,6 +335,18 @@ public class DGroup implements PlayerGroup {
|
||||
this.gameWorld = gameWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game getGame() {
|
||||
if (game == null && gameWorld != null) {
|
||||
game = gameWorld.getGame();
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
||||
public void setGame(Game game) {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dungeon getDungeon() {
|
||||
return dungeon;
|
||||
|
Loading…
Reference in New Issue
Block a user