public class Database implements Serializable {
@Serial
private static transient final long serialVersionUID = -1681012206529286330L;
public static final String filePath = "database.ser";
private ItemStack[] activeItems;
private ItemStack[] collectedItems;
private ItemStack[] disabledItems;
...
public boolean saveData(String filePath) {
Bukkit.getServer().getLogger().log(Level.INFO, "Trying to save...");
try {
FileOutputStream fileOut = new FileOutputStream(filePath);
BukkitObjectOutputStream out = new BukkitObjectOutputStream(fileOut);
out.writeObject(this);
out.close();
Bukkit.getServer().getLogger().log(Level.INFO, "Data saved!");
return true;
} catch (Exception e) {
e.printStackTrace();
Bukkit.getServer().getLogger().log(Level.INFO, "!SAVING FAILED!");
return false;
}
}
...
}
Hey,
im trying to save the entire Database Class with the active,collected and disabledItems arrays into a file. Is this the right way to go about it? Its loosely based on this https://www.spigotmc.org/wiki/save-load-data-files/
If i save the data this way no file gets created :/ Does anyone see why ?