multi-string errors when skipping

This commit is contained in:
G Krupa 2014-07-12 01:36:24 -07:00
parent f4c4f3895b
commit 0e1100f812

View File

@ -2312,8 +2312,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (location != null) { if (location != null) {
quest.blockStart = location; quest.blockStart = location;
} else { } else {
printSevere("[Quests] block-start: for Quest " + quest.name + " is not in proper location format!"); skipQuestProcess(new String[]{
skipQuestProcess("[Quests] Proper location format is: \"WorldName x y z\""); "[Quests] block-start: for Quest " + quest.name + " is not in proper location format!",
"[Quests] Proper location format is: \"WorldName x y z\""});
} }
} }
@ -2468,8 +2469,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (failed) { if (failed) {
printSevere("[Quests] " + PINK + failedQuest + " inside quests: Requirement for Quest " + quest.name + " is not a valid Quest name!"); skipQuestProcess(new String[]{
skipQuestProcess("Make sure you are using the Quest name: value, and not the block name."); "[Quests] " + PINK + failedQuest + " inside quests: Requirement for Quest " + quest.name + " is not a valid Quest name!",
"Make sure you are using the Quest name: value, and not the block name."});
} }
} else { } else {
@ -2509,8 +2511,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (failed) { if (failed) {
printSevere("[Quests] " + failedQuest + " inside quests: Requirement for Quest " + quest.name + " is not a valid Quest name!"); skipQuestProcess(new String[]{
skipQuestProcess("Make sure you are using the Quest name: value, and not the block name."); "[Quests] " + failedQuest + " inside quests: Requirement for Quest " + quest.name + " is not a valid Quest name!",
"Make sure you are using the Quest name: value, and not the block name."});
} }
} else { } else {
@ -2607,7 +2610,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (!found) { if (!found) {
printWarning("[Quests] Custom requirement \"" + name + "\" for Quest \"" + quest.name + "\" could not be found!"); printWarning("[Quests] Custom requirement \"" + name + "\" for Quest \"" + quest.name + "\" could not be found!");
skipQuestProcess(null); skipQuestProcess((String)null); // null bc we warn, not severe for this one
} }
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
@ -2833,11 +2836,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} // for() } // for()
} }
private void skipQuestProcess(String msg) throws SkipQuest { private void skipQuestProcess(String[] msgs) throws SkipQuest {
for (String msg : msgs) {
if (msg != null) {
printSevere(msg); printSevere(msg);
}
}
throw new SkipQuest(); throw new SkipQuest();
} }
private void skipQuestProcess(String msg) throws SkipQuest {
skipQuestProcess(new String[]{msg});
}
private void populateCustomRewards(FileConfiguration config) { private void populateCustomRewards(FileConfiguration config) {
ConfigurationSection sec = config.getConfigurationSection("quests." + questName + ".rewards.custom-rewards"); ConfigurationSection sec = config.getConfigurationSection("quests." + questName + ".rewards.custom-rewards");
for (String path : sec.getKeys(false)) { for (String path : sec.getKeys(false)) {
@ -3367,8 +3378,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
y = Double.parseDouble(info[2]); y = Double.parseDouble(info[2]);
z = Double.parseDouble(info[3]); z = Double.parseDouble(info[3]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
printSevere("[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!"); stageFailed(new String[]{
stageFailed("[Quests] Proper location format is: \"WorldName x y z\""); "[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!",
"[Quests] Proper location format is: \"WorldName x y z\""});
} }
if (getServer().getWorld(info[0]) != null) { if (getServer().getWorld(info[0]) != null) {
@ -3379,8 +3391,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} else { } else {
printSevere("[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!"); stageFailed(new String[]{
stageFailed("[Quests] Proper location format is: \"WorldName x y z\""); "[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!",
"[Quests] Proper location format is: \"WorldName x y z\""});
} }
} }
@ -3479,8 +3492,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
y = Double.parseDouble(info[2]); y = Double.parseDouble(info[2]);
z = Double.parseDouble(info[3]); z = Double.parseDouble(info[3]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
printSevere("[Quests] " + loc + " inside locations-to-reach: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!"); stageFailed(new String[]{
stageFailed("[Quests] Proper location format is: \"WorldName x y z\""); "[Quests] " + loc + " inside locations-to-reach: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!",
"[Quests] Proper location format is: \"WorldName x y z\""});
} }
if (getServer().getWorld(info[0]) != null) { if (getServer().getWorld(info[0]) != null) {
@ -3491,8 +3505,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} else { } else {
printSevere("[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!"); stageFailed(new String[]{
stageFailed("[Quests] Proper location format is: \"WorldName x y z\""); "[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!",
"[Quests] Proper location format is: \"WorldName x y z\""});
} }
} }
@ -3912,13 +3927,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} }
private void throwStageFailed() throws StageFailedException { private void stageFailed(String msg) throws StageFailedException {
throw new StageFailedException(); stageFailed(new String[]{msg});
} }
private void stageFailed(String msg) throws StageFailedException { private void stageFailed(String[] msgs) throws StageFailedException {
for (String msg : msgs) {
if (msg != null) {
printSevere(msg); printSevere(msg);
throwStageFailed(); }
}
throw new StageFailedException();
} }
public void loadEvents() { public void loadEvents() {