getDatabase().save(class) not working...

Discussion in 'Plugin Development' started by Prgr, May 6, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Prgr

    So right now I am working with javax persistence and I need to know why it is not saving my class in the database. It isnt throwing any errors but when I load or unload a class from the database it does not save.
    Code:java
    1. frominventory.setIntIDs(fromIDs);
    2. System.out.println("Saving "+frominventory.getPlayerName()+"'s Inventory FROM "+frominventory.getWorldName());
    3. System.out.println("IDs:" + frominventory.getStringIDs());
    4.  
    5. plugin.getDatabase().save(frominventory);

    I can paste alot of code butit looks like this is the main focus, because my code will show the changes and then when i load this backup it is reverted back to what it was berfore using this:
    Code:java
    1. WorldInventory toinventory = plugin.getDatabase()
    2. .find(WorldInventory.class).where()
    3. .ieq("worldName", toWorld.getName())
    4. .ieq("playerName", player.getName()).findUnique();
    5.  
    6. if(toinventory==null){
    7. player.sendMessage("Its your first time in the world " + toWorld.getName());
    8. toinventory = new WorldInventory();
    9. toinventory.setPlayer(player);
    10. toinventory.setWorldName(toWorld.getName());
    11. player.getInventory().clear();
    12. } else {
    13. player.sendMessage("Loading inventory for world: " + toWorld.getName());
    14. int[] toIDs = toinventory.getIntIDs();
    15. System.out.println(toWorld.getName()+"IDs:" + toinventory.getStringIDs());
    16. for(int i=0; i<35; i++){
    17. player.getInventory().setItem(i, new ItemStack(toIDs, 1));
    18. }
    19. }
    20.  

    The strange part is when I delete the db file, it will save the inventory the first time but that inventory is not saved over afterwards.
     
  2. Offline

    bluej100

Thread Status:
Not open for further replies.

Share This Page