semi-auto cleanup
This commit is contained in:
1 parent
cad80f82c6
commit
8f61271606
99 files changed
+11463
-8007
No files matched your search
@@ -3,27 +3,31 @@ package carpet.script.utils;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class InputValidator {
|
||||
public static String validateSimpleString(String input, boolean strict)
|
||||
public class InputValidator
|
||||
{
|
||||
public static String validateSimpleString(final String input, final boolean strict)
|
||||
{
|
||||
String simplified = input.toLowerCase(Locale.ROOT).replaceAll("[^A-Za-z0-9+_]", "");
|
||||
final String simplified = input.toLowerCase(Locale.ROOT).replaceAll("[^A-Za-z0-9+_]", "");
|
||||
if (simplified.isEmpty() || (strict && !simplified.equals(input)))
|
||||
{
|
||||
throw new InternalExpressionException("simple name can only contain numbers, letter and _");
|
||||
}
|
||||
return simplified;
|
||||
}
|
||||
|
||||
public static ResourceLocation identifierOf(String string)
|
||||
public static ResourceLocation identifierOf(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new ResourceLocation(string);
|
||||
}
|
||||
catch (ResourceLocationException iie)
|
||||
catch (final ResourceLocationException iie)
|
||||
{
|
||||
throw new InternalExpressionException("Incorrect identifier format '"+string+"': "+iie.getMessage());
|
||||
throw new InternalExpressionException("Incorrect identifier format '" + string + "': " + iie.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user