Posts by angriff

A new update is now available, introducing seasons and more!
Latest hotfix: 0.8.0.2 (2024-12-30)

    Ok well the question came up with what Minos said that we would not load all the libraries in a plugin when you are putting together some code. I was make a call to a connection and kept getting an error until i found the single java.sql class package that made it go away. It was not intuitive in my opinion. I also create a lot of little plugins for my server that use common libraries. I find it easier to upgrade them that way but I wanted to make sure I was not slowing down computers doing that. Also I see that area protection and some third party plug-ins load tons of lines in the logs that appears to slow down boot into the game so I wanted to discuss optimization.



    from another thread..............Minos reply excerpted.


    To be able to use all the classes of a package you need to import it as java.sql.* so that the import includes all the classes of the package and not just one.


    having said that though it is not good practice to import huge packages if you are only going to use 3-4 classes thereof

    When a timer finishes and executes it action does the program logic continue from the last bracket? I know this sounds intuitive but I have a routine that works then when I place it in a different spot in the code is acts different in game. It starts another timer but somehow I cannot detect that timer running anymore.

    Minos when I try to use your PrepareStatement


    PreparedStatement prep = con.prepareStatement("UPDATE


    I get an error cannot find symbol PreparedStatement . Do I have to declare this a string?

    Nevermind I figured it out. I needed to import the java library item
    import java.sql.PreparedStatement;


    This is what frustrates me with examples.. there are hidden things programmers with experience know about that dont show up on examples in you find on the internet. To me once you attach a library it should have all the crap needed not having to import it every time for every class. It is really a wasteful time killing effort in my opinion. REWRITE JAVA NOW TO MAKE ME HAPPY> :cursing:8|:rolleyes:

    Oh, extra brackets don't matter btw, so even something like int a = ((((((((4 + 2)))))))); is totally legit (even though that's ugly). If was just referring to the wrong bracket positions, since this actually makes a difference ^^

    ya you called it red... was a typo when I transcribed it from the code.. Thanks for the help.. hope others can see through the chatter and it helps..


    this is more fun than building right now. :huh:

    I see the get Day and stuff but I have two questions


    How does in game day month date stuff work. Is it running only when the server has not been restarted? Is it running only from start to start and is totally fictitious.


    Is there a way to get a time date stamp in real time for a data point?

    Would be nice to have a visual.. but it appears that chunks are big blocks. Each chunk is broken into an array of blocks. So if something starts in Chunk x and block 1 and ends in chunk x+1 and block 1 it is 20 (mas o minus)blocks in that direction. Correct?


    So how are chunks numbered in blocks top to bottom or left to right.

    Well that is what is confusing. If positional coordinates are found int large numbers like 4658.49166.81 -1664.58. How does an area stored in small numbers relate If a size of a chunk is 20 x 20 blocks and 68 blocks high. Is this position 232 chunks away from the origin?

    I am not sure there is any case in Java needing such weirdly placed brackets :/ the most complex bracket structure you can find in Java is either a lambda expression (i.e. how you specify the runnable task of a timer) or a casting structure i.e. int a = (int) myTimer.getTick()
    but glad you have managed to get it working in the end :)

    ya it works great... expands the potential huge for me and makes it fun. 8o I will try to find that example and show you.


    Now I need to read a preset config file to set up basic parameters for a routine.

    You probably are most correct but I am a voodoo programmer... if it works dont muss with it, just keep holding your mouth sideways to make it work. Not much for semantics in programs just syntax though in communication I am.


    No yellow error other may than split text when highlighted.


    I have another routine similar that needed the brackets to execute the look up task as a complete variable, so I probably put them in when I was searching for the forward slash (/) solution.

    Just a minor correction, the line above is almost correct, but some brackets are at the wrong position (so it won't work this way). Probably you wanted it to look like this :)
    Database db1 = getSQLiteConnection(getPluginByName("Portals").getPath() + "/portals_pingperfect.db");

    Thanks, the extra parentheses (round brackets) are in a different place surrounding the getplugin statement. Maybe superfluous but is working.


    Database db1 =(getSQLiteConnection((getPluginByName("Portals").getPath()) + "/Portals_Pingperfect.db"));

    It is in the main plugins/teleport directory. No subdirectory to the main plugin. If you turned it into a .txt file rename it without the .txt after it is loaded into the plugin directory. You cant upload it here as a .conf so i uploaded it as a .txt. Rename to config.conf without .txt in the directory. I use Notepad to edit it as it does not change the ascii text to Rich Text Format (RTF).

    Files

    So yes it works. It gets the path. I open the connection and now having some sort of query exception catch issue that I should not have .


    oh ok.. here is the trick. You probably know this but for this NOOB to the sport i have to learn the hard way. The path only returns the path. If the DB is in the main plugin subdirectory you have to add the last / in front of the DB name.


    Database db1 =((getSQLiteConnection(getPluginByName("Portals").getPath()) + "/portals_pingperfect.db"));


    Thought I would elucidate for any casual readers here.



    Works like a charm guys.. THANKS !!! 8|:thumbsup:


    PS the rest of the path on my server has all those horrible \ that netbeans hates to the getpath thing worked just boss!

    Thanks got something similar and I trying to run it right now.. had a typo and got a null exception


    OOPS not finding it


    so from your example
    Database db1 =((getSQLiteConnection(getPluginByName("Portals").getPath()) + "portals_pingperfect.db"));


    Correct?


    Seems to get the connectin but I get bumped in an exception when I try to read. I will let you know.

    Just to complement Minotorious' great description, "Name_of_Plugin" is the "name:" entry of the plug-in plugin.yml.


    As plug-ins are unlikely to go or change while RW is running, you may rather safely get the target plug-in at your plug-in OnEnable method and keep it in a global variable:

    Java
    @Override
    public void onEnable()
    {
    targetPlugin = (TargetPlugin)getPluginByName(targetPluginName);
    // more initialisation...
    }

    You may need to add the target plug-in in your IDE as an external Library / JAR / ... in order for the target plug-in specific methods to be known and callable.

    There in lies an issue if I access some third party plug in. The name is likely to be similar to all the others since many use the world name and on my commercial server the World Database is pingperfect.db and many other plugins are pingperfect.db.


    Not using either Iconomy or Mirrwares bank backend on my server. This is other plugins and luascripts.