Bounty

Discussion in 'Plugin Development' started by thomasb454, Mar 12, 2014.

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

    thomasb454

    Hello Bukkit,

    I've been assigned a task; create a bounty plugin. Within the specification it states that the bounties must still be there even after a reboot (save the Hash Map to file, then load it) and there must be a configurable time limit to as when the bounties are removed.

    Saving and reading these from a config file will be very unstable and will cause lag (500 player server), so what is your advice, how to save the bounties? Also, how would I go about removing the correct bounties are the correct time, add a time stamp to the data that is saved? I really am stumped; that's why I am asking for some help,

    Thanks in advance,
    Thomas.
     
  2. Offline

    tommycake50

    Store it in an SQLite database and put a Unix timestamp and how many milliseconds untill the bounty should expire, then check the database every so often and check if the timestamp now - the timestamp >= the length of the bounty and if so remove it.

    If you can't be bothered with SQL then YAML/whatever is the way to go.
     
  3. Offline

    thomasb454


    I've never really used SQLite, I'll take a look though.
     
  4. Offline

    Maurdekye

    thomasb454 No, it won't be very laggy unless you flush the file often. Using getConfig().getInt() and .setInt() that often will be completely fine, as long as you don't call saveDefaultConfig() too often. Even if you have doubts, just try it and see how laggy it really is. It honestly should be fine if you just put one saveDefaultConfig() in your onDisable().
     
    tommycake50 likes this.
  5. Offline

    thomasb454


    I'm going to need to check if x player killed y player, if so x player gets x amount which z player has pre-defined, so whatever way I do this will be intense. I can't even think of a way to give them a unique ID
     
  6. Offline

    Mathias Eklund

    thomasb454 Their usernames should be the "unique ID" you need.
     
  7. Offline

    thomasb454


    No no no.

    If I player X place a bounty on player Z, then player Y kills player Z how would it know to remove me too (I think I am confusing myself, this is probably really easy ._.)
     
  8. Offline

    Mathias Eklund

    Just add a node in the files that supplies that information.
     
  9. Offline

    thomasb454


    Could you give me an example of this (I don't know if you can tell, but I am REALLY confused)
     
  10. Offline

    Mathias Eklund

    thomasb454 when someone sets a bounty on someone, add that players name inside the config section for that bounty.
     
  11. Offline

    Maurdekye

    thomasb454 Doesn't matter, it won't be any more intense than using a HashMap. Because that's probably what's saved for use when you load a config file in. Why are you complaining so much without having tried it? Just implement it like that and if it's too laggy, then use the previous method. But I can almost guarantee you it'll be just as fast.
     
  12. Offline

    thomasb454



    Okay, will do. Also I wasn't complaning, just wondering.



    Thanks - that cleared it up a bit for me. :p
     
  13. Offline

    Mathias Eklund

Thread Status:
Not open for further replies.

Share This Page