+ update nbt api
This commit is contained in:
		@@ -122,10 +122,10 @@ public class NBTBase {
 | 
			
		||||
        return type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static NBTBase formNBTBase(Object obj) {
 | 
			
		||||
    public static NBTBase toNBT(Object obj) {
 | 
			
		||||
        if (obj instanceof String) {
 | 
			
		||||
            if (SHORT_PATTERN.matcher(obj.toString()).matches()) {
 | 
			
		||||
                return formNBTBase(Short.valueOf(obj.toString().substring(0, obj.toString().length() - 1)));
 | 
			
		||||
                return toNBT(Short.valueOf(obj.toString().substring(0, obj.toString().length() - 1)));
 | 
			
		||||
            }
 | 
			
		||||
            return new NBTBase((String) obj);
 | 
			
		||||
        } else if (obj instanceof Integer) {
 | 
			
		||||
@@ -144,11 +144,11 @@ public class NBTBase {
 | 
			
		||||
            return translateList(new NBTList(), (List) obj);
 | 
			
		||||
        } else if (obj instanceof Map) {
 | 
			
		||||
            NBTCompound nbtCompound = new NBTCompound();
 | 
			
		||||
            ((Map) obj).forEach((key, value) -> nbtCompound.put(key.toString(), formNBTBase(value)));
 | 
			
		||||
            ((Map) obj).forEach((key, value) -> nbtCompound.put(key.toString(), toNBT(value)));
 | 
			
		||||
            return nbtCompound;
 | 
			
		||||
        } else if (obj instanceof ConfigurationSection) {
 | 
			
		||||
            NBTCompound nbtCompound = new NBTCompound();
 | 
			
		||||
            ((ConfigurationSection) obj).getValues(false).forEach((key, value) -> nbtCompound.put(key, formNBTBase(value)));
 | 
			
		||||
            ((ConfigurationSection) obj).getValues(false).forEach((key, value) -> nbtCompound.put(key, toNBT(value)));
 | 
			
		||||
            return nbtCompound;
 | 
			
		||||
        }
 | 
			
		||||
        return new NBTBase("error: " + obj);
 | 
			
		||||
@@ -156,7 +156,7 @@ public class NBTBase {
 | 
			
		||||
 | 
			
		||||
    public static NBTList translateList(NBTList nbtListBase, List list) {
 | 
			
		||||
        for (Object obj : list) {
 | 
			
		||||
            NBTBase base = formNBTBase(obj);
 | 
			
		||||
            NBTBase base = toNBT(obj);
 | 
			
		||||
            if (base == null) {
 | 
			
		||||
                TabooLib.getLogger().warn("Invalid Type: " + obj + " [" + obj.getClass().getSimpleName() + "]");
 | 
			
		||||
                continue;
 | 
			
		||||
@@ -172,7 +172,7 @@ public class NBTBase {
 | 
			
		||||
            NBTBase base;
 | 
			
		||||
            if (obj instanceof ConfigurationSection) {
 | 
			
		||||
                base = translateSection(new NBTCompound(), section.getConfigurationSection(key));
 | 
			
		||||
            } else if ((base = formNBTBase(obj)) == null) {
 | 
			
		||||
            } else if ((base = toNBT(obj)) == null) {
 | 
			
		||||
                TabooLib.getLogger().warn("Invalid Type: " + obj + " [" + obj.getClass().getSimpleName() + "]");
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -64,6 +64,14 @@ public class NBTCompound extends NBTBase implements Map<String, NBTBase> {
 | 
			
		||||
        return this.value.put(key, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public NBTBase put(String key, Object value) {
 | 
			
		||||
        return this.value.put(key, NBTBase.toNBT(value));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public NBTBase putDeep(String key, Object value) {
 | 
			
		||||
        return putDeep(key, NBTBase.toNBT(value));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public NBTBase putDeep(String key, NBTBase value) {
 | 
			
		||||
        NBTBase compound = this, temp;
 | 
			
		||||
        String[] keySplit = key.split("\\.");
 | 
			
		||||
@@ -112,7 +120,7 @@ public class NBTCompound extends NBTBase implements Map<String, NBTBase> {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public NBTBase getOrDefault(Object key, NBTBase defaultValue) {
 | 
			
		||||
        return this.value.getOrDefault(key, defaultValue);
 | 
			
		||||
        return this.value.getOrDefault(String.valueOf(key), defaultValue);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user