sendBlockChange Problems - [Urgent]

Discussion in 'Plugin Development' started by Build_and_Break, Apr 13, 2014.

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

    Build_and_Break

    Hello all,

    About 2 months ago, I began work on a project known as Location Watchdog, which is a location logger and viewer. It uses MySQL statements to log and result sets to get the data. A while back I posted a thread asking for help with Advanced Block Manipulation. Since then, I've devised a way to make massive amounts of block changes from data pulled from a MySQL Result Set (And undo the block changes!). It's simple, and I feel dumb for wasting time on it. Anyway, to the point. After resolving most of the errors in the code, I ran a test which was sorta lame. Here's my code: http://hastebin.com/panecovifa.avrasm

    Here's the problem: No block changes actually happen (that I can see).
    Here's what works: I am successfully entered into the hashmap. The command IS ran. I get the message saying it's showing me what it has logged for that player. I can run the done command, but it obviously has no impact. Other commands work, and my plugin.yml is valid and in sync with the .jar.

    Bump: I should mention: I am positive the database has information, because if it did not, it would tell me.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    RawCode

    zero debug messages?
    i strongly advice to add debug trace to your code.
     
  3. This won't fix your error - But you haven't checked to see whether the CommandSender was an instanceof Player, and not console.

    Debug this:
    Code:
    while (res.next()) {
        int x = res.getInt("x");
        int y = res.getInt("y");
        int z = res.getInt("z");
        System.out.println("X: " + x + ", Y: " + y + ", Z: " + z);
        run.sendBlockChange(new Location(w, x, y, z), 113, (byte) 0);
        run.sendBlockChange(new Location(w, x, y + 1, z), 89, (byte) 0);
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Build_and_Break

    OK, thanks. I'm away from home at the moment, but I'll try soon.

    OK, tried that and tried with getLogger.info(""), but neither outputted ANYTHING to the console. Hmm.... Again, the problem shouldn't be that there isn't data, because it can rule that out. Perhaps the while loop is inefective?

    OK, just ran it so it would tell me each base location to the sender, and yet it still returned nothing. Either the loop isn't being executed, or there's some sort of far worse problem.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  5. Sorry, I'm busy with my own plugins, I can't help. Anyone else?
     
  6. Offline

    xize

    Build_and_Break

    it sounds like the tables doesn't exist, but when I looked futher I see you use TEXT in the table creation while actually there it should be INT, then futher I see you try to resolve a actually int from the database while it actually is set to a TEXT.

    your code, look to the x, y, z tables:
    Code:
    tableSetup
    .execute("CREATE TABLE IF NOT EXISTS `LW` (`ID` INTEGER PRIMARY KEY NOT NULL, `ign` TEXT NOT NULL, `w` TEXT NOT NULL, `x` TEXT NOT NULL, `y` TEXT NOT NULL, `z` TEXT NOT NULL)");
    
    and how you resolve it is:
    Code:
     while (res.next()) { int x = res.getInt("x");
    int y = res.getInt("y");
    int z = res.getInt("z");
    run.sendBlockChange(new Location(w, x,
    y, z), 113, (byte) 0);
    y++;
    run.sendBlockChange(new Location(w, x,
    y, z), 89, (byte) 0);
    }
    
    this is probably the error because the table creation should be:

    Code:
    tableSetup
    .execute("CREATE TABLE IF NOT EXISTS `LW` (`ID` INTEGER PRIMARY KEY NOT NULL, `ign` TEXT NOT NULL, `w` TEXT NOT NULL, `x` INT NOT NULL, `y` INT NOT NULL, `z` INT NOT NULL)");
    
    not sure if a int in sql can be null could possible throw a exception though so probably you may need to remove the NOT NULL there.
     
  7. Offline

    Build_and_Break

    Might have this figured out. My if(Res.first) was incorrectly positioned.

    Oh my! I feel like a total idiot. I'll fix this right away. I don't believe this is the fix for the problem at hand, but thanks!

    Now it's telling me I don't have any logged locations in any world. Hmm......

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  8. Offline

    xize

    Build_and_Break
    oh wait I made a error I think the INT should be DOUBLE as Location .getX() returns a Double.
    and you are sure the tables exist in the db file?, if not you could use a program called sqlitebrowser its free plus it also shows all the tables I use it to debug it:p
     
  9. Offline

    Build_and_Break

    OK, I'll try that. I should clear my tables, too.

    Still says there is no data logged for me.

    Updated Code: http://hastebin.com/gifajurofo.avrasm

    There are still no logged locations for me, supposedly.

    Hmm, maybe it is incorrectly grabbing the data? I'm nearly positive there IS data for my player, because I waiting like a minute, which is enough for 4 logs, and still, it did not log. My config says to wait 15 seconds between logging.

    Edit: Or so it seems it did not log. Gah, I don't know anymore. This is pretty urgent, anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  10. Offline

    Build_and_Break

    Bump. Is there any possibility my database is blank? I checked in MySQL WB, and it did create the tables, columns, etc successfully.
     
  11. Offline

    Build_and_Break

    Bump again? Any news/help is useful. I have heard that asyncrepeating task isn't exactly stable, but I believe I've done mine right.
     
Thread Status:
Not open for further replies.

Share This Page