disconnect combat help

Discussion in 'Spigot Plugin Development' started by ElbestHD, Aug 31, 2018.

  1. Hello good afternoon people from spigot I need a yauda from you as I can do that when a user disconnects in combat 0 of hearts
  2. Hello, if i understood u right u want that somebody gets killed if he disconnects when he is in a fight? Well make a HashMap with a Player and a long. Put the player in if he gets attacked or attacks someone for a amount of time. And look at the quit event if he is in the hashmap.
    • Agree Agree x 1
  3. While the player is in combat make sure to store him in a HashMap.*
    Code (Text):
    combat#put(uuid, boolean);
    *Do not forget to create a scheduler to remove him from the HashMap after X time has passed.

    To detect the player's quit while being in combat just listen to the PlayerQuitEvent.
    Code (Text):
    public void onCombatQuit(PlayerQuitEvent event) {
    if (combat.contains(uuid)) {
    // Do anything.
  4. Sorry but just use a HashMap with a long.
  5. I would also recommend just a HashMap with a long, compare this long with the current server time and you have your "delay". If a player quits you should delete its key in the HashMap of course.

    If you want to schedule tasks there is no need to use a HashMap anyway, you are absolutely fine with a List
    • Agree Agree x 1