Process durability as Short rather than Integer, fixes #76

This commit is contained in:
HappyPikachu 2017-07-26 20:40:26 -04:00
parent a326308d37
commit eae9461f7f
2 changed files with 70 additions and 70 deletions

View File

@ -1018,19 +1018,19 @@ public class QuestFactory implements ConversationAbandonedListener {
String pref;
LinkedList<Integer> breakIds;
LinkedList<Integer> breakAmounts;
LinkedList<Integer> breakDurability;
LinkedList<Short> breakDurability;
LinkedList<Integer> damageIds;
LinkedList<Integer> damageAmounts;
LinkedList<Integer> damageDurability;
LinkedList<Short> damageDurability;
LinkedList<Integer> placeIds;
LinkedList<Integer> placeAmounts;
LinkedList<Integer> placeDurability;
LinkedList<Short> placeDurability;
LinkedList<Integer> useIds;
LinkedList<Integer> useAmounts;
LinkedList<Integer> useDurability;
LinkedList<Short> useDurability;
LinkedList<Integer> cutIds;
LinkedList<Integer> cutAmounts;
LinkedList<Integer> cutDurability;
LinkedList<Short> cutDurability;
Integer fish;
Integer players;
LinkedList<String> enchantments;
@ -1132,27 +1132,27 @@ public class QuestFactory implements ConversationAbandonedListener {
if (cc.getSessionData(pref + CK.S_BREAK_NAMES) != null) {
breakIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_NAMES);
breakAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_AMOUNTS);
breakDurability = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_DURABILITY);
breakDurability = (LinkedList<Short>) cc.getSessionData(pref + CK.S_BREAK_DURABILITY);
}
if (cc.getSessionData(pref + CK.S_DAMAGE_NAMES) != null) {
damageIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_DAMAGE_NAMES);
damageAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS);
damageDurability = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY);
damageDurability = (LinkedList<Short>) cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY);
}
if (cc.getSessionData(pref + CK.S_PLACE_NAMES) != null) {
placeIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_PLACE_NAMES);
placeAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_PLACE_AMOUNTS);
placeDurability = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_PLACE_DURABILITY);
placeDurability = (LinkedList<Short>) cc.getSessionData(pref + CK.S_PLACE_DURABILITY);
}
if (cc.getSessionData(pref + CK.S_USE_NAMES) != null) {
useIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_USE_NAMES);
useAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_USE_AMOUNTS);
useDurability = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_USE_DURABILITY);
useDurability = (LinkedList<Short>) cc.getSessionData(pref + CK.S_USE_DURABILITY);
}
if (cc.getSessionData(pref + CK.S_CUT_NAMES) != null) {
cutIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_CUT_NAMES);
cutAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_CUT_AMOUNTS);
cutDurability = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_CUT_DURABILITY);
cutDurability = (LinkedList<Short>) cc.getSessionData(pref + CK.S_CUT_DURABILITY);
}
if (cc.getSessionData(pref + CK.S_FISH) != null) {
fish = (Integer) cc.getSessionData(pref + CK.S_FISH);

View File

@ -577,8 +577,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n";
for (Integer i : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
for (Short s : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
@ -627,16 +627,16 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
if (one == two) {
int missing;
LinkedList<Integer> elements;
LinkedList<Short> elements;
if (context.getSessionData(pref + CK.S_BREAK_DURABILITY) != null) {
missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_BREAK_DURABILITY)).size();
elements = (LinkedList<Integer>) context.getSessionData(pref + CK.S_BREAK_DURABILITY);
missing = one - ((List<Short>) context.getSessionData(pref + CK.S_BREAK_DURABILITY)).size();
elements = (LinkedList<Short>) context.getSessionData(pref + CK.S_BREAK_DURABILITY);
} else {
missing = one;
elements = new LinkedList<Integer>();
elements = new LinkedList<Short>();
}
for (int i = 0; i < missing; i++) {
elements.add(0);
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_BREAK_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -659,8 +659,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
@SuppressWarnings("unchecked")
private List<Integer> getBlockDurability(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + CK.S_BREAK_DURABILITY);
private List<Short> getBlockDurability(ConversationContext context) {
return (List<Short>) context.getSessionData(pref + CK.S_BREAK_DURABILITY);
}
}
@ -742,11 +742,11 @@ public class CreateStagePrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> durability = new LinkedList<Integer>();
LinkedList<Short> durability = new LinkedList<Short>();
for (String s : args) {
try {
if (Integer.parseInt(s) > 0) {
durability.add(Integer.parseInt(s));
if (Short.parseShort(s) > 0) {
durability.add(Short.parseShort(s));
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " " + Lang.get("stageEditortNotGreaterThanZero"));
return new BreakBlockDurabilityPrompt();
@ -794,8 +794,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n";
for (Integer i : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
for (Short s : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
@ -844,16 +844,16 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
if (one == two) {
int missing;
LinkedList<Integer> elements;
LinkedList<Short> elements;
if (context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) != null) {
missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY)).size();
elements = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY);
missing = one - ((List<Short>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY)).size();
elements = (LinkedList<Short>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY);
} else {
missing = one;
elements = new LinkedList<Integer>();
elements = new LinkedList<Short>();
}
for (int i = 0; i < missing; i++) {
elements.add(0);
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -876,8 +876,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
@SuppressWarnings("unchecked")
private List<Integer> getBlockDurability(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY);
private List<Short> getBlockDurability(ConversationContext context) {
return (List<Short>) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY);
}
}
@ -959,11 +959,11 @@ public class CreateStagePrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> durability = new LinkedList<Integer>();
LinkedList<Short> durability = new LinkedList<Short>();
for (String s : args) {
try {
if (Integer.parseInt(s) > 0) {
durability.add(Integer.parseInt(s));
if (Short.parseShort(s) > 0) {
durability.add(Short.parseShort(s));
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " " + Lang.get("stageEditortNotGreaterThanZero"));
return new DamageBlockDurabilityPrompt();
@ -1011,8 +1011,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n";
for (Integer i : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
for (Short s : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
@ -1061,16 +1061,16 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
if (one == two) {
int missing;
LinkedList<Integer> elements;
LinkedList<Short> elements;
if (context.getSessionData(pref + CK.S_PLACE_DURABILITY) != null) {
missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_PLACE_DURABILITY)).size();
elements = (LinkedList<Integer>) context.getSessionData(pref + CK.S_PLACE_DURABILITY);
missing = one - ((List<Short>) context.getSessionData(pref + CK.S_PLACE_DURABILITY)).size();
elements = (LinkedList<Short>) context.getSessionData(pref + CK.S_PLACE_DURABILITY);
} else {
missing = one;
elements = new LinkedList<Integer>();
elements = new LinkedList<Short>();
}
for (int i = 0; i < missing; i++) {
elements.add(0);
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_PLACE_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -1093,8 +1093,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
@SuppressWarnings("unchecked")
private List<Integer> getBlockDurability(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + CK.S_PLACE_DURABILITY);
private List<Short> getBlockDurability(ConversationContext context) {
return (List<Short>) context.getSessionData(pref + CK.S_PLACE_DURABILITY);
}
}
@ -1176,11 +1176,11 @@ public class CreateStagePrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> durability = new LinkedList<Integer>();
LinkedList<Short> durability = new LinkedList<Short>();
for (String s : args) {
try {
if (Integer.parseInt(s) > 0) {
durability.add(Integer.parseInt(s));
if (Short.parseShort(s) > 0) {
durability.add(Short.parseShort(s));
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " " + Lang.get("stageEditortNotGreaterThanZero"));
return new PlaceBlockDurabilityPrompt();
@ -1228,8 +1228,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n";
for (Integer i : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
for (Short s : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
@ -1278,16 +1278,16 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
if (one == two) {
int missing;
LinkedList<Integer> elements;
LinkedList<Short> elements;
if (context.getSessionData(pref + CK.S_USE_DURABILITY) != null) {
missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_USE_DURABILITY)).size();
elements = (LinkedList<Integer>) context.getSessionData(pref + CK.S_USE_DURABILITY);
missing = one - ((List<Short>) context.getSessionData(pref + CK.S_USE_DURABILITY)).size();
elements = (LinkedList<Short>) context.getSessionData(pref + CK.S_USE_DURABILITY);
} else {
missing = one;
elements = new LinkedList<Integer>();
elements = new LinkedList<Short>();
}
for (int i = 0; i < missing; i++) {
elements.add(0);
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_USE_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -1310,8 +1310,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
@SuppressWarnings("unchecked")
private List<Integer> getBlockDurability(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + CK.S_USE_DURABILITY);
private List<Short> getBlockDurability(ConversationContext context) {
return (List<Short>) context.getSessionData(pref + CK.S_USE_DURABILITY);
}
}
@ -1393,11 +1393,11 @@ public class CreateStagePrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> durability = new LinkedList<Integer>();
LinkedList<Short> durability = new LinkedList<Short>();
for (String s : args) {
try {
if (Integer.parseInt(s) > 0) {
durability.add(Integer.parseInt(s));
if (Short.parseShort(s) > 0) {
durability.add(Short.parseShort(s));
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " " + Lang.get("stageEditortNotGreaterThanZero"));
return new UseBlockDurabilityPrompt();
@ -1445,8 +1445,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n";
for (Integer i : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
for (Short s : getBlockDurability(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
@ -1495,16 +1495,16 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
if (one == two) {
int missing;
LinkedList<Integer> elements;
LinkedList<Short> elements;
if (context.getSessionData(pref + CK.S_CUT_DURABILITY) != null) {
missing = one - ((List<Integer>) context.getSessionData(pref + CK.S_CUT_DURABILITY)).size();
elements = (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_DURABILITY);
missing = one - ((List<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY)).size();
elements = (LinkedList<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY);
} else {
missing = one;
elements = new LinkedList<Integer>();
elements = new LinkedList<Short>();
}
for (int i = 0; i < missing; i++) {
elements.add(0);
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_CUT_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -1527,8 +1527,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
@SuppressWarnings("unchecked")
private List<Integer> getBlockDurability(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + CK.S_CUT_DURABILITY);
private List<Short> getBlockDurability(ConversationContext context) {
return (List<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY);
}
}
@ -1610,11 +1610,11 @@ public class CreateStagePrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> durability = new LinkedList<Integer>();
LinkedList<Short> durability = new LinkedList<Short>();
for (String s : args) {
try {
if (Integer.parseInt(s) > 0) {
durability.add(Integer.parseInt(s));
if (Short.parseShort(s) > 0) {
durability.add(Short.parseShort(s));
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " " + Lang.get("stageEditortNotGreaterThanZero"));
return new CutBlockDurabilityPrompt();