Countdowns in interact event

Discussion in 'Plugin Development' started by yustinv2, Mar 5, 2016.

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

    yustinv2

    someone can help me, i need to do a countdown, when you right click with a paper it add you to an array list, but in 2 seconds after the right click you get removed from arraylist, any ideas about it? im starting with plugin development

    my code:

    Code:
     ArrayList<Player> comb1 = new ArrayList<Player>();
    
        @EventHandler
        public void InteractEvent(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            Action a = e.getAction();
    
                if (p.getItemInHand().getType() == Material.PAPER)
                if (a == (Action.RIGHT_CLICK_AIR) || a == (Action.RIGHT_CLICK_BLOCK)){
                ActionBar combi1 = new ActionBar(ChatColor.GREEN + "" + ChatColor.UNDERLINE + "Left   ____   ___");
                combi1.sendToPlayer(p);
                comb1.add(p);[code]
    
    i will really appreciate if someone could tell me how to do the countdown, btw im sorry if my english is so bad...
     
    Last edited by a moderator: Mar 5, 2016
  2. Offline

    teej107

    @yustinv2 When the cooldown ends, do you want to alert the player?
     
  3. Offline

    yustinv2

    No, im making a plugin of combination of clicks like if you do left click then right click and then left click you fire a fireball, so, i have to use arrayslist to do the combination, but in the case the player just do 1 left click he will be in the array list of the first click, but if he doesnt complete the combination (Isnt in code) he will be in the array list... that means, if i want to do later left - right - left clicks to fire a fireball the first left click wont count because im alredy in the array so the combination in this case will be right - left click

    so to the question, how i can do to remove player from arraylist every 2 seconds and everytime i do a left/right click following combination it reset again to 2 seconds ?

    a little example;

    when i do a click i have 2 seconds to do the second click if the 2 seconds ends i have to start again combination...

    Any ideas ?
     
Thread Status:
Not open for further replies.

Share This Page