Skip to content

Commit

Permalink
#61: Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed May 11, 2016
1 parent ee23253 commit 01cfaaf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/github/dre2n/dungeonsxl/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ public void fetchRules() {
finalRules.apply(type);
}

if (dungeonConfig != null) {
if (dungeonConfig != null && dungeonConfig.getOverrideValues() != null) {
finalRules.apply(dungeonConfig.getOverrideValues());
}

if (floorConfig != null) {
finalRules.apply(floorConfig);
}

if (dungeonConfig != null) {
if (dungeonConfig != null && dungeonConfig.getDefaultValues() != null) {
finalRules.apply(dungeonConfig.getDefaultValues());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ public void respawn() {
}

// Respawn Items
if (Game.getByWorld(getWorld()).getRules().getKeepInventoryOnDeath()) {
Game game = Game.getByWorld(getWorld());

if (game != null && game.getRules().getKeepInventoryOnDeath()) {
applyRespawnInventory();
}
}
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ public void startGame(Game game) {
if (game == null) {
return;
}
game.fetchRules();

for (DGroup dGroup : game.getDGroups()) {
if (dGroup == null) {
Expand Down Expand Up @@ -516,31 +517,30 @@ public void startGame(Game game) {
}
}

GameRules rules = gameWorld.getGame().getRules();
if (rules != null) {
for (Requirement requirement : rules.getRequirements()) {
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
plugin.getServer().getPluginManager().callEvent(event);
GameRules rules = game.getRules();

if (requirementDemandEvent.isCancelled()) {
continue;
}
for (Requirement requirement : rules.getRequirements()) {
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
plugin.getServer().getPluginManager().callEvent(event);

requirement.demand(player);
if (requirementDemandEvent.isCancelled()) {
continue;
}

GameType gameType = game.getType();
if (gameType == GameTypeDefault.DEFAULT) {
player.setGameMode(rules.getGameMode());
if (rules.isTimeIsRunning()) {
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
}
requirement.demand(player);
}

} else {
player.setGameMode(gameType.getGameMode());
if (gameType.getShowTime()) {
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
}
GameType gameType = game.getType();
if (gameType == GameTypeDefault.DEFAULT) {
player.setGameMode(rules.getGameMode());
if (rules.isTimeIsRunning()) {
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
}

} else {
player.setGameMode(gameType.getGameMode());
if (gameType.getShowTime()) {
timeIsRunningTask = new TimeIsRunningTask(this, rules.getTimeToFinish()).runTaskTimer(plugin, 20, 20);
}
}

Expand Down

0 comments on commit 01cfaaf

Please sign in to comment.