System Cannot Find File, Server Crash.. [pls help]

Discussion in 'Plugin Development' started by Jeff.Halbert, Apr 19, 2012.

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

    Jeff.Halbert

    I'm trying to make a very simplistic chest protection system. The core concept is: when a chest is placed, it's registered to the player who placed it. After registration, no one can interact with the chest besides the player that placed/registered it. Please take a look at what I have so far, (im a noob, this is my first plugin attempt :-D), but it's not working. I'm recieving error messages in the server log that read:
    [SEVERE] plugins/ChestProtect/Chests/subspec.txt (The system cannot find the file specified)
    That's when ever the player doesn't already have a file. The chest is accessable to everyone. Then when you place another chest it doesn't allow ANYONE to interact with it, and the server crashes.

    I'm running craftbukkit-1.2.5-R1.0.jar for my server, and I have to two classes in the plugin jar.

    Where am I going wrong?

    [​IMG]
    [​IMG][​IMG]
     
  2. Offline

    CorrieKay

    wait hold on, you got the server to actually crash?

    ...with a plugin?

    Edit: now for the actual plugin itsself:

    Okay right off the bat im seeing an issue with your directory. instead of maindirectory as is, do this
    Static string maindirectory = this.getDataFolder()+File.separator+"Chests";

    Also, instead of just assuming the directory doesnt exist, you should do a check.

    In your player interact event, you should actually be listening for inventory open events instead.

    Once you do that, you can check if the inventory owner is an instance of a chest or double chest, etc.

    inside of the event, you dont make a check if the file exists, either use an if(!file.exists()) statement, or handle the exception that is thrown (the first one preferrably..)

    other than these things... uh, honestly i dont see how this can possible crash the server... and technically it should work. or at least, the errors should be more obvious... Would you care to post some stacktrace(s)?
     
  3. Offline

    Jeff.Halbert

    Yeah, i'm pretty new at this. Kinda learning java in the process... LOL. but yeah, I'm guessing the check for the registered chest is an infinite loop? And the MCserver freezes servers side(the same experience i usually get when it runs out of resources) and the MCclient crashes.

    Thanks for the insight, I'll give this a try....

    But how do I see stacktraces? sorry, again, I'm new to this whole thing.

    ok so... I rewrote the ChestListener Class. It now works! The only bug I found is: When a playerOne puts down a single chest, it will protect it. BUT, if playerTwo places a single chest next to playerOne's chest, thus making it a double chest, then playerTwo can access the chess. Is there a way to stop a player from making a double chest? If there is, can it be implemented only on chests that they do not own?

    Here's what I have so far.....
    [​IMG]
    [​IMG]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  4. Offline

    Neodork

    Euhm slap me if I'm wrong but I think you can do this:


    check if the placed chest is already next to one, then cancel the event and tell them, the spot was already registered for: ......
     
  5. Offline

    Jeff.Halbert

    yeah... the idea is what i'm looking for... but im so lost looking at your code... Time? it's throwing me off, i'm thinking like "what does time have to do with place?" but I think i'm just confused. Is there anyway you could explain it to me?

    Edit:
    oh wait ..... HAHAHHAHAHA, that's your signiture! man, i'm not as sharp as I thought..

    But yeah, how would I do that with code?
     
  6. Offline

    Njol

    when a chest is placed, check for chests around it:
    Code:java
    1. for (BlockFace f:new BlockFace[]{BlockFace.NORTH, Blockface.EAST, Blockface.SOUTH, BlockFace.WEST}) {
    2. if (event.getBlock().getRelative(f, 1).getType() == Material.CHEST) {
    3. // placed next to a chest!
    4. // if you want to you can check the owner of the already placed chest (event.getBlock().getRelative(f, 1))
    5. }
    6. }


    You have not been the first one to mistake his signature for part of the post, and will likely not be the last one.
     
  7. Offline

    Jeff.Halbert

    oh man, thats freakin beautiful! Thanks man! you GOTTA see what I was about to try... LOL

    [​IMG]
    [​IMG]

    LMAO, garbage right? Thanks again man.
     
Thread Status:
Not open for further replies.

Share This Page