Avoid device duplication due to synthetic name device.

This commit is contained in:
Florian Nücke
2021-08-03 02:51:37 +02:00
parent e481c42f82
commit a3edc7e216

View File

@@ -5,6 +5,7 @@ import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import java.util.List;
import java.util.Objects;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
@@ -25,4 +26,17 @@ public final class TypeNameRPCDevice implements RPCDevice, ItemDevice {
public List<RPCMethod> getMethods() {
return emptyList();
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final TypeNameRPCDevice that = (TypeNameRPCDevice) o;
return typeName.equals(that.typeName);
}
@Override
public int hashCode() {
return Objects.hash(typeName);
}
}