Use faster deepEquals method in java to replace lines check

Former-commit-id: cec29e4517b627ca50c4e37bd06636acc34b4aaf [formerly 2261ef58b73b1bc28d8d2581869a81e728ee3699]
Former-commit-id: 7241fc0086cb3804a684f401d01c2648f97bc358
This commit is contained in:
Ghost_chu committed 2019-08-19 15:18:20 +08:00
1 parent d808b9c0c9
commit 792fd82d1e
1 file changed
+12 -11
@@ -1,6 +1,7 @@
package org.maxgamer.quickshop.Util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -43,6 +44,11 @@ public class ItemMatcher {
return false; // One of them is null (Can't be both, see above)
}
requireStack = requireStack.clone();
requireStack.setAmount(1);
givenStack = givenStack.clone();
givenStack.setAmount(1);
if (plugin.getConfig().getBoolean("shop.strict-matches-check")) {
Util.debugLog("Execute strict match check...");
return requireStack.equals(givenStack);
@@ -218,15 +224,7 @@ public class ItemMatcher {
}
List<String> lores1 = meta1.getLore();
List<String> lores2 = meta2.getLore();
if (lores1.size() != lores2.size()) {
return false;
}
for (int i = 0; i < lores1.size(); i++) {
if (!lores1.get(i).equals(lores2.get(i))) {
return false;
}
}
return true;
return !Arrays.deepEquals(lores1.toArray(), lores2.toArray());
}
boolean matches(ItemStack requireStack, ItemStack givenStack) {
@@ -330,9 +328,12 @@ public class ItemMatcher {
if(!potion2.hasCustomEffects()){
return false;
}
if (!Util.listMatches(potion1.getCustomEffects(),potion2.getCustomEffects())) {
return false;
if(!Arrays.deepEquals(potion1.getCustomEffects().toArray(),potion2.getCustomEffects().toArray())){
return false;
}
// if (!Util.listMatches(potion1.getCustomEffects(),potion2.getCustomEffects())) {
// return false;
// }
}
PotionData data1 = potion1.getBasePotionData();
PotionData data2 = potion2.getBasePotionData();