Advertisement
Guest User

Untitled

a guest
May 14th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public void saveInventory(List<ItemStack> items){
  2. try {
  3. FileOutputStream fos = new FileOutputStream(new File(dir));
  4. BukkitObjectOutputStream boos = new BukkitObjectOutputStream(fos);
  5. boos.writeObject(items);
  6. boos.close();
  7. } catch (IOException ioexception) {
  8. ioexception.printStackTrace();
  9. }
  10. }
  11.  
  12. @SuppressWarnings("unchecked")
  13. public List<ItemStack> loadInventory(){
  14. List<ItemStack> loadedList = null;
  15. try {
  16. FileInputStream fis = new FileInputStream(new File(dir));
  17. BukkitObjectInputStream bois = new BukkitObjectInputStream(fis);
  18. loadedList = (List<ItemStack>) bois.readObject();
  19. bois.close();
  20. } catch (IOException ioexception) {
  21. ioexception.printStackTrace();
  22. return null;
  23. } catch (ClassNotFoundException classNotFoundException) {
  24. classNotFoundException.printStackTrace();
  25. return null;
  26. }
  27. return loadedList;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement