Remove legacy weirdness

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-09-01 11:56:09 +02:00
parent 2c0cd4ff7a
commit 9bb4043571
2 changed files with 4 additions and 13 deletions

View File

@ -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);
}
/**

View File

@ -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);
}
}