From 70b4d16be58f5c94bb25c2bf57dce04d47be7584 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Wed, 11 May 2016 15:11:42 +0200 Subject: [PATCH] #61: Some fixes --- .../io/github/dre2n/dungeonsxl/game/Game.java | 4 +- .../dre2n/dungeonsxl/player/DGamePlayer.java | 4 +- .../dre2n/dungeonsxl/player/DGroup.java | 40 +++++++++---------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java b/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java index 320c1778..abb97ef3 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/game/Game.java @@ -195,7 +195,7 @@ public class Game { finalRules.apply(type); } - if (dungeonConfig != null) { + if (dungeonConfig != null && dungeonConfig.getOverrideValues() != null) { finalRules.apply(dungeonConfig.getOverrideValues()); } @@ -203,7 +203,7 @@ public class Game { finalRules.apply(floorConfig); } - if (dungeonConfig != null) { + if (dungeonConfig != null && dungeonConfig.getDefaultValues() != null) { finalRules.apply(dungeonConfig.getDefaultValues()); } diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java index cea1086d..8628b5a1 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java @@ -520,7 +520,9 @@ public class DGamePlayer extends DInstancePlayer { } // Respawn Items - if (Game.getByWorld(getWorld()).getRules().getKeepInventoryOnDeath()) { + Game game = Game.getByWorld(getWorld()); + + if (game != null && game.getRules().getKeepInventoryOnDeath()) { applyRespawnInventory(); } } diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java index af033d43..4deff62d 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DGroup.java @@ -464,6 +464,7 @@ public class DGroup { if (game == null) { return; } + game.fetchRules(); for (DGroup dGroup : game.getDGroups()) { if (dGroup == null) { @@ -521,31 +522,30 @@ public class DGroup { } } - 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); } }