handle invalid identifiers, fixes #980
This commit is contained in:
1 parent
8dc1556790
commit
d07fe18bb5
6 files changed
+47
-49
No files matched your search
@@ -1,6 +1,9 @@
|
||||
package carpet.script.utils;
|
||||
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.InvalidIdentifierException;
|
||||
import org.lwjgl.system.CallbackI;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -13,4 +16,16 @@ public class InputValidator {
|
||||
return simplified;
|
||||
}
|
||||
|
||||
public static Identifier identifierOf(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Identifier(string);
|
||||
}
|
||||
catch (InvalidIdentifierException iie)
|
||||
{
|
||||
throw new InternalExpressionException("Incorrect identifier format '"+string+"': "+iie.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user