#equals and #hashCode for item stats!

This commit is contained in:
Indyuce 2022-08-01 15:00:36 +02:00
parent 674df6c4b6
commit d2c65dc3e8

View File

@ -14,10 +14,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.*;
public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData> {
@NotNull
@ -239,8 +236,16 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
}
@Override
public boolean equals(Object obj) {
return obj instanceof ItemStat && ((ItemStat) obj).getId().equals(getId());
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ItemStat<?, ?> itemStat = (ItemStat<?, ?>) o;
return id.equals(itemStat.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
public static String translate(String path) {