#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.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData> { public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData> {
@NotNull @NotNull
@ -239,8 +236,16 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object o) {
return obj instanceof ItemStat && ((ItemStat) obj).getId().equals(getId()); 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) { public static String translate(String path) {