Potential bug fixes

This commit is contained in:
HappyPikachu 2017-07-08 00:07:50 -04:00
parent 8ab76338f1
commit 2a84736d01
4 changed files with 50 additions and 83 deletions

View File

@ -498,15 +498,9 @@ public class Quester {
} }
} }
for (ItemStack is : getCurrentStage(quest).itemsToDeliver) { for (ItemStack is : getCurrentStage(quest).itemsToDeliver) {
int delivered = 0; int delivered = getQuestData(quest).itemsDelivered.get(is);
int amt = is.getAmount(); int amt = is.getAmount();
Integer npc = null; Integer npc = getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(is));
if (getQuestData(quest).itemsDelivered.get(is) != null) {
delivered = getQuestData(quest).itemsDelivered.get(is);
}
if (getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(is)) != null) {
npc = getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(is));
}
if (delivered < amt) { if (delivered < amt) {
String obj = Lang.get("deliver"); String obj = Lang.get("deliver");
obj = obj.replaceAll("<item>", ItemUtil.getName(is)); obj = obj.replaceAll("<item>", ItemUtil.getName(is));
@ -698,7 +692,6 @@ public class Quester {
toDamage = is; toDamage = is;
} }
} }
if (damaged != null && toDamage != null) {
if (damaged.getAmount() < toDamage.getAmount()) { if (damaged.getAmount() < toDamage.getAmount()) {
ItemStack newDamaged = damaged; ItemStack newDamaged = damaged;
newDamaged.setAmount(damaged.getAmount() + 1); newDamaged.setAmount(damaged.getAmount() + 1);
@ -708,13 +701,8 @@ public class Quester {
finishObjective(quest, "damageBlock", m, null, null, null, null, null, null, null, null, null); finishObjective(quest, "damageBlock", m, null, null, null, null, null, null, null, null, null);
} }
} }
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
} }
// Called when a block is broken in PlayerListener, hence ItemStack m will always have amount of 1
public void breakBlock(Quest quest, ItemStack m) { public void breakBlock(Quest quest, ItemStack m) {
ItemStack temp = m; ItemStack temp = m;
temp.setAmount(0); temp.setAmount(0);
@ -730,7 +718,6 @@ public class Quester {
toBreak = is; toBreak = is;
} }
} }
if (broken != null && toBreak != null) {
if (broken.getAmount() < toBreak.getAmount()) { if (broken.getAmount() < toBreak.getAmount()) {
ItemStack newBroken = broken; ItemStack newBroken = broken;
newBroken.setAmount(broken.getAmount() + 1); newBroken.setAmount(broken.getAmount() + 1);
@ -740,10 +727,6 @@ public class Quester {
finishObjective(quest, "breakBlock", m, null, null, null, null, null, null, null, null, null); finishObjective(quest, "breakBlock", m, null, null, null, null, null, null, null, null, null);
} }
} }
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
} }
public void placeBlock(Quest quest, ItemStack m) { public void placeBlock(Quest quest, ItemStack m) {
@ -761,7 +744,6 @@ public class Quester {
toPlace = is; toPlace = is;
} }
} }
if (placed != null && toPlace != null) {
if (placed.getAmount() < toPlace.getAmount()) { if (placed.getAmount() < toPlace.getAmount()) {
ItemStack newplaced = placed; ItemStack newplaced = placed;
newplaced.setAmount(placed.getAmount() + 1); newplaced.setAmount(placed.getAmount() + 1);
@ -771,10 +753,6 @@ public class Quester {
finishObjective(quest, "placeBlock", m, null, null, null, null, null, null, null, null, null); finishObjective(quest, "placeBlock", m, null, null, null, null, null, null, null, null, null);
} }
} }
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
} }
public void useBlock(Quest quest, ItemStack m) { public void useBlock(Quest quest, ItemStack m) {
@ -792,7 +770,6 @@ public class Quester {
toUse = is; toUse = is;
} }
} }
if (used != null && toUse != null) {
if (used.getAmount() < toUse.getAmount()) { if (used.getAmount() < toUse.getAmount()) {
ItemStack newUsed = used; ItemStack newUsed = used;
newUsed.setAmount(used.getAmount() + 1); newUsed.setAmount(used.getAmount() + 1);
@ -802,10 +779,6 @@ public class Quester {
finishObjective(quest, "useBlock", m, null, null, null, null, null, null, null, null, null); finishObjective(quest, "useBlock", m, null, null, null, null, null, null, null, null, null);
} }
} }
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
} }
public void cutBlock(Quest quest, ItemStack m) { public void cutBlock(Quest quest, ItemStack m) {
@ -823,7 +796,6 @@ public class Quester {
toCut = is; toCut = is;
} }
} }
if (cut != null && toCut != null) {
if (cut.getAmount() < toCut.getAmount()) { if (cut.getAmount() < toCut.getAmount()) {
ItemStack newCut = cut; ItemStack newCut = cut;
newCut.setAmount(cut.getAmount() + 1); newCut.setAmount(cut.getAmount() + 1);
@ -833,10 +805,6 @@ public class Quester {
finishObjective(quest, "cutBlock", m, null, null, null, null, null, null, null, null, null); finishObjective(quest, "cutBlock", m, null, null, null, null, null, null, null, null, null);
} }
} }
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
} }
public void catchFish(Quest quest) { public void catchFish(Quest quest) {
@ -881,7 +849,7 @@ public class Quester {
Location locationToKillWithin = questData.locationsToKillWithin.get(indexOfMobKilled); Location locationToKillWithin = questData.locationsToKillWithin.get(indexOfMobKilled);
double radius = questData.radiiToKillWithin.get(indexOfMobKilled); double radius = questData.radiiToKillWithin.get(indexOfMobKilled);
// Check world #name, not the object // Check world #name, not the object
if ((killedLocation.getWorld().getName() == locationToKillWithin.getWorld().getName()) == false) { if ((killedLocation.getWorld().getName().equals(locationToKillWithin.getWorld().getName())) == false) {
return; return;
} }
// Radius check, it's a "circle", not cuboid // Radius check, it's a "circle", not cuboid
@ -2001,7 +1969,7 @@ public class Quester {
for (String s : names) { for (String s : names) {
ItemStack is; ItemStack is;
// if (durability.get(names.indexOf(s)) != -1) { // if (durability.get(names.indexOf(s)) != -1) {
if (durability.indexOf(names.indexOf(s)) != -1) { if (durability.indexOf((short)names.indexOf(s)) != -1) {
is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s)));
} else { } else {
// Legacy // Legacy
@ -2017,7 +1985,7 @@ public class Quester {
for (String s : names) { for (String s : names) {
ItemStack is; ItemStack is;
// if (durability.get(names.indexOf(s)) != -1) { // if (durability.get(names.indexOf(s)) != -1) {
if (durability.indexOf(names.indexOf(s)) != -1) { if (durability.indexOf((short)names.indexOf(s)) != -1) {
is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s)));
} else { } else {
// Legacy // Legacy
@ -2033,7 +2001,7 @@ public class Quester {
for (String s : names) { for (String s : names) {
ItemStack is; ItemStack is;
// if (durability.get(names.indexOf(s)) != -1) { // if (durability.get(names.indexOf(s)) != -1) {
if (durability.indexOf(names.indexOf(s)) != -1) { if (durability.indexOf((short)names.indexOf(s)) != -1) {
is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s)));
} else { } else {
// Legacy // Legacy
@ -2049,7 +2017,7 @@ public class Quester {
for (String s : names) { for (String s : names) {
ItemStack is; ItemStack is;
// if (durability.get(names.indexOf(s)) != -1) { // if (durability.get(names.indexOf(s)) != -1) {
if (durability.indexOf(names.indexOf(s)) != -1) { if (durability.indexOf((short)names.indexOf(s)) != -1) {
is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s)));
} else { } else {
// Legacy // Legacy
@ -2065,7 +2033,7 @@ public class Quester {
for (String s : names) { for (String s : names) {
ItemStack is; ItemStack is;
// if (durability.get(names.indexOf(s)) != -1) { // if (durability.get(names.indexOf(s)) != -1) {
if (durability.indexOf(names.indexOf(s)) != -1) { if (durability.indexOf((short)names.indexOf(s)) != -1) {
is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s)));
} else { } else {
// Legacy // Legacy

View File

@ -1792,7 +1792,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} catch (Exception e) { } catch (Exception e) {
// TODO find source of NullPointerException from Github ticket #130 e.printStackTrace();
} }
} }
} else { } else {

View File

@ -3668,7 +3668,9 @@ public class CreateStagePrompt extends FixedSetPrompt {
break; break;
} }
} }
if (found != null) {
text += ChatColor.BLUE + found.getCountPrompt().toString() + "\n\n"; text += ChatColor.BLUE + found.getCountPrompt().toString() + "\n\n";
}
return text; return text;
} }
@ -3688,7 +3690,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
break; break;
} }
} }
if (found.datamap.isEmpty() == false) { if (found != null && found.datamap.isEmpty() == false) {
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found.descriptions); context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found.descriptions);
return new ObjectiveCustomDataListPrompt(); return new ObjectiveCustomDataListPrompt();
} else { } else {

View File

@ -34,13 +34,10 @@ public class ItemUtil {
* @return -5&nbsp;-> stack enchantments are unequal<br> * @return -5&nbsp;-> stack enchantments are unequal<br>
*/ */
public static int compareItems(ItemStack one, ItemStack two, boolean ignoreAmount) { public static int compareItems(ItemStack one, ItemStack two, boolean ignoreAmount) {
if (one == null && two != null || one != null && two == null) { if (one == null || two == null) {
return 0; return 0;
} }
if (one == null && two == null) { if (one.getType().name().equals(two.getType().name()) == false) {
return 0;
}
if (one.getType().name() != two.getType().name()) {
return -1; return -1;
} else if ((one.getAmount() != two.getAmount()) && ignoreAmount == false) { } else if ((one.getAmount() != two.getAmount()) && ignoreAmount == false) {
return -2; return -2;