Solved cancel reapiting task

Discussion in 'Plugin Development' started by bronzzze, Mar 29, 2015.

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

    bronzzze

    I am using schulderreapitingtask for particles and when other player activate paricle it cancel it for other players. Should i use arraylist
     
  2. Offline

    mythbusterma

    @bronzzze

    I'm not sure what you mean. That post was incredibly vague.
     
  3. Wow. That makes so much sense...
     
  4. Offline

    xMrPoi

    You're probably using a variable to store a single player to deliver particles to. You should make some sort of list to store multiple players in so that you can loop through that list and give all those players particle effects.

    Code:java
    1. List<UUID> particlePlayers = new ArrayList<UUID>();
     
  5. Offline

    TheDiamond06

    @bronzzze Can you please make your question more clear? Since your title is saying how to cancel a repeating task, you need to get the plugin instance then get the scheduler, then cancel the task. Simple.
     
  6. Offline

    bronzzze

    Sorry for bad explanation. My english suck.

    So
    This is my reapitingtask:
    Code:
    note = Bukkit.getServer().getScheduler()
                            .scheduleSyncRepeatingTask(main, new Runnable() {
                                private int time = 1;
    
                                public void run() {
    
                                    final Location l = p.getLocation();
                                    l.setY(l.getY() + 2.125);
                                    if (time == 1) {
                                        ParticleEffect.NOTE.display(0, 0, 0, 2, 3,
                                                l, 15);
                                        time = time + 1;
                                    }
                                    time--;
    
                                }
                            }, 1, 2);
    And when player leaves I make it like this:
    Code:
    @EventHandler
        public void onWorldChange(PlayerChangedWorldEvent e) {
            Bukkit.getScheduler().cancelTask(ParticleEvent.note);
    
    This cancel note particle for all players. So should I use somekind of ArrayList so in cancel it only for player who left.
     
  7. Use a HashMap<String, Integer> to store the players name with the taskID
     
    bronzzze likes this.
  8. Offline

    bronzzze

Thread Status:
Not open for further replies.

Share This Page