Merge branch 'no-quest-npe-fix' into 'master'

Fix a crash that occurred when no quests were available to load

See merge request core-developers/forge!959
This commit is contained in:
Michael Kamensky
2018-09-29 04:24:13 +00:00

View File

@@ -429,19 +429,25 @@ public class QuestController {
* Reset the duels manager. * Reset the duels manager.
*/ */
public void resetDuelsManager() { public void resetDuelsManager() {
QuestWorld world = getWorld(); QuestWorld world = getWorld();
String path; String path = ForgeConstants.DEFAULT_CHALLENGES_DIR;
if(world.getName().equals(QuestWorld.STANDARDWORLDNAME)){
this.duelManager = new QuestEventLDADuelManager(); if (world != null) {
return;
} if (world.getName().equals(QuestWorld.STANDARDWORLDNAME)) {
if (world == null || !world.isCustom()){ this.duelManager = new QuestEventLDADuelManager();
path = world == null || world.getDuelsDir() == null ? ForgeConstants.DEFAULT_DUELS_DIR : ForgeConstants.QUEST_WORLD_DIR + world.getDuelsDir(); return;
}else{ } else if (world.isCustom()) {
path = world == null || world.getDuelsDir() == null ? ForgeConstants.DEFAULT_DUELS_DIR : ForgeConstants.USER_QUEST_WORLD_DIR + world.getDuelsDir(); path = world.getDuelsDir() == null ? ForgeConstants.DEFAULT_DUELS_DIR : ForgeConstants.USER_QUEST_WORLD_DIR + world.getDuelsDir();
} else {
path = world.getDuelsDir() == null ? ForgeConstants.DEFAULT_DUELS_DIR : ForgeConstants.QUEST_WORLD_DIR + world.getDuelsDir();
}
} }
this.duelManager = new QuestEventDuelManager(new File(path)); this.duelManager = new QuestEventDuelManager(new File(path));
} }
public HashSet<StarRating> GetRating() { public HashSet<StarRating> GetRating() {
@@ -453,19 +459,25 @@ public class QuestController {
* Reset the challenges manager. * Reset the challenges manager.
*/ */
public void resetChallengesManager() { public void resetChallengesManager() {
QuestWorld world = getWorld(); QuestWorld world = getWorld();
String path; String path = ForgeConstants.DEFAULT_CHALLENGES_DIR;
if (world.getName().equals(QuestWorld.STANDARDWORLDNAME)){
allChallenges = QuestChallengeGenerator.generateChallenges(); if (world != null) {
return;
} if (world.getName().equals(QuestWorld.STANDARDWORLDNAME)) {
if (world == null || !world.isCustom()){ allChallenges = QuestChallengeGenerator.generateChallenges();
path = world == null || world.getChallengesDir() == null ? ForgeConstants.DEFAULT_CHALLENGES_DIR : ForgeConstants.QUEST_WORLD_DIR + world.getChallengesDir(); return;
}else{ } else if (world.isCustom()) {
path = world == null || world.getChallengesDir() == null ? ForgeConstants.DEFAULT_CHALLENGES_DIR : ForgeConstants.USER_QUEST_WORLD_DIR + world.getChallengesDir(); path = world.getChallengesDir() == null ? ForgeConstants.DEFAULT_CHALLENGES_DIR : ForgeConstants.QUEST_WORLD_DIR + world.getChallengesDir();
} else {
path = world.getChallengesDir() == null ? ForgeConstants.DEFAULT_CHALLENGES_DIR : ForgeConstants.USER_QUEST_WORLD_DIR + world.getChallengesDir();
}
} }
this.allChallenges = new StorageBase<QuestEventChallenge>("Quest Challenges", new QuestChallengeReader(new File(path)));
this.allChallenges = new StorageBase<>("Quest Challenges", new QuestChallengeReader(new File(path)));
} }
/** /**