mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Auto casted 1f, 1.0f to to floats same for doubles
This commit is contained in:
1 parent
1dbeaf2c84
commit
2e99dffc33
1 file changed
+14
-4
@@ -1683,10 +1683,20 @@ public class ScriptDocument {
|
||||
}
|
||||
|
||||
// Numeric literals
|
||||
if (expr.matches("-?\\d+[lL]?")) {
|
||||
if (expr.toLowerCase().endsWith("l")) {
|
||||
return TypeInfo.fromPrimitive("long");
|
||||
}
|
||||
// Float: can be 10f, 10.5f, 10.f, .5f
|
||||
if (expr.matches("-?\\d*\\.?\\d+[fF]")) {
|
||||
return TypeInfo.fromPrimitive("float");
|
||||
}
|
||||
// Double: can be 10d, 10.5d, 10.5, .5, 10., but NOT plain integers
|
||||
if (expr.matches("-?\\d*\\.\\d+[dD]?") || expr.matches("-?\\d+\\.[dD]?") || expr.matches("-?\\d+[dD]")) {
|
||||
return TypeInfo.fromPrimitive("double");
|
||||
}
|
||||
// Long: 10L or 10l
|
||||
if (expr.matches("-?\\d+[lL]")) {
|
||||
return TypeInfo.fromPrimitive("long");
|
||||
}
|
||||
// Int: plain integers without suffix
|
||||
if (expr.matches("-?\\d+")) {
|
||||
return TypeInfo.fromPrimitive("int");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user