mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-24 11:38:42 +01:00
Return unique value for null stacks during comparison
This commit is contained in:
parent
290ac4f158
commit
8ae3ebae7f
@ -37,24 +37,25 @@ import me.blackvein.quests.Quests;
|
|||||||
public class ItemUtil {
|
public class ItemUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will compare stacks by name, amount, durability, display name/lore and enchantments
|
* Compare two stacks by name, amount, durability, display name, lore, enchantments and stored enchants
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param one
|
* @param one first ItemStack to compare against second
|
||||||
* ItemStack to compare
|
* @param two second ItemStack to compare against first
|
||||||
* @param two
|
* @param ignoreAmount whether to ignore stack amounts
|
||||||
* ItemStack to compare to
|
* @return 1 if either stack is null<br>
|
||||||
* @return 0 if stacks are equal, or the first inequality from the following values:<br>
|
* 0 if stacks are equal<br>
|
||||||
* @return -1 -> stack names are unequal<br>
|
* -1 if stack names are unequal<br>
|
||||||
* @return -2 -> stack amounts are unequal<br>
|
* -2 if stack amounts are unequal<br>
|
||||||
* @return -3 -> stack durability is unequal<br>
|
* -3 if stack durability is unequal<br>
|
||||||
* @return -4 -> stack display name/lore is unequal<br>
|
* -4 if stack display name/lore is unequal<br>
|
||||||
* @return -5 -> stack enchantments are unequal<br>
|
* -5 if stack enchantments are unequal<br>
|
||||||
|
* -6 if stack stored enchants are unequal
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
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) {
|
if (one == null || two == null) {
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
if (one.getType().name().equals(two.getType().name()) == false) {
|
if (one.getType().name().equals(two.getType().name()) == false) {
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user