Setting a delay between the use of a spawner egg.

Discussion in 'Plugin Development' started by slater96, Feb 23, 2012.

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


    Hi, I need some help with setting a delay between each use of a spawner egg. I've managed to generate a config saying:

    # Default Configuration - MobEggs by slater96
    Enabled: false
    # Do you want a delay on the time each mob can be spawned?
    Delay: 5
    # Time in seconds, between each use of a MobEgg.

    Now I need to read the config so atm I have:
    if(plugin.getConfig().getBoolean("Enabled") == true){
    //do something
    I'm stuck on setting a delay so if any one can help it would be much appreciated. Thanks

    Bump anyone?

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


    HashMap<Player,Long> lastUseMap = new HashMap<Player,Long>();
    long millis = System.currentTimeMillis();
    if(lastUseMap.get(player) != null && (millis - lastUseMap.get(player))/1000 > delay)
        //allow spawn
        //forbid spawn
  3. Offline

    dark navi

    delay = Integer.parseInt(plugin.getConfig().getString("Delay"));
Thread Status:
Not open for further replies.

Share This Page