Solved Checking if Player has been interacted with

Discussion in 'Plugin Development' started by Josh774, Dec 9, 2018.

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


    I'm using the PlayerInteractEntityEvent. When the Player is interacted with I want to make it so the player cant be interacted with again until the first interaction is done with. Not sure how I would go about doing this.

    Im sorry if this is dumb, pretty new to all this.
  2. Offline

    timtower Ninja on the waves Moderator

    @Josh774 I highly doubt that your method runs for that long.
  3. Offline


    Maybe try explaining what you want to do in detail
  4. Offline


    what kind of 'interaction' like getting hit, like @DerDonut said, explain more and maybe what the full aim is?
  5. Offline


    I'm happy to be schooled if I'm off track here.. but..

    It depends on what you're looking for. For example.. if you're looking for something where say a player gets poisoned for 30 seconds and you want them to be immune until after that period.. a potential solution would be to use a hashmap to record player and a timestamp of the last successful interaction. On player interaction, check the timestamp in the hashmap, and decide if you cancel the event or not (so the hashmap just records last successful interaction) - if it has been long enough since the last interaction, you can just replace the timestamp with the new one, otherwise, cancel the event. If the number of players is a concern, you could schedule a cleanup of the hashmap where timestamp > x seconds ago.

    However, if you're looking for not getting hit with a sword right after getting hit with a sword.. I can't imagine that the 2 events would last long enough to cross over.
  6. Offline


    All good I figured it out! Thanks anyway
Thread Status:
Not open for further replies.

Share This Page