MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / parse

Method parse

src/main/java/net/minecraft/nbt/JsonToNBT.java:455–551  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

453 }
454
455 public NBTBase parse() throws NBTException
456 {
457 try
458 {
459 if (DOUBLE.matcher(this.jsonValue).matches())
460 {
461 return new NBTTagDouble(Double.parseDouble(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
462 }
463
464 if (FLOAT.matcher(this.jsonValue).matches())
465 {
466 return new NBTTagFloat(Float.parseFloat(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
467 }
468
469 if (BYTE.matcher(this.jsonValue).matches())
470 {
471 return new NBTTagByte(Byte.parseByte(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
472 }
473
474 if (LONG.matcher(this.jsonValue).matches())
475 {
476 return new NBTTagLong(Long.parseLong(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
477 }
478
479 if (SHORT.matcher(this.jsonValue).matches())
480 {
481 return new NBTTagShort(Short.parseShort(this.jsonValue.substring(0, this.jsonValue.length() - 1)));
482 }
483
484 if (INTEGER.matcher(this.jsonValue).matches())
485 {
486 return new NBTTagInt(Integer.parseInt(this.jsonValue));
487 }
488
489 if (DOUBLE_UNTYPED.matcher(this.jsonValue).matches())
490 {
491 return new NBTTagDouble(Double.parseDouble(this.jsonValue));
492 }
493
494 if (this.jsonValue.equalsIgnoreCase("true") || this.jsonValue.equalsIgnoreCase("false"))
495 {
496 return new NBTTagByte((byte)(Boolean.parseBoolean(this.jsonValue) ? 1 : 0));
497 }
498 }
499 catch (NumberFormatException var6)
500 {
501 this.jsonValue = this.jsonValue.replaceAll("\\\\\"", "\"");
502 return new NBTTagString(this.jsonValue);
503 }
504
505 if (this.jsonValue.startsWith("[") && this.jsonValue.endsWith("]"))
506 {
507 String s = this.jsonValue.substring(1, this.jsonValue.length() - 1);
508 String[] astring = Iterables.toArray(SPLITTER.split(s), String.class);
509
510 try
511 {
512 int[] aint = new int[astring.length];

Callers

nothing calls this directly

Calls 13

parseDoubleMethod · 0.80
lengthMethod · 0.80
parseLongMethod · 0.80
startsWithMethod · 0.80
endsWithMethod · 0.80
trimMethod · 0.80
matchesMethod · 0.65
parseFloatMethod · 0.45
parseIntMethod · 0.45
parseBooleanMethod · 0.45
toArrayMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected