mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-18 07:07:40 +01:00
Only compare ItemFlags above MC 1.11, fixes #609
This commit is contained in:
parent
9facf6dafc
commit
e3f388e485
@ -573,12 +573,16 @@ public class Quest {
|
||||
if (i.getEnchantments().isEmpty()) {
|
||||
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount();
|
||||
} else {
|
||||
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET;
|
||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
||||
text += ChatColor.GRAY + " " + Lang.get(player, "with") + ChatColor.DARK_PURPLE;
|
||||
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||
text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue();
|
||||
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET;
|
||||
try {
|
||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
||||
text += ChatColor.GRAY + " " + Lang.get(player, "with") + ChatColor.DARK_PURPLE;
|
||||
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||
text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue();
|
||||
}
|
||||
}
|
||||
} catch (Throwable tr) {
|
||||
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
||||
}
|
||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
||||
}
|
||||
@ -597,11 +601,15 @@ public class Quest {
|
||||
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount();
|
||||
} else {
|
||||
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i);
|
||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
||||
text += ChatColor.GRAY + " " + Lang.get(player, "with");
|
||||
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||
text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue();
|
||||
try {
|
||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
||||
text += ChatColor.GRAY + " " + Lang.get(player, "with");
|
||||
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||
text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue();
|
||||
}
|
||||
}
|
||||
} catch (Throwable tr) {
|
||||
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
||||
}
|
||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
broken = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
broken = is;
|
||||
}
|
||||
@ -932,7 +932,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
toBreak = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
toBreak = is;
|
||||
}
|
||||
@ -966,7 +966,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
damaged = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
damaged = is;
|
||||
}
|
||||
@ -982,7 +982,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
toDamage = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
toDamage = is;
|
||||
}
|
||||
@ -1016,7 +1016,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
placed = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
placed = is;
|
||||
}
|
||||
@ -1032,7 +1032,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
toPlace = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
toPlace = is;
|
||||
}
|
||||
@ -1066,7 +1066,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
used = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
used = is;
|
||||
}
|
||||
@ -1082,7 +1082,7 @@ public class Quester {
|
||||
//Blocks are solid, so check durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
toUse = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
toUse = is;
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
cut = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
cut = is;
|
||||
}
|
||||
@ -1132,7 +1132,7 @@ public class Quester {
|
||||
//Blocks are solid so check for durability
|
||||
if (m.getDurability() == is.getDurability()) {
|
||||
toCut = is;
|
||||
} else if (!LocaleQuery.oldVersion) {
|
||||
} else if (!LocaleQuery.isBelow113(Quests.bukkitVersion)) {
|
||||
//Ignore durability for 1.13+
|
||||
toCut = is;
|
||||
}
|
||||
|
@ -82,10 +82,17 @@ public class ItemUtil {
|
||||
} else if (one.getItemMeta().hasLore() && two.getItemMeta().hasLore() && one.getItemMeta().getLore().equals(two.getItemMeta().getLore()) == false) {
|
||||
return -4;
|
||||
}
|
||||
for (ItemFlag flag : ItemFlag.values()) {
|
||||
if (one.getItemMeta().hasItemFlag(flag) == false && two.getItemMeta().hasItemFlag(flag)) {
|
||||
return -7;
|
||||
try {
|
||||
ItemMeta test = one.getItemMeta();
|
||||
test.setUnbreakable(true);
|
||||
// We're on 1.11+ so check ItemFlags
|
||||
for (ItemFlag flag : ItemFlag.values()) {
|
||||
if (one.getItemMeta().hasItemFlag(flag) == false && two.getItemMeta().hasItemFlag(flag)) {
|
||||
return -7;
|
||||
}
|
||||
}
|
||||
} catch (Throwable tr) {
|
||||
// We're below 1.11 so don't check ItemFlags
|
||||
}
|
||||
}
|
||||
if (one.getEnchantments().equals(two.getEnchantments()) == false) {
|
||||
@ -153,7 +160,6 @@ public class ItemUtil {
|
||||
String display = null;
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
String[] flags = new String[10];
|
||||
//ItemFlag[] flags = new ItemFlag[ItemFlag.values().length];
|
||||
LinkedHashMap<Enchantment, Integer> stored = new LinkedHashMap<Enchantment, Integer>();
|
||||
LinkedHashMap<String, Object> extra = new LinkedHashMap<String, Object>();
|
||||
ItemMeta meta = null;
|
||||
@ -200,7 +206,6 @@ public class ItemUtil {
|
||||
String[] mapping = value.replace("[", "").replace("]", "").split(", ");
|
||||
int index = 0;
|
||||
for (String s : mapping) {
|
||||
//flags[index] = ItemFlag.valueOf(s);
|
||||
flags[index] = s;
|
||||
index++;
|
||||
}
|
||||
@ -255,6 +260,8 @@ public class ItemUtil {
|
||||
meta.setUnbreakable(true);
|
||||
}
|
||||
} catch (Throwable tr) {
|
||||
// ItemMeta.setUnbrekable() not introduced until 1.11
|
||||
// However, NBT tags could be set by Spigot-only methods, so show error
|
||||
Bukkit.getLogger().info("You are running a version of CraftBukkit"
|
||||
+ " for which Quests cannot set the NBT tag " + key);
|
||||
}
|
||||
@ -299,6 +306,10 @@ public class ItemUtil {
|
||||
meta.addItemFlags(ItemFlag.valueOf(flag));
|
||||
} catch (NullPointerException npe) {
|
||||
Bukkit.getLogger().severe(flag + " is not a valid ItemFlag");
|
||||
} catch (Throwable tr) {
|
||||
// ItemMeta.addItemFlags() not introduced until 1.8.3
|
||||
Bukkit.getLogger().info("You are running a version of CraftBukkit"
|
||||
+ " for which Quests cannot add the item flag " + flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class LocaleQuery {
|
||||
private static Class<?> craftMagicNumbers = null;
|
||||
private static Class<?> itemClazz = null;
|
||||
private final Quests plugin;
|
||||
public static boolean oldVersion = false;
|
||||
private static boolean oldVersion = false;
|
||||
|
||||
public LocaleQuery(Quests plugin){
|
||||
this.plugin = plugin;
|
||||
@ -158,6 +158,10 @@ public class LocaleQuery {
|
||||
}
|
||||
|
||||
public static boolean isBelow113(String bukkitVersion) {
|
||||
return _isBelow113(bukkitVersion);
|
||||
}
|
||||
|
||||
private static boolean _isBelow113(String bukkitVersion) {
|
||||
if (bukkitVersion.matches("^[0-9.]+$")) {
|
||||
switch(bukkitVersion) {
|
||||
case "1.12" :
|
||||
|
Loading…
Reference in New Issue
Block a user