Fix Key equals()

This commit is contained in:
Lukas Rieger (Blue) 2022-08-01 11:12:50 +02:00
parent ffc472ce84
commit fba273f620
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -1,7 +1,6 @@
package de.bluecolored.bluemap.core.util;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.core.resources.ResourcePath;
@DebugDump
public class Key {
@ -14,15 +13,15 @@ public class Key {
public Key(String formatted) {
String namespace = MINECRAFT_NAMESPACE;
String path = formatted;
String value = formatted;
int namespaceSeparator = formatted.indexOf(':');
if (namespaceSeparator > 0) {
namespace = formatted.substring(0, namespaceSeparator);
path = formatted.substring(namespaceSeparator + 1);
value = formatted.substring(namespaceSeparator + 1);
}
this.namespace = namespace.intern();
this.value = path.intern();
this.value = value.intern();
this.formatted = (this.namespace + ":" + this.value).intern();
}
@ -49,7 +48,7 @@ public String getFormatted() {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ResourcePath<?> that = (ResourcePath<?>) o;
Key that = (Key) o;
return getFormatted() == that.getFormatted();
}