Ignore facing direction for block objectives, fixes #146. Bump version

This commit is contained in:
HappyPikachu 2018-01-10 00:03:45 -05:00
parent e6224e47f3
commit 76f0076f9d
3 changed files with 105 additions and 25 deletions

View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId> <groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId> <artifactId>quests</artifactId>
<version>3.2.0</version> <version>3.2.1</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

@ -710,14 +710,30 @@ public class Quester {
ItemStack broken = temp; ItemStack broken = temp;
ItemStack toBreak = temp; ItemStack toBreak = temp;
for (ItemStack is : getQuestData(quest).blocksBroken) { for (ItemStack is : getQuestData(quest).blocksBroken) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
broken = is;
}
} else {
//Blocks are not solid so ignore durability
broken = is; broken = is;
} }
} }
}
for (ItemStack is : getCurrentStage(quest).blocksToBreak) { for (ItemStack is : getCurrentStage(quest).blocksToBreak) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
toBreak = is; toBreak = is;
} }
} else {
//Blocks are not solid so ignore durability
toBreak = is;
}
}
} }
if (broken.getAmount() < toBreak.getAmount()) { if (broken.getAmount() < toBreak.getAmount()) {
ItemStack newBroken = broken; ItemStack newBroken = broken;
@ -735,14 +751,30 @@ public class Quester {
ItemStack damaged = temp; ItemStack damaged = temp;
ItemStack toDamage = temp; ItemStack toDamage = temp;
for (ItemStack is : getQuestData(quest).blocksDamaged) { for (ItemStack is : getQuestData(quest).blocksDamaged) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
damaged = is;
}
} else {
//Blocks are not solid so ignore durability
damaged = is; damaged = is;
} }
} }
}
for (ItemStack is : getCurrentStage(quest).blocksToDamage) { for (ItemStack is : getCurrentStage(quest).blocksToDamage) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
toDamage = is; toDamage = is;
} }
} else {
//Blocks are not solid so ignore durability
toDamage = is;
}
}
} }
if (damaged.getAmount() < toDamage.getAmount()) { if (damaged.getAmount() < toDamage.getAmount()) {
ItemStack newDamaged = damaged; ItemStack newDamaged = damaged;
@ -760,14 +792,30 @@ public class Quester {
ItemStack placed = temp; ItemStack placed = temp;
ItemStack toPlace = temp; ItemStack toPlace = temp;
for (ItemStack is : getQuestData(quest).blocksPlaced) { for (ItemStack is : getQuestData(quest).blocksPlaced) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
placed = is;
}
} else {
//Blocks are not solid so ignore durability
placed = is; placed = is;
} }
} }
}
for (ItemStack is : getCurrentStage(quest).blocksToPlace) { for (ItemStack is : getCurrentStage(quest).blocksToPlace) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
toPlace = is; toPlace = is;
} }
} else {
//Blocks are not solid so ignore durability
toPlace = is;
}
}
} }
if (placed.getAmount() < toPlace.getAmount()) { if (placed.getAmount() < toPlace.getAmount()) {
ItemStack newplaced = placed; ItemStack newplaced = placed;
@ -785,14 +833,30 @@ public class Quester {
ItemStack used = temp; ItemStack used = temp;
ItemStack toUse = temp; ItemStack toUse = temp;
for (ItemStack is : getQuestData(quest).blocksUsed) { for (ItemStack is : getQuestData(quest).blocksUsed) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType() ) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
used = is;
}
} else {
//Blocks are not solid so ignore durability
used = is; used = is;
} }
} }
}
for (ItemStack is : getCurrentStage(quest).blocksToUse) { for (ItemStack is : getCurrentStage(quest).blocksToUse) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType() ) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid, so check durability
if (m.getDurability() == is.getDurability()) {
toUse = is; toUse = is;
} }
} else {
//Blocks are not solid, so ignore durability
toUse = is;
}
}
} }
if (used.getAmount() < toUse.getAmount()) { if (used.getAmount() < toUse.getAmount()) {
ItemStack newUsed = used; ItemStack newUsed = used;
@ -810,14 +874,30 @@ public class Quester {
ItemStack cut = temp; ItemStack cut = temp;
ItemStack toCut = temp; ItemStack toCut = temp;
for (ItemStack is : getQuestData(quest).blocksCut) { for (ItemStack is : getQuestData(quest).blocksCut) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
cut = is;
}
} else {
//Blocks are not solid so ignore durability
cut = is; cut = is;
} }
} }
}
for (ItemStack is : getCurrentStage(quest).blocksToCut) { for (ItemStack is : getCurrentStage(quest).blocksToCut) {
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { if (m.getType() == is.getType()) {
if (m.getType().isSolid() && is.getType().isSolid()) {
//Blocks are solid so check for durability
if (m.getDurability() == is.getDurability()) {
toCut = is; toCut = is;
} }
} else {
//Blocks are not solid so ignore durability
toCut = is;
}
}
} }
if (cut.getAmount() < toCut.getAmount()) { if (cut.getAmount() < toCut.getAmount()) {
ItemStack newCut = cut; ItemStack newCut = cut;
@ -1055,7 +1135,6 @@ public class Quester {
* See CustomObjective class * See CustomObjective class
*/ */
public void finishObjective(Quest quest, String objective, ItemStack material, ItemStack delivery, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) { public void finishObjective(Quest quest, String objective, ItemStack material, ItemStack delivery, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) {
//TODO ItemStack material, is largely unnecessary as .name() can be obtained thru getQuestData(quest).blocksXXXX
Player p = getPlayer(); Player p = getPlayer();
if (getCurrentStage(quest).objectiveOverride != null) { if (getCurrentStage(quest).objectiveOverride != null) {
if (testComplete(quest)) { if (testComplete(quest)) {

View File

@ -187,16 +187,17 @@ public class ItemUtil {
return text; return text;
} }
@SuppressWarnings("deprecation")
public static String getName(ItemStack is) { public static String getName(ItemStack is) {
String text = ""; String text = "";
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) { if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName(); text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName();
} else { } else {
try { try {
text = ChatColor.AQUA + Items.itemByStack(is).getName(); text = ChatColor.AQUA + Items.itemByType(is.getType()).getName();
} catch (Exception ne) { } catch (Exception ne) {
text = ChatColor.AQUA + is.getType().name().toLowerCase().replace("_", " "); text = ChatColor.AQUA + Quester.prettyItemString(is.getType().name());
Bukkit.getLogger().severe("This error is caused by an incompatible version of Vault. Please consider updating."); Bukkit.getLogger().severe("This error is likely caused by an incompatible version of Vault. Please consider updating.");
ne.printStackTrace(); ne.printStackTrace();
} }
} }