Fill in ALL durability values when adding multiple items, fixes #58

This commit is contained in:
HappyPikachu 2017-07-19 10:30:07 -04:00
parent 038c3dc86f
commit 7c752674e1
2 changed files with 51 additions and 34 deletions

View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId> <groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId> <artifactId>quests</artifactId>
<version>2.9.1</version> <version>2.9.2</version>
<name>quests</name> <name>quests</name>
<url>https://github.com/FlyingPikachu/Quests/</url> <url>https://github.com/FlyingPikachu/Quests/</url>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

@ -626,11 +626,17 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0; two = 0;
} }
if (one == two) { if (one == two) {
if (context.getSessionData(pref + CK.S_BREAK_DURABILITY) == null) { int missing;
LinkedList<Integer> noEntry = new LinkedList<Integer>(); if (context.getSessionData(pref + CK.S_BREAK_DURABILITY) != null) {
noEntry.add(0); missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_BREAK_DURABILITY)).size();
context.setSessionData(pref + CK.S_BREAK_DURABILITY, noEntry); } else {
missing = one;
} }
LinkedList<Integer> noEntry = new LinkedList<Integer>();
for (int i = 0; i < missing; i++) {
noEntry.add(0);
}
context.setSessionData(pref + CK.S_BREAK_DURABILITY, noEntry);
return new CreateStagePrompt(stageNum, questFactory, citizens); return new CreateStagePrompt(stageNum, questFactory, citizens);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize"));
@ -835,14 +841,17 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0; two = 0;
} }
if (one == two) { if (one == two) {
if (context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) == null) { int missing;
LinkedList<Integer> noEntry = new LinkedList<Integer>(); if (context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) != null) {
noEntry.add(0); missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY)).size();
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, noEntry);
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize")); missing = one;
}
LinkedList<Integer> noEntry = new LinkedList<Integer>();
for (int i = 0; i < missing; i++) {
noEntry.add(0);
}
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, noEntry);
return new DamageBlockListPrompt(); return new DamageBlockListPrompt();
} }
} }
@ -1044,14 +1053,17 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0; two = 0;
} }
if (one == two) { if (one == two) {
if (context.getSessionData(pref + CK.S_PLACE_DURABILITY) == null) { int missing;
LinkedList<Integer> noEntry = new LinkedList<Integer>(); if (context.getSessionData(pref + CK.S_PLACE_DURABILITY) != null) {
noEntry.add(0); missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_PLACE_DURABILITY)).size();
context.setSessionData(pref + CK.S_PLACE_DURABILITY, noEntry);
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize")); missing = one;
}
LinkedList<Integer> noEntry = new LinkedList<Integer>();
for (int i = 0; i < missing; i++) {
noEntry.add(0);
}
context.setSessionData(pref + CK.S_PLACE_DURABILITY, noEntry);
return new PlaceBlockListPrompt(); return new PlaceBlockListPrompt();
} }
} }
@ -1253,15 +1265,17 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0; two = 0;
} }
if (one == two) { if (one == two) {
if (context.getSessionData(pref + CK.S_USE_DURABILITY) == null) { int missing;
LinkedList<Integer> noEntry = new LinkedList<Integer>(); if (context.getSessionData(pref + CK.S_USE_DURABILITY) != null) {
noEntry.add(0); missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_USE_DURABILITY)).size();
context.setSessionData(pref + CK.S_USE_DURABILITY, noEntry);
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize")); missing = one;
return new UseBlockListPrompt(); }
LinkedList<Integer> noEntry = new LinkedList<Integer>();
for (int i = 0; i < missing; i++) {
noEntry.add(0);
}
context.setSessionData(pref + CK.S_USE_DURABILITY, noEntry);
} }
} }
return null; return null;
@ -1462,14 +1476,17 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0; two = 0;
} }
if (one == two) { if (one == two) {
if (context.getSessionData(pref + CK.S_CUT_DURABILITY) == null) { int missing;
LinkedList<Integer> noEntry = new LinkedList<Integer>(); if (context.getSessionData(pref + CK.S_CUT_DURABILITY) != null) {
noEntry.add(0); missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_CUT_DURABILITY)).size();
context.setSessionData(pref + CK.S_CUT_DURABILITY, noEntry);
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize")); missing = one;
}
LinkedList<Integer> noEntry = new LinkedList<Integer>();
for (int i = 0; i < missing; i++) {
noEntry.add(0);
}
context.setSessionData(pref + CK.S_CUT_DURABILITY, noEntry);
return new CutBlockListPrompt(); return new CutBlockListPrompt();
} }
} }