geforkt von Mirrors/Paper
SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
b5a8d2cf35
Commit
cc919bf976
@ -7,6 +7,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
@ -21,27 +22,28 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class AttributeModifier implements ConfigurationSerializable, Keyed {
|
||||
|
||||
private static final Pattern UUID_PATTERN = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$");
|
||||
private final NamespacedKey key;
|
||||
private final double amount;
|
||||
private final Operation operation;
|
||||
private final EquipmentSlotGroup slot;
|
||||
|
||||
@Deprecated
|
||||
@Deprecated(since = "1.21", forRemoval = true)
|
||||
public AttributeModifier(@NotNull String name, double amount, @NotNull Operation operation) {
|
||||
this(UUID.randomUUID(), name, amount, operation);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Deprecated(since = "1.21", forRemoval = true)
|
||||
public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation) {
|
||||
this(uuid, name, amount, operation, (EquipmentSlot) null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Deprecated(since = "1.21", forRemoval = true)
|
||||
public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation, @Nullable EquipmentSlot slot) {
|
||||
this(uuid, name, amount, operation, (slot) == null ? EquipmentSlotGroup.ANY : slot.getGroup());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Deprecated(since = "1.21", forRemoval = true)
|
||||
public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation, @NotNull EquipmentSlotGroup slot) {
|
||||
this(NamespacedKey.fromString(uuid.toString()), amount, operation, slot);
|
||||
}
|
||||
@ -64,9 +66,18 @@ public class AttributeModifier implements ConfigurationSerializable, Keyed {
|
||||
* @deprecated attributes are now identified by keys
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@Deprecated(since = "1.21", forRemoval = true)
|
||||
public UUID getUniqueId() {
|
||||
return UUID.nameUUIDFromBytes(getKey().toString().getBytes(StandardCharsets.UTF_8));
|
||||
NamespacedKey namespacedKey = getKey();
|
||||
if (namespacedKey.getNamespace().equals(NamespacedKey.MINECRAFT)) {
|
||||
String key = namespacedKey.getKey();
|
||||
|
||||
if (key.length() == 36 && UUID_PATTERN.matcher(key).matches()) {
|
||||
return UUID.fromString(key);
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.nameUUIDFromBytes(namespacedKey.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren