mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-04-13 09:41:09 +00:00
Merging in latest from upstream (SPIGOT/bukkit:refs/heads/master)
* commit '8ae2e3beb8f51ad5588480bf6d1a46ace90a1402': #1055: Expand riptiding API SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor
This commit is contained in:
commit
f6e7dbd76e
1 changed files with 17 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue