34 lines
980 B
Java
34 lines
980 B
Java
package eu.mikroskeem.utils.text;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class MinecraftText {
|
|
/**
|
|
* Validate Minecraft username
|
|
*
|
|
* @param name Name to validate
|
|
* @return Whether name is valid or not
|
|
*/
|
|
public static boolean validateUsername(@NotNull String name){
|
|
if(
|
|
(name.length() > 16 || name.length() < 3) || /* Check length */
|
|
!name.matches("^[A-Za-z0-9_]+$") /* Check characters */
|
|
){
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Translate alternate color codes to Minecraft color codes.
|
|
*
|
|
* Note: shittier version of {@link org.bukkit.ChatColor}
|
|
* @param seq Sequence to replace
|
|
* @param text Text to do replace on
|
|
* @return Text with replaced color codes
|
|
*/
|
|
@NotNull public static String translateAltColors(char seq, @NotNull String text){
|
|
return text.replace(seq, '§');
|
|
}
|
|
}
|