Solved DelayTask && Dont work correctly the second sentence

Discussion in 'Plugin Development' started by user_91277742, Nov 21, 2017.

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

    user_91277742

    Hello everyone! , so I am using a delaytask and the problem is, this task do the same action 2 times. I will mean...
    Code:
        public void changeEars(InventoryClickEvent e) {
            Player p = (Player) e.getWhoClicked();
            String race = main.raceConfig.getString(p.getUniqueId().toString() + ".Race");
            main.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable(){
                public void run() {
                    if(p.getInventory().getHelmet() == null){
                        if(race != null && race.equals("Nekos")) {
                            ItemStack ears = main.hatList("neko");
                            p.getInventory().setHelmet(ears);
                            p.sendMessage(ChatColor.GREEN + "You have already the ears neko!");
                        }else{
                            p.sendMessage("test");
                        }
                    }
                }
    
            },20L);
        }
    
    The message of test, appear two times with a delay of 1 sec and I dont have any idea for what.
    Also, the second sentence dont work. The second sentence is If you have no hats in you head or helmet, add to you automatically a hat with ears appearance.
    Code:
    if(race != null && race.equals("Nekos")) {
    
     
    Last edited by a moderator: Nov 21, 2017
  2. Offline

    Caderape2

    @Ahrigumi
    Are you sure the file configuration is loaded correctly?
    Are you sure in your config, you have 'UUID.Race' set ?

    If it throw a NPE, it's probably cuz the plugin don't find it.
     
  3. Offline

    user_91277742

    aaam yes, I have my configuration loaded correctly because I use the config in my others events and I dont have issues except this one and yes, I have set the UUID.Race in my race.yml
     
  4. Offline

    Caderape2

    @Ahrigumi
    Do a test in the event.
     
  5. Offline

    Unknown123

    Don't use schedule Methods. Use BukkitRunnable and runTask. Send the player a message at the start of the event also
     
  6. Offline

    user_91277742

Thread Status:
Not open for further replies.

Share This Page