I want to add a feature but don't know how to :(

Discussion in 'Plugin Development' started by HDMelonGaming, Jan 29, 2016.

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

    HDMelonGaming

    Hello! I have recently made a plugin which counts the amount of villager kills on the server. I want to add a feature to this that gives the player a villager spawner once the number hits 1000. Any idea on how to do this? That would be fantastic!

    Main Class: http://pastebin.com/K3nEZzit

    Listener: http://pastebin.com/6gPwKz2z
     
  2. Offline

    Xerox262

    @HDMelonGaming if you would like to do it only when it reaches 1000 then in your listener check the amount of villager kills, if it's 1000 then add the spawner. If you want to do it every 1000 kills then again inside your listener add a modulo if to check if it's a 1000th kill
    Code:
    if (killcount % 1000 == 0) {
        // Add the spawner every 1000 kills
    }
    Code:
    if (killcount == 1000) {
        // Add the spawner only on the 1000 kill and never again
    }
    P.S. Rather than adding 1 on when setting it you should add one on when it's declared, it means you don't have to keep adding to check
    Code:
    int killcount = configGetter.getConfig().getInt("villagerkills");
    //Add one kill to the counter
    configGetter.getConfig().set("villagerkills", killcount +1);
    Changed to
    Code:
    int killcount = configGetter.getConfig().getInt("villagerkills") + 1;
    // Check the amount and add the item.
    configGetter.getConfig().set("villagerkills", killcount);
     
  3. Offline

    HDMelonGaming

    Thank you! I've been trying to get the spawner to go into the players inventory using p.getInventory.addItem and it doesn't seem to work for me? Any ideas?
     
  4. Offline

    Xerox262

    Clarify how it doesn't work, does it add a spawner that is the wrong type? Does it not add the spawner at all? What happens? Also post what you have.
     
Thread Status:
Not open for further replies.

Share This Page