SHARE
TWEET

Untitled

a guest Aug 13th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.aragone.framecraft;
  2.  
  3. import org.bukkit.entity.Player;
  4. import org.bukkit.inventory.ItemStack;
  5. import org.bukkit.inventory.meta.Damageable;
  6.  
  7. public class InventorySerializer {
  8.    
  9.     private SqlDatabase sql;
  10.    
  11.     public void saveInventory(Player p) {
  12.  
  13.        
  14.         sql = new SqlDatabase("jdbc:mysql://","localhost","minesr","root","");
  15.        
  16.         String invToString = new String();
  17.         int i = 0;
  18.        
  19.         while(i < 36) {
  20.            
  21.             if(p.getInventory().getItem(i) == null)
  22.                
  23.                 i++;
  24.            
  25.             else {
  26.                
  27.                 ItemStack item = new ItemStack(p.getInventory().getItem(i));
  28.                
  29.                 invToString += i + "#";
  30.                 invToString += "t@" + item.getType().toString() + ":";
  31.                 invToString += "a@" + item.getAmount() + ":";
  32.                
  33.                 Damageable meta = (Damageable) item.getItemMeta();
  34.                
  35.                 invToString += "d@" + meta.getDamage() + ":";
  36.                 invToString += "e@" + item.getEnchantments().toString() + ";";
  37.                
  38.                 i++;
  39.                
  40.             }
  41.            
  42.         }
  43.        
  44.         sql.setInventory(p, invToString);
  45.        
  46.     }
  47.    
  48.     public void restoreInventory(Player p) {
  49.        
  50.         //String[] serializedBlocks = sql.getInventory(p).split(";");
  51.        
  52.     }
  53.    
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top