mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +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;
|
package net.minestom.server.attribute;
|
||||||
|
|
||||||
import net.minestom.server.utils.UniqueIdUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent an attribute modifier.
|
* Represent an attribute modifier.
|
||||||
@ -24,7 +22,7 @@ public class AttributeModifier {
|
|||||||
* @param operation the operation to apply this modifier with
|
* @param operation the operation to apply this modifier with
|
||||||
*/
|
*/
|
||||||
public AttributeModifier(@NotNull String name, float amount, @NotNull AttributeOperation operation) {
|
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;
|
package net.minestom.server.utils;
|
||||||
|
|
||||||
import java.util.Random;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An utilities class for {@link UUID}.
|
* An utilities class for {@link UUID}.
|
||||||
*/
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
public final class UniqueIdUtils {
|
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");
|
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) {
|
public static boolean isUniqueId(String input) {
|
||||||
return input.matches(UNIQUE_ID_PATTERN.pattern());
|
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