diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/component/ComponentPredicate.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/component/ComponentPredicate.java index 782de5ae2e..4158f7a025 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/component/ComponentPredicate.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/component/ComponentPredicate.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; @@ -88,4 +89,22 @@ public List> getRequiredComponents() { public void setRequiredComponents(List> requiredComponents) { this.requiredComponents = requiredComponents; } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (!(obj instanceof ComponentPredicate)) return false; + ComponentPredicate that = (ComponentPredicate) obj; + return this.requiredComponents.equals(that.requiredComponents); + } + + @Override + public int hashCode() { + return Objects.hashCode(this.requiredComponents); + } + + @Override + public String toString() { + return "ComponentPredicate{requiredComponents=" + this.requiredComponents + '}'; + } } diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/component/PatchableComponentMap.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/component/PatchableComponentMap.java index dbc5aaa882..55c3b4a83a 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/component/PatchableComponentMap.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/component/PatchableComponentMap.java @@ -96,6 +96,20 @@ public Map, Optional> getPatches() { return this.patches; } + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (!(obj instanceof PatchableComponentMap)) return false; + PatchableComponentMap that = (PatchableComponentMap) obj; + if (!this.base.equals(that.base)) return false; + return this.patches.equals(that.patches); + } + + @Override + public int hashCode() { + return Objects.hash(this.base, this.patches); + } + @Override public String toString() { return "PatchableComponentMap{base=" + this.base + ", patches=" + this.patches + '}'; diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/component/StaticComponentMap.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/component/StaticComponentMap.java index 1363649e06..68f198231c 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/component/StaticComponentMap.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/component/StaticComponentMap.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Optional; public class StaticComponentMap implements IComponentMap { @@ -82,6 +83,24 @@ public boolean isEmpty() { return this.empty; } + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (!(obj instanceof StaticComponentMap)) return false; + StaticComponentMap that = (StaticComponentMap) obj; + return this.delegate.equals(that.delegate); + } + + @Override + public int hashCode() { + return Objects.hashCode(this.delegate); + } + + @Override + public String toString() { + return "StaticComponentMap{empty=" + this.empty + ", delegate=" + this.delegate + '}'; + } + public static class Builder { private final Map, Object> map = new HashMap<>();