80 | * Returns empty NBTContainer if file does not exist. 81 | * 82 | * @param file file to read 83 | * @return NBTCompound holding file's nbt data 84 | * @throws IOException exception 85 | * @deprecated Use NBT.readFile(file) 86 | */ 87 | @Deprecated 88 | public static NBTCompound readFrom(File file) throws IOException { 89 | if (!file.exists()) 90 | return new NBTContainer(); 91 | return new NBTContainer(NBTReflectionUtil.readNBT(Files.newInputStream(file.toPath()))); 92 | } 93 | 94 | /** 95 | * Saves NBT data to the provided file. 96 | *
97 | * Will fully override the file if it already exists.
98 | *
99 | * @param file file
100 | * @param nbt NBT data
101 | * @throws IOException exception
102 | * @deprecated Use NBT.writeFile(file, nbt)
103 | */
104 | @Deprecated
105 | public static void saveTo(File file, NBTCompound nbt) throws IOException {
106 | if (!file.exists()) {
107 | file.getParentFile().mkdirs();
108 | if (!file.createNewFile())
109 | throw new IOException("Unable to create file at " + file.getAbsolutePath());
110 | }
111 | nbt.writeCompound(Files.newOutputStream(file.toPath()));
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTFloatList.java:
--------------------------------------------------------------------------------
1 | package de.tr7zw.changeme.nbtapi;
2 |
3 | import java.lang.reflect.Constructor;
4 | import java.lang.reflect.InvocationTargetException;
5 |
6 | import de.tr7zw.changeme.nbtapi.utils.nmsmappings.ClassWrapper;
7 | import de.tr7zw.changeme.nbtapi.utils.nmsmappings.ReflectionMethod;
8 |
9 | /**
10 | * Float implementation for NBTLists
11 | *
12 | * @author tr7zw
13 | *
14 | */
15 | public class NBTFloatList extends NBTList