mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-06 02:41:59 +01:00
Remove legacy weirdness
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
2c0cd4ff7a
commit
9bb4043571
@ -1,10 +1,8 @@
|
||||
package net.minestom.server.attribute;
|
||||
|
||||
import net.minestom.server.utils.UniqueIdUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* Represent an attribute modifier.
|
||||
@ -24,7 +22,7 @@ public class AttributeModifier {
|
||||
* @param operation the operation to apply this modifier with
|
||||
*/
|
||||
public AttributeModifier(@NotNull String name, float amount, @NotNull AttributeOperation operation) {
|
||||
this(UniqueIdUtils.createRandomUUID(ThreadLocalRandom.current()), name, amount, operation);
|
||||
this(UUID.randomUUID(), name, amount, operation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,15 @@
|
||||
package net.minestom.server.utils;
|
||||
|
||||
import java.util.Random;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* An utilities class for {@link UUID}.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public final class UniqueIdUtils {
|
||||
|
||||
public static final Pattern UNIQUE_ID_PATTERN = Pattern.compile("\\b[0-9a-f]{8}\\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}\\b");
|
||||
|
||||
/**
|
||||
@ -20,12 +21,4 @@ public final class UniqueIdUtils {
|
||||
public static boolean isUniqueId(String input) {
|
||||
return input.matches(UNIQUE_ID_PATTERN.pattern());
|
||||
}
|
||||
|
||||
public static UUID createRandomUUID(Random random) {
|
||||
long most = random.nextLong() & -61441L | 16384L;
|
||||
long least = random.nextLong() & 4611686018427387903L | Long.MAX_VALUE;
|
||||
|
||||
return new UUID(most, least);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user