Skip to content

Commit

Permalink
Merge pull request Sefiraat#178 from balugaq/master
Browse files Browse the repository at this point in the history
Update zh-CN.yml
  • Loading branch information
balugaq authored Nov 18, 2024
2 parents 9ef5c57 + b9ee511 commit 1c43e9b
Show file tree
Hide file tree
Showing 2 changed files with 389 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/main/java/io/github/sefiraat/networks/utils/StackUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,47 @@ public static ItemStack getAsQuantity(@Nullable ItemStack itemStack, int amount)
return clone;
}

public static boolean itemsMatch(@Nullable ItemStack itemStack1, @Nullable ItemStack itemStack2, boolean checkLore, boolean checkAmount, boolean checkCustomModelId) {
return itemsMatch(new ItemStackCache(itemStack1), itemStack2, checkLore, checkAmount, checkCustomModelId);
}

public static boolean itemsMatch(@Nullable ItemStack itemStack1, @Nullable ItemStack itemStack2, boolean checkLore, boolean checkAmount) {
return itemsMatch(new ItemStackCache(itemStack1), itemStack2, checkLore, checkAmount);
return itemsMatch(new ItemStackCache(itemStack1), itemStack2, checkLore, checkAmount, true);
}

public static boolean itemsMatch(@Nullable ItemStack itemStack1, @Nullable ItemStack itemStack2, boolean checkLore) {
return itemsMatch(new ItemStackCache(itemStack1), itemStack2, checkLore, false);
return itemsMatch(new ItemStackCache(itemStack1), itemStack2, checkLore, false, true);
}

public static boolean itemsMatch(@Nullable ItemStack itemStack1, @Nullable ItemStack itemStack2) {
return itemsMatch(new ItemStackCache(itemStack1), itemStack2, false, false);
return itemsMatch(new ItemStackCache(itemStack1), itemStack2, false, false,true);
}

public static boolean itemsMatch(@Nonnull ItemStackCache cache, @Nullable ItemStack itemStack, boolean checkLore, boolean checkAmount) {
return itemsMatch(cache, itemStack, checkLore, checkAmount, true);
}

public static boolean itemsMatch(@Nonnull ItemStackCache cache, @Nullable ItemStack itemStack, boolean checkLore) {
return itemsMatch(cache, itemStack, checkLore, false);
return itemsMatch(cache, itemStack, checkLore, false, true);
}

public static boolean itemsMatch(@Nonnull ItemStackCache cache, @Nullable ItemStack itemStack) {
return itemsMatch(cache, itemStack, false, false);
return itemsMatch(cache, itemStack, false, false, true);
}

public static boolean itemsMatch(@Nullable ItemStack itemStack, @Nonnull ItemStackCache cache, boolean checkLore, boolean checkAmount, boolean checkCustomModelId) {
return itemsMatch(cache, itemStack, checkLore, checkAmount, checkCustomModelId);
}
public static boolean itemsMatch(@Nullable ItemStack itemStack, @Nonnull ItemStackCache cache, boolean checkLore, boolean checkAmount) {
return itemsMatch(cache, itemStack, checkLore, checkAmount);
return itemsMatch(cache, itemStack, checkLore, checkAmount, true);
}

public static boolean itemsMatch(@Nullable ItemStack itemStack, @Nonnull ItemStackCache cache, boolean checkLore) {
return itemsMatch(cache, itemStack, checkLore, false);
return itemsMatch(cache, itemStack, checkLore, false, true);
}

public static boolean itemsMatch(@Nullable ItemStack itemStack, @Nonnull ItemStackCache cache) {
return itemsMatch(cache, itemStack, false, false);
return itemsMatch(cache, itemStack, false, false, true);
}

/**
Expand All @@ -99,7 +110,7 @@ public static boolean itemsMatch(@Nullable ItemStack itemStack, @Nonnull ItemSta
* @param itemStack The {@link ItemStack} being evaluated
* @return True if items match
*/
public static boolean itemsMatch(@Nonnull ItemStackCache cache, @Nullable ItemStack itemStack, boolean checkLore, boolean checkAmount) {
public static boolean itemsMatch(@Nonnull ItemStackCache cache, @Nullable ItemStack itemStack, boolean checkLore, boolean checkAmount, boolean checkCustomModelId) {
// Null check
if (cache.getItemStack() == null || itemStack == null) {
return itemStack == null && cache.getItemStack() == null;
Expand Down Expand Up @@ -151,15 +162,17 @@ public static boolean itemsMatch(@Nonnull ItemStackCache cache, @Nullable ItemSt
return false;
}

// Custom model data is different, no match
final boolean hasCustomOne = itemMeta.hasCustomModelData();
final boolean hasCustomTwo = cachedMeta.hasCustomModelData();
if (hasCustomOne) {
if (!hasCustomTwo || itemMeta.getCustomModelData() != cachedMeta.getCustomModelData()) {
if (checkCustomModelId) {
// Custom model data is different, no match
final boolean hasCustomOne = itemMeta.hasCustomModelData();
final boolean hasCustomTwo = cachedMeta.hasCustomModelData();
if (hasCustomOne) {
if (!hasCustomTwo || itemMeta.getCustomModelData() != cachedMeta.getCustomModelData()) {
return false;
}
} else if (hasCustomTwo) {
return false;
}
} else if (hasCustomTwo) {
return false;
}

// PDCs don't match
Expand Down
Loading

0 comments on commit 1c43e9b

Please sign in to comment.