Who has a certain item?

Discussion in 'Plugin Development' started by MCmine.info, Jan 19, 2012.

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

    MCmine.info

    I want to make a very simple plugin which is linked to a text file. When a Person has a specific item on them, there name is put into a textfile.

    For example:

    The item is a Diamond Sword.

    Someone picks up a Diamond Sword and there name is placed into the textfile. However there name is only in the textfile aslong as they have it in there inventory. So if they lose it or drop it then there name is taken out of the textfile.

    It seems fairly easy to do and I'm hoping it is. I'm new to Plugin Development so any help would be greatly appreciated.
     
  2. Offline

    wwsean08

    yah you would just need to use a player listener, listening for a PlayerPickupItemEvent, PlayerDropItemEvent, PlayerRespawnEvent. However the down side is this will not tell you if they for example put that item into a chest, for that you would need to use the server side spout and use at least one of their inventory events (at least the InventoryCloseEvent) as a custom event in bukkit.
     
  3. Offline

    Father Of Time

    May I ask why you are writing it to a file? unless it's for persistence or because you wish to access this information outside game I don't see a reason for it, just use a collection.
     
  4. Offline

    wwsean08

    i agree, i just have given up on asking why people want to do stuff that makes no sense and just try and answer what i can in their question lol
     
  5. Offline

    Father Of Time

    I can understand that, but sometimes by questioning them you introduce concepts previously unknown to them, and may inspire a better concept than they originally had.

    There is a fine line between sharing knowledge and appearing pompous, But I'm willing to walk it!:p
     
  6. Offline

    MCmine.info

    Yes I want to access the information from a website.
     
  7. Offline

    wwsean08

    haha, yah i understand, and believe me, you're amongst my favorite as far as advice givers go.

    So ya you'll want those events that I mentioned, my recomendation is that you put the player names in a list, from there everytime a person either removes or adds the item to their inventory you write the list to a configuration file (or if you want this in html and stylized, write a file writer which will overwrite the old html file).
     
    Father Of Time likes this.
  8. Offline

    Father Of Time

    Aww, you are going to make me blush! Seriously though, thank you. :D

    Back to the OP, using a text file as a website backend would be simply horrible... You don't have direct record access with txt files, meaning every time you wanted to query specific information you would have to loop through every record, among a lot of other amazingly inefficient reasons not to do it.

    If you want to feed information from a server to a web front end I would strongly advise using a MySQL back-end with a PHP front-end (or something comparable). SQL is a Query relational database system that allows you to add, remove, alter, and query specific record sets, pretty much perfect for a web display environment; and PHP will allow you to dynamically design your web front end.

    Crap, gotta run... work!
     
Thread Status:
Not open for further replies.

Share This Page