mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +01:00
Add shorthand methods for string creation
This commit is contained in:
parent
3651a132fe
commit
0ac6d1aa37
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.utils.identity;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -21,6 +22,16 @@ public interface NamedAndIdentified extends Named<Component>, Identified {
|
||||
return of(EMPTY, UUID.randomUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link NamedAndIdentified} instance with a given name and a random UUID.
|
||||
*
|
||||
* @param name the name
|
||||
* @return the named and identified instance
|
||||
*/
|
||||
static @NotNull NamedAndIdentified named(@NotNull String name) {
|
||||
return of(name, UUID.randomUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link NamedAndIdentified} instance with a given name and a random UUID.
|
||||
*
|
||||
@ -41,6 +52,17 @@ public interface NamedAndIdentified extends Named<Component>, Identified {
|
||||
return of(EMPTY, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link NamedAndIdentified} instance with a given name and UUID.
|
||||
*
|
||||
* @param name the name
|
||||
* @param uuid the uuid
|
||||
* @return the named and identified instance
|
||||
*/
|
||||
static @NotNull NamedAndIdentified of(@NotNull String name, @NotNull UUID uuid) {
|
||||
return new NamedAndIdentifiedImpl(name, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link NamedAndIdentified} instance with a given name and UUID.
|
||||
*
|
||||
|
@ -15,6 +15,17 @@ class NamedAndIdentifiedImpl implements NamedAndIdentified {
|
||||
private final Component name;
|
||||
private final UUID uuid;
|
||||
|
||||
/**
|
||||
* Creates a new named and identified implementation.
|
||||
*
|
||||
* @param name the name
|
||||
* @param uuid the uuid
|
||||
* @see NamedAndIdentified#of(String, UUID)
|
||||
*/
|
||||
NamedAndIdentifiedImpl(@NotNull String name, @NotNull UUID uuid) {
|
||||
this(Component.text(name), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new named and identified implementation.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user