| package net.querz.nbt.util; |
| import net.querz.nbt.NumberTag; |
| import net.querz.nbt.Tag; |
| public static Number toNumber(Tag tag) { |
| if (tag != null && tag instanceof NumberTag) |
| return (Number) tag.getValue(); |
| return new Byte((byte) 0); |
| * checks if tag is a Number and interprets it as a boolean. |
| * @return true if the Number is > 0 |
| public static boolean toBoolean(Tag tag) { |
| return toNumber(tag).byteValue() > 0; |
| public static String joinTagString(String delimiter, Object... o) { |
| StringBuilder sb = new StringBuilder(); |
| sb.append((first ? "" : delimiter) + ((Tag) obj).toTagString()); |
| public static String joinArray(String delimiter, Object array) { |
| StringBuilder sb = new StringBuilder(); |
| for (int i = 0; i < Array.getLength(array); i++) { |
| sb.append((first ? "" : delimiter) + Array.get(array, i)); |
| public static String createNamePrefix(Tag tag) { |
| return tag.getName().equals("") ? "" : (tag.getName() + ":"); |