[INACTIVE][DEV] Persistence v0.76 - Data-Driven Bukkit [677]

Discussion in 'Inactive/Unsupported Plugins' started by NathanWolf, Jan 29, 2011.

  1. Offline

    NathanWolf

    Persistence - Data-Driven Bukkit

    PLEASE NOTE
    Persistence is a developer API and framework- NOT a game or admin plugin.

    If you've come here looking for plugin/admin support for Spells, Wand, NetherGate or any other plugin that uses Persistence- please turn around and go back to that thread. Thank you for your cooperation!

    If you're a dev, then check the Persistence wiki for information on using the Persistence framework.

    View changelog on github
     
    Duccis likes this.
  2. Offline

    NathanWolf

    Hi! Sorry about that. Can you please try shutting down your server, deleting the files in "plugins/Persistence/" in starting up again?

    That should resolve your issue- if it does not, please come back and let me know. You can let me know if it does work, too, if you want- always good to hear :)

    Data migration is coming, I promise...
    --- merged: Feb 18, 2011 8:18 PM ---
    Ok, please see Groups. Done talking about permissions in here.
     
  3. Offline

    flerndip

    I appreciate the response. I'll try that now.

    Edit: that seems to fix the problem. thank you!
     
  4. Offline

    NathanWolf

    Glad I could help! These sorts of things are really "pre-beta" issues- I'm hoping it won't be a problem, hopefully soon.

    There is a new version of Persistence coming- I'm changing a lot.

    Basically, it's going to get broken up. I'm still working on the new structure, but it's going to consist of one or more libraries and one or more plugins (I've already broken out the experimental permissions work into its own plugin).

    Currently, I'm thinking:
    • A "Persistence" library for the core object persistence engine
    • A "BukkitPersistence" library for the plugin API and global DAOs
    • A "PersistencePlugin", what this thread will be become for, which is basically a UI for Persisitence.
    This will allow me to, among other things, maintain separate threads for each of the separate "pieces" of Persistence- so we don't get so much cross-chatter.

    And, if I do it right, it should represent the inherent modularity of this system much better, and making using Maven to bind to Persistence (any level of it) easier, etc.

    I'll do my best to make sure this makes things less complicated for everyone involved, rather than more.

    More news soon...
    --- merged: Feb 19, 2011 8:34 PM ---
    Persistence 0.44 Released

    Please grab this!

    I don't think anyone is using the built-in permissions support, but if you are then wait for 0.45 .... I dropped Permissions support. It's going to come back in Groups 0.12- that functionality doesn't belong in Persistence. It may not even need a Persistence 0.45, actually- I'm reserving that thought, just in case.

    This is kind of a rush-job, I had planned to jump straight to 0.50, but complications arose and I had to do some quick refactoring.

    However, there are a tremendous number of bugfixes, performance improvements, and other great things in 0.44 that were not in 0.41 ... so it's really worth updating. I've tested it, and it seems really solid in every way. I'll post an update if I find otherwise, or I'm sure you'll let me know :)

    Thanks,
    Nathan
     
  5. Offline

    Sc1234freak

    Nathan,

    There seems to be a problem with your latest update. I am running Craftbukkit version git-Bukkit-0.0.0-409-gcb2bced (MC: 1.2_01) {Latest as of 02/20} with Presistence v0.47 {Downloaded 02/20}. When I start the server, I get the error message, "SEVERE: Could not load plugins\Persistence.jar ..." I run multiple plugins on Windows Server 2008 R2 with Java 6 Version 23. Please let me know if you need the complete error message or complete plugin list. If possible, would you include the last stable .jar, thanks again. Let me know if you need anymore info.

    Sc1234freak
     
  6. Offline

    NathanWolf

    Could PM me your server log, or stick it here in a spoiler tag, please? After you've deleted your db files, like it says to do in the instructions for each update... this shouldn't be necessary much longer, I hope.
     
  7. Offline

    NoSDuDe

    Hi Nathan,

    I'm trying to run Persistence on the last version of CB and I get this log :

    version :This server is running Craftbukkit version git-Bukkit-0.0.0-409-gcb2bced (MC: 1.2_01)

    Code:
    21 feb. 2011 01:16:28 org.bukkit.plugin.SimplePluginManager loadPlugins
    GRAVE: Could not load plugins/Persistence.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:79)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:117)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:82)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:53)
            at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:171)
            at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:158)
            at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:110)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:209)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    Caused by: java.lang.NoSuchMethodException: com.elmakers.mine.bukkit.plugins.persistence.PersistencePlugin.<init>(org.bukkit.plugin.PluginLoader, org.bukkit.Server, org.bukkit.plugin.PluginDescriptionFile, java.io.File, java.io.File, java.lang.ClassLoader)
            at java.lang.Class.getConstructor0(Class.java:2723)
            at java.lang.Class.getConstructor(Class.java:1674)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:75)
            ... 8 more
    
    As I've never runned it, i don't have the Persistence folder with the db files in it.
    I've also tried to put the sqllitejdbc in a lib folder (like you tell in your instructions) but it didn't help.

    And i'm stuck here :(

    Anyway, thanks for your efforts this plugin is looking great :)
     
  8. Offline

    NathanWolf

    Did they drop that constructor already?

    I thought I'd updated for this... maybe not Persistence?

    Well, if that's the case, I'll just go ahead and update then :) I wanted to wait, because I did some refactoring- but if it's broken anyway....
    --- merged: Feb 21, 2011 5:19 AM ---
    0.48 Released

    Ok, this one is a bit tricky. I reorganized the code some- this was in preparation for breaking out the persistence engine itself to submit to the bukkit team as core tech (which has been done, now, officially! We'll see what they think of it!)

    So, devs - some classpaths have moved around, you're going to have to update. Sorry about that!
    And, admins - I *think* that all my plugins are broken right now with this latest Persistence, except for CrowdControl. Sorry- grab Persistence-47.jar if you need a fix!

    I'll get my plugins fixed up tomorrow, hopefully... very tired now :)
     
  9. Offline

    matejdro

    How can i store multiple different classes? Do i just have to change second parameter in get function?
     
  10. Offline

    NathanWolf

    Right, exactly. The put() function can determine the type from the class you're putting, but you have to tell get() what kind you want so it knows what to look for:

    Code:
    PlayerData myObject = new PlayerData(player);
    
    persistence.put(myObject); // no type required!
    myObject = persistence.get(player.getName(), PlayerData.class);
    
    // get() needs a Class as a second parameter
    There could be any number of objects of various types, stored in different databases/schema, even, that have an id matching that player's name. That's how, for instance, I store any player-specific data for any of my plugins- so there's a nether.player, for instance, a NetherGate entity with a PlayerData id, which means that it's id will always be a player name.

    So, without any additional type info, get() doesn't know whether you want global.player, or nether.player, or what.
     
  11. Offline

    matejdro

    Awesome. Thanks.
     
  12. Offline

    NathanWolf

    0.49 Released

    Release 0.49 should fix the functionality gap I left in 0.48 (whoops!)

    If you were calling hasPermissions directly, you kind of... lost the ability to do it in 0.48. Easily, anyway :)

    There is now a "Security" interface for this, which you can (as of 0.49) get at via PluginUtilities.getSecurity. I also threw "getPersistence" in there, because, well.... I'm hoping these are both functions that will go on bukkit.Server one day! :D

    Otherwise, this is unchanged from 0.48. You will, for 0.48 and up, by the way, have to do some classpath renaming. And... you'll have to do this again, at some point, I'm hoping- when it all changes to org.bukkit.persistence.

    Hopefully something like Eclipse will make this a 30-second job for you. Anything that has a "Find and Replace in Files" should work, really- and any IDE or even text editor worth it's salt should have that much at least :p

    I'll try to stop breaking things now, at least until integration, if/when that happens. :)
     
  13. Offline

    MonsterCWP

    Hi,

    The stuff about how to download Persistence in the description is a bit to technical for me. I want to get Persistence so I can get your NetherGate and CrowdControl plugins as well. I have SQLite, CrowdControl, NetherGate, and Persistence. What should I do?


    I get a Reeallly long error message. I'm guessing that the plugins are in the wrong place, though I'm not sure how i fix this.

    HTML:
    Feb 21, 2011 2:24:37 PM org.bukkit.plugin.SimplePluginManager loadPlugins
    SEVERE: Could not load plugins/CrowdControl.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:79)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:117)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:82)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:53)
        at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:171)
        at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:158)
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:110)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:209)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    Caused by: java.lang.NoSuchMethodException: com.elmakers.mine.bukkit.plugins.crowd.CrowdControlPlugin.<init>(org.bukkit.plugin.PluginLoader, org.bukkit.Server, org.bukkit.plugin.PluginDescriptionFile, java.io.File, java.io.File, java.lang.ClassLoader)
        at java.lang.Class.getConstructor0(Class.java:2706)
        at java.lang.Class.getConstructor(Class.java:1657)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:75)
        ... 8 more
    Feb 21, 2011 2:24:37 PM org.bukkit.plugin.SimplePluginManager loadPlugins
    SEVERE: Could not load plugins/NetherGate.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:79)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:117)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:82)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:53)
        at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:171)
        at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:158)
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:110)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:209)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    Caused by: java.lang.NoClassDefFoundError: com/elmakers/mine/bukkit/plugins/persistence/Persistence
        at com.elmakers.mine.bukkit.plugins.nether.NetherGatePlugin.<clinit>(NetherGatePlugin.java:695)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:73)
        ... 8 more
    Caused by: java.lang.ClassNotFoundException: com.elmakers.mine.bukkit.plugins.persistence.Persistence
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:30)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 12 more
    Feb 21, 2011 2:24:37 PM org.bukkit.plugin.SimplePluginManager loadPlugins
    SEVERE: Could not load plugins/Persistence.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:79)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:117)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:82)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:53)
        at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:171)
        at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:158)
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:110)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:209)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    Caused by: java.lang.NoSuchMethodException: com.elmakers.mine.bukkit.plugins.persistence.PersistencePlugin.<init>(org.bukkit.plugin.PluginLoader, org.bukkit.Server, org.bukkit.plugin.PluginDescriptionFile, java.io.File, java.io.File, java.lang.ClassLoader)
        at java.lang.Class.getConstructor0(Class.java:2706)
        at java.lang.Class.getConstructor(Class.java:1657)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:75)
        ... 8 more
    
     
  14. Offline

    NathanWolf

    All you need is the jar! There should be a link for Persistence.jar on the CrowdControl and NetherGate posts, that's where you should get it from (they all point to the same jar).

    This thread is really for devs who want to use persistence- you probably clicked on the "(thread)" link instead of the actual "Persistence.jar".

    Just drop both (or all three) jars into your plugins folder, that should be all you need to do :)

    Sorry for the confusion.
     
  15. Offline

    Sc1234freak

    Nathan, here is a screen shot of the errors. For some reason it did not write to the log, so I took a screen shot. This is with version v.049.

    per_error.jpg
     
  16. Offline

    NathanWolf

    What version of CB do you have? All my plugins require 357 or higher for the constructor change that shows up in your logs- so I think you're out of date.
     
  17. Offline

    Jimmy

    Need help!!
    Code:
    com.elmakers.mine.bukkit.plugins.persistence.Pers
    com/elmakers/mine/craftbukkit/persistence/Persist
    
    com.elmakers.mine.bukkit.plugins.persistence.Pers
    com/elmakers/mine/craftbukkit/persistence/Persist
    
    bukkit.plugins.spells.SpellsPlugin.onEnable(Spell
    
    java.JavaPlugin.setEnabled(JavaPlugin.java:140)
    java.JavaPluginLoader.enablePlugin(JavaPluginLoad
    
    SimplePluginManager.enablePlugin(SimplePluginMana
    
    kkit.CraftServer.loadPlugin(CraftServer.java:74)
    kkit.CraftServer.loadPlugins(CraftServer.java:55)
    er.MinecraftServer.e(MinecraftServer.java:178)
    er.MinecraftServer.c(MinecraftServer.java:165)
    er.MinecraftServer.d(MinecraftServer.java:117)
    er.MinecraftServer.run(MinecraftServer.java:217)
    er.ThreadServerApplication.run(SourceFile:512)
    I'm using Persistence v0.47 because when I use 0.49 I get more errors besides this. I'm using CraftBukkit Build 409 and Spells v0.95.
     
  18. Offline

    NathanWolf

    I don't think the code tags will work for that- try spoiler?

    It's also cut off, but at any rate- if you're using one of my plugins, I'd appreciate bug reports there, not here. And make sure you follow all the upgrade instructions over there.

    And this would all be with latest versions- I don't support anything but that, sorry. I'm running latest with no issues- start clean (just delete the "Persistence" folder in plugins) if you think you've got bad data.
     
  19. Offline

    Jimmy

    Thanks nathan! Deleting the folder worked. I found another problem I had. I had an old plugin that hasn't been updated that uses Persistence. Sorry, I didn't know how to use spoilers so I just used code. Just found out it's "
    Show Spoiler
    "
     
  20. Offline

    NathanWolf

    You got it! ;)

    Took me a while to find that, too- I guess there's also a FAQ tag?

    Anyway, glad you got going!
     
  21. Offline

    matejdro

    How can i check if object exists? Like:

    Code:
    Boolean exists = persistence.contains(player.getName(), PlayerData.class);
    

    EDIT: first something more important:I have to add my @PeristField to each variable and get/set in my class? In that case, do i have to add it to both get and set? Sorry I'm little confused.

    EDIT2: What am i doing wrong?

    Code:
    @PersistField(id=true)
    	public String getName()
    	{
    		return name;
    	}
    Code:
    [WARNING] Persistence: Field com.matejdro.bukkit.jail.JailPrisoner.getName is not persistable, type=java.lang.String
     
  22. Offline

    NathanWolf

    The easiest (and perhaps only) way is this:

    Code:
    boolean exists = persistence.get(objectId, ObjectClass.class) != null;
    So, basically get the object you want- if it doesn't exist, you'll get null back. If I were to add a "contains" kind of thing, this is all it would do- so I'm probably not going to add one.... maybe later, I'd have to think about it. Since it would actually load data (if the cache is empty), I think that's a bit confusing.

    Yes- you must markup your classes with @PersistClass and the fields you want to save/load with @PersistField. That's the easiest way, anyway, and probably the only way that will be supported at the interface-level API for a bit (now that there is such an abstraction in the code).

    You only need @PersistedField on either the getter or the setter. But you have to have both, generally (you can go without a setter if you mark the field readonly).

    It's possible that you're missing a setter?

    I'm actually working in here myself right now, and got this very error- it turns out I was missing a setter (Well, not missing, exactly, just a typo in the name!). I've added some better log prints for this, I'll try to get an update out soon :)

    That's probably your issue, though- there were only two reasons that line above would get printed- one was a missing setter, and the other was a totally bogus setter name (I think you'd have to mark up a function that was just called "get" or something like that....)

    So, make sure you have a setName(), though it does not need the annotation, since you've got it on the getter.
     
  23. Offline

    matejdro

    Oh, i did not have a setter. Thanks!
     
  24. Offline

    NathanWolf

    Sure! Like I said, I just had the same problem, so I can relate :D

    Let me know if you have any more trouble... hoping to release Persistence 0.50 soon, some good bugfixes in here (and better logging for this specific case you're dealing with!)

    BTW, I have an issue open to turn these sorts of things into custom exceptions- that's really how this should be handled.
    --- merged: Feb 22, 2011 12:42 PM ---
    Well, ok actually...
    Persistence 0.50 Released

    This is mainly a maintenance release (check the changelog), but there is one new thing in here I want you all to be aware of, from a dev perspective:

    Persisted
    We now have a "Persisted" base class that I'm going to recommend you use as a common base class for all your Data Access Object's- you can see I've already done this for all the global DAOs.

    This class does a few really handy things for you:
    • Auto-generates a hash function based on your id. This is really important if you want to be able to use your object as a key in a HashTable.
    • Auto-generates a clone() function, which will only clone persistent data.
    • Maintains a reference to your PersistedClass, which can be handy at runtime (e.g. you can get to the Server instance that contains this instance of your DAO)
    So, while it's not required, I'm going to call it "best practice" to extend from Persisted when making a DAO (whenever you use @PersistClass, you're making a DAO, basically!).

    Some other cool things in here of note, all experimental:
    • First-round data migration is here, finally! Right now, it's very rough (and very dangerous)- it just auto-drops and re-creates a table if it detects that you changed your DAO. Going to have a better version out soon, but personally this will save me, as a plugin dev using Persistence, a tremendous number of headaches.
    • You can now, I think, created inherited DAO's - so you could, theoretically, extend from another DAO. I still can't think of a good use case for this, but it seems like supporting the concept may have been as easy as adding the meta-annotation @Inherited to @PersistField... haven't had a chance to actually try it yet, though.
    Please update, and let me know if you have any trouble!

    Thanks.
     
  25. Offline

    matejdro

    Can i create this?

    Code:
    @PersistField(id=true)
    	private String name;
    	@PersistField()
    	private int remaintime;
    	@PersistField()
    	private JailZone jail;
    	@PersistField()
    	private Boolean offline;
    	@PersistField()
    	private String transferDest = "";
    	@PersistField()
    	private Boolean releasing = false;
     
  26. Offline

    NathanWolf

    You can persist fields directly if you want (instead of getters/setters)- but they have to be public, either way!

    And if you reference an object that you persist (like JailZone), then JailZone must also have @PersistClass and at least a @PersistField(id=true).

    Or, if JailZone is just a structure that you want to use- put @PersistField(contained=true). This way, JailZone doesn't need to have an id- though it still needs @PersistClass and at least one @PersistField (to have something useful to persist, else why are you persisting a reference to it... if that makes sense!)

    The "contained" thing is sort of like using a structure instead of a class- it will add all of JailZone's data to your class. This is not really the most common use case- but it does often make sense for things like BlockVector or BoundingBox.

    Finally, if JailZone is something like a simple area that you want to contain- I'd urge you to consider using BoundingBox from my Gameplay library instead :)

    Hm... you may even be able to extend BoundingBox if you want, as of 0.50 ... and this may actually be a valid use-case, depending on what you want to do with JailZone :)
     
  27. Offline

    matejdro

    Thanks. Another question (sorry for having so many questions):

    Code:
    @PersistField(contained=true)
    	public Location getReleaseLocation()
    	{
    		return (new Location(freeWorld, freeX, freeY, freeZ));
    	}
    	
    	public void setReleaseLocation(Location input)
    	{
    		freeWorld = input.getWorld();
    		freeX = input.getX();
    		freeY = input.getY();
    		freeZ = input.getZ();
    	}
    Code:
    [WARNING] Persistence: class org.bukkit.Location does not have the @PersistClass annotation.
    How can i solve that? Location is class inside bukkit, so i cannot edit it to add persistance annotation.
     
  28. Offline

    NathanWolf

    I don't think any update was needed for Persistence and 1.3, FYI - 0.50 should be good.
     
  29. Offline

    Sc1234freak

    Nathan,

    I updated to CB 432 (Recomended Build) which runs MC Server 1.3. The server ran fully functional until I installed Persistence 0.50. This is the error I received.

    Thanks Again,

    Sc
     
  30. Offline

    NathanWolf

    Do you have the latest ProtectedDoors?
     
  31. Offline

    Sc1234freak

    Yes, I downloaded it a few hours ago. Do you think that is the probelm? It said it was enabled, but I guess that doesn't mean much.

    Sc
     

Share This Page