AFK Plugin Help. Help me understand a simple afk plugin :)

Discussion in 'Plugin Development' started by Jace_oio, Mar 25, 2013.

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

    Jace_oio

    Hi,

    I have been trying to understand the way a afk plugin works but failed.
    All the code ive been trying to study is just too complicated, so I was wondering if any one could show me a very very simple example.
    When I say afk plugin I mean when player stands still in X amount of time it will say (Player) is now afk and if he moves it will say (Player) is no longer afk.

    Please help me with this all you skilled plugin developers out there :)

    - Best wishes JACE_OiO

    PS: Im not new at making plugins, and I know my way around in Java :)
     
  2. Offline

    beastman3226

    I'm not completely sure about the standing still part. But, for un-afking a player just use on step, first checking if that player was afk, if he wasn't then nothing happens, if he was he is no longer AFK.
     
  3. Offline

    Jace_oio

    Okay,
    meny thanks for your quik answer but I still need to know how to do the standing still part :)
    - best wishes JACE_OiO

    Please anybody any kind of help is appreciated :)

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

    TheUpdater

    do on playermoveEvent and if Player is Standing still in 5 min then a message will come up
     
  5. Offline

    ShadowDog007

    Store a map of the last time each player moved.
    You can check if they move by listening to a PlayerMoveEvent and checking if one of their to/from block coordinates does not match.

    Make a task which checks every player (Which isn't already afk) in the servers last movement, if its more than the AFK time. Set them as afk (Store that in a map too?) And broadcast a message saying so.

    Then when they move again, update their lastMoved timestamp, and set AFK = false.

    You could run the task in async using ConcurrentHashMaps. Take the load of checking afk status of all players off your main thread. Shouldn't be a problem unless you have a massive server though.
     
  6. Offline

    Jace_oio

    Meney thanks ShadowDog007 and TheUpdater :) I really appreciate the replies, but I need some simple code examples to fully understand it :)


    from block coordinates does not match - Great idea :)
     
  7. Offline

    ZeusAllMighty11


    Relying on being spoonfed code is a terrible way to understand, just sayin'.
     
    ShadowDog007 likes this.
  8. Offline

    Jace_oio

    ZeusAllMighty11 You might be right, but everything is worth a try :)

    Sometimes its just better to see the code and the explanation at the same time :)
     
  9. Offline

    Compressions

    Jace_oio Do NOT get into the habit of using example code in your plugins. You will never learn anything if you don't try yourself.
     
  10. Offline

    Jace_oio

    Compressions

    - It is very rare I come here and ask things, so when I finaly end up here I normaly have absolutely no idea on how to do the things I need help with :)

    Since I started Developing plugins ive tried, worked hard to understand bukkits API, this is my first post ever in the plugin development section.
     
Thread Status:
Not open for further replies.

Share This Page