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) {
int delivered = 0;
int delivered = getQuestData(quest).itemsDelivered.get(is);
int amt = is.getAmount();
Integer npc = null;
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));
}
Integer npc = getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(is));
if (delivered < amt) {
String obj = Lang.get("deliver");
obj = obj.replaceAll("<item>", ItemUtil.getName(is));
@ -698,7 +692,6 @@ public class Quester {
toDamage = is;
}
}
if (damaged != null && toDamage != null) {
if (damaged.getAmount() < toDamage.getAmount()) {
ItemStack newDamaged = damaged;
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);
}
}
} 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) {
ItemStack temp = m;
temp.setAmount(0);
@ -730,7 +718,6 @@ public class Quester {
toBreak = is;
}
}
if (broken != null && toBreak != null) {
if (broken.getAmount() < toBreak.getAmount()) {
ItemStack newBroken = broken;
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);
}
}
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
}
public void placeBlock(Quest quest, ItemStack m) {
@ -761,7 +744,6 @@ public class Quester {
toPlace = is;
}
}
if (placed != null && toPlace != null) {
if (placed.getAmount() < toPlace.getAmount()) {
ItemStack newplaced = placed;
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);
}
}
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
}
public void useBlock(Quest quest, ItemStack m) {
@ -792,7 +770,6 @@ public class Quester {
toUse = is;
}
}
if (used != null && toUse != null) {
if (used.getAmount() < toUse.getAmount()) {
ItemStack newUsed = used;
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);
}
}
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
}
public void cutBlock(Quest quest, ItemStack m) {
@ -823,7 +796,6 @@ public class Quester {
toCut = is;
}
}
if (cut != null && toCut != null) {
if (cut.getAmount() < toCut.getAmount()) {
ItemStack newCut = cut;
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);
}
}
} else {
// Do nothing
System.out.println(quest + " somehow threw a null value. Please report on Github!");
}
}
public void catchFish(Quest quest) {
@ -881,7 +849,7 @@ public class Quester {
Location locationToKillWithin = questData.locationsToKillWithin.get(indexOfMobKilled);
double radius = questData.radiiToKillWithin.get(indexOfMobKilled);
// Check world #name, not the object
if ((killedLocation.getWorld().getName() == locationToKillWithin.getWorld().getName()) == false) {
if ((killedLocation.getWorld().getName().equals(locationToKillWithin.getWorld().getName())) == false) {
return;
}
// Radius check, it's a "circle", not cuboid
@ -2001,7 +1969,7 @@ public class Quester {
for (String s : names) {
ItemStack is;
// 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)));
} else {
// Legacy
@ -2017,7 +1985,7 @@ public class Quester {
for (String s : names) {
ItemStack is;
// 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)));
} else {
// Legacy
@ -2033,7 +2001,7 @@ public class Quester {
for (String s : names) {
ItemStack is;
// 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)));
} else {
// Legacy
@ -2049,7 +2017,7 @@ public class Quester {
for (String s : names) {
ItemStack is;
// 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)));
} else {
// Legacy
@ -2065,7 +2033,7 @@ public class Quester {
for (String s : names) {
ItemStack is;
// 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)));
} else {
// Legacy

View File

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

View File

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

View File

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