Questions About Development

Discussion in 'Plugin Development' started by azoundria, Jan 21, 2011.

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

    azoundria

    1) For Location, what's the unit?

    2) If I need to save data/settings with my plugin for later retrieval, what are my options?

    3) Is onDisable() run when the server shuts down (the 'stop' command)?

    4) The plugins= value in server.properties doesn't seem to have any effect. It still loads all the plug-ins in the plugins folder, regardless what I put for that.
     
  2. For location i think its x y z per block
    Flatfile mysql or sqlite
    Yes/when plugin disabled with command
    Hasn't been implemented as stiol dev build
     
  3. Offline

    Mixcoatl

    The unit is cubic meters.
    There is no built-in support for persistence at the present time. You will need to write your own persistence code using some mechanism that makes sense in the context of your plug-in and skill level.

    As rob4001 pointed out, most bukkit plug-in developers are leaning strongly towards using MySQL or SQLite for persistence. All of the implementations using these technologies, thus far, are home grown, as yours would be.

    If you're going to roll your own object persistence you actually have quite a few options:
    • SQLite is a single-file extremely light-weight database that exists entirely in the public domain.
    • MySQL is a very, very popular open source database in the Linux community. It's very fast and very free, but it requires some experience to be able to setup and maintain it correctly. (Your server host may be willing to do some portion of this work for you for a fee.)
    • Serialized objects are often used to store Java objects on disk. The format is a platform-independent binary format specific to the Java language. It is not human readable, which is a consideration to make when choosing a persistence technology.
    • Properties files are very nice for small, simple objects. They consist only of key-value pairs and are wholly incapably, without substantial effort on the part of the programmer, of representing more complex data structures. Properties files are human readable.
    • XML files, like properties files, are human readable text files. They're more appropriate for complex Java objects, but they require quite a bit more code to successfully implement than either serialized objects or properties files. You'll need a basic understanding of XML syntax to make much sense of the XML document model or the resulting XML documents.
    • YML files are similar to XML files for are more structurally simple. Bukkit includes a package to read YML files but does not support them inherently as a persistence mechanism. You would need to write code similar to the XML or properties file choices to make use of YML.
    • Proprietary flat files are another choice available to you. You could create your own files containing your own data structures in any format that makes sense in your plug-in. They could be text or binary, structured or unstructured. Obviously, this would require some effort on your part to write the file parser, but there may be benefits if the other technologies lack some feature you require.
    To make your choice you must weigh the benefits and drawbacks of each technology, the learning curve, and the degree of complexity to which you're comfortable subjecting your users. All of this must be considered in the context of the data being persisted.
    I assumed so. I've never really tested it to see for certain.
     
  4. Offline

    phondeux

    A follow up question regarding MySQL - I want to use this, is there an easy way to do it within java or do you need to have the plugin users drop a mysql_driver.jar file in their server directory as a requirement?
     
  5. Offline

    Mixcoatl

    There are two pieces you need:

    MySQL Server
    If you're hosted on a Linux, CentOS, or FreeBSD server you may already have MySQL installed. At the shell prompt you can run this command to find out:

    % mysqladmin --version​

    You'll see some version information come back if it's installed and you have access to it. You may or may not need to contact your You can also download server binaries for most OSes from the following link: http://dev.mysql.com/downloads/mysql/5.5.html

    MySQL JDBC Driver
    You'll need to download the latest MySQL Connector/J driver. You can download it from the following link: http://dev.mysql.com/downloads/connector/j/ Remember to add this to your Eclipse project as a JAR not an external JAR. You may also need to update your manifest to include the driver .jar file in your class path.
     
  6. Offline

    phondeux

    Thanks Mixcoatl!

    If I add the driver jar file to my project, will people using my plugin need to do the same?
     
  7. Offline

    Mixcoatl

    They will need to have the same .jar file in their bin directory (I think it's the bin directory).

    Another option is to instruct Eclipse to include the dependencies in your .jar file when you export it. This will make your plug-in a lot larger. Users of your plug-in won't need to provide that .jar file but there may be some compatibility issues if they're using another version of the same driver (You would need to try it to see if it causes a problem.)
     
  8. Offline

    phondeux

    Thanks again! That was a sticking point for me; I've followed the guides and have looked over the bukkit API reference as well as the source code of a dozen apps and have got a 'hello world' plugin working so I was looking forward to putting actual functionality in my code and realized that as I outlined it I needed to use mysql.
     
Thread Status:
Not open for further replies.

Share This Page