Ir para conteúdo
  • 0

[Resolvido] Ajuda delay


LuizB

Pergunta

Tipo porque o Codigo abaixo n funfa ?

tipo vc continua clicando e as bolas saindo

e o tempo nunca Acaba, fica só mandando as mensagem de aguarde, Quando clica

 

  @EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        	if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        		if (player.getItemInHand().getType().equals(Material.STONE_HOE)){
            	player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
            	if (!dly.contains(player)) {
                	dly.add(player);
                	Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
        				
        				public void run() {
        					dly.remove(player);
        					
        				}
        			}, Principal.cf.getConfig().getInt("Delay") * 20L);
                }else{
                	player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                }
             }
            }
            }
        }
}  

OBS: o Delay que ta na config é 3

 



 

Link para o comentário
Compartilhar em outros sites

Posts Recomendados

tenta isso

 

desculpe não li oque você queria então esso codigo so fara o delay funcionar eu vo arrumar aqui. caso funcione responda

 

  @EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        if (player.getItemInHand().getType().equals(Material.STONE_HOE)){
            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
            if (!dly.contains(player)) {
                dly.add(player);
       Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable()
       {
         public void run()
         {
           dly.remove(p);
         }
       }, Principal.cf.getConfig().getInt("Delay") * 10L);
     }
     else
     {
            player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                }
             }
            }
            }
        }
}  
 
 
o meu ta assim
 
       Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable()
       {
         public void run()
         {
           dly.remove(p);
         }
       }, 3 * 10L);
     }
     else
     {
  p.sendMessage(PREFIXF + "§7§oO comando esta em delay" );
     }
}
}
}
return false;
}
}
 
Editado por FdeV
Link para o comentário
Compartilhar em outros sites

PRONTO ACHO QUE AGORA VAI!

 

MOTIVO - VOCÊ BOTOU O DELAY DEPOIS DE FAZER O EVENTO - CASO ESTE NÃO FUNCIONE BOTE ELE JUNTO COM O IF(2)

 

@EventHandler

    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) //IF2
        if (!dly.contains(player)) { //NOVO BG ADICIONADO 
                dly.add(player);{
            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
       
        public void run() {
        dly.remove(player);
       
        }
        }, Principal.cf.getConfig().getInt("Delay") * 20L);
                }else{
                player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                }
        }
        }
        }
}
}
Link para o comentário
Compartilhar em outros sites

 

PRONTO ACHO QUE AGORA VAI!

 

MOTIVO - VOCÊ BOTOU O DELAY DEPOIS DE FAZER O EVENTO - CASO ESTE NÃO FUNCIONE BOTE ELE JUNTO COM O IF(2)

 

@EventHandler

    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) //IF2
        if (!dly.contains(player)) { //NOVO BG ADICIONADO 
                dly.add(player);{
            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
       
        public void run() {
        dly.remove(player);
       
        }
        }, Principal.cf.getConfig().getInt("Delay") * 20L);
                }else{
                player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                }
        }
        }
        }
}
}

 

seu código ta todo zoado em organização... e usa o [.CODE] (sem ponto) quando for colocar codigo

Editado por Proyx
Link para o comentário
Compartilhar em outros sites

 

tenta isso

 

desculpe não li oque você queria então esso codigo so fara o delay funcionar eu vo arrumar aqui. caso funcione responda

 

  @EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        if (player.getItemInHand().getType().equals(Material.STONE_HOE)){
            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
            if (!dly.contains(player)) {
                dly.add(player);
       Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable()
       {
         public void run()
         {
           dly.remove(p);
         }
       }, Principal.cf.getConfig().getInt("Delay") * 10L);
     }
     else
     {
            player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                }
             }
            }
            }
        }
}  
 
 
o meu ta assim
 
       Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable()
       {
         public void run()
         {
           dly.remove(p);
         }
       }, 3 * 10L);
     }
     else
     {
  p.sendMessage(PREFIXF + "§7§oO comando esta em delay" );
     }
}
}
}
return false;
}
}
 

 

Aomda contianua o erro

Link para o comentário
Compartilhar em outros sites

Aomda contianua o erro

 

@EventHandler

    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) 
        if (!dly.contains(player)) {
                dly.add(player);{
            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
       
        public void run() {
        dly.remove(player);
       
        }
        }, Principal.cf.getConfig().getInt("Delay") * 20L);
                }else{
                player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                }
        }
        }
        }
}
}
Editado por FdeV
Link para o comentário
Compartilhar em outros sites

 O erro e que o delay não esta funcionando o codigo que eu mandei agora deveria funcionar

Não vejo nada de diferente do código dele pro seu... O dele parece funcionar corretamente...

 

Tem algum erro no console? Explica exatamente o que dá de errado

Link para o comentário
Compartilhar em outros sites

Não vejo nada de diferente do código dele pro seu... O dele parece funcionar corretamente...

 

Tem algum erro no console? Explica exatamente o que dá de errado

meu amigo ele esta colocando o codigo depois do uso do evento '-'

Link para o comentário
Compartilhar em outros sites

TA FUI VER NO ECLIPSE E VI ISSO PESSO DESCULPA

 

ve se e isso;

 

 

@EventHandler

    public void interact(PlayerInteractEvent e){

        Action eventAction = e.getAction();

        final Player player = e.getPlayer();

        if (pyro.contains(player.getName())) {

        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){

        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) 

        if ((!dly.contains(player))) {

        dly.add(player);

            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));

                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {

       

        public void run() {

        dly.remove(player);

       

        }

        }, Principal.cf.getConfig().getInt("Delay") * 20L);

        }

        } else {

            player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));

        }

        }

}

}

 

 

 

 

[

Editado por FdeV
Link para o comentário
Compartilhar em outros sites

uéeu tirei e pediu pra colocar denovo :/

 

USA ESTE CODIGO TIU '-'

 

http://prnt.sc/a6c7w9

 

@EventHandler

    public void interact(PlayerInteractEvent e){

        Action eventAction = e.getAction();

        final Player player = e.getPlayer();

        if (pyro.contains(player.getName())) {

        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){

        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) 

        if ((!dly.contains(player))) {

        dly.add(player);

            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));

                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {

       

        public void run() {

        dly.remove(player);

       

        }

        }, Principal.cf.getConfig().getInt("Delay") * 20L);

        }

        } else {

            player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));

        }

        }

}

}

Editado por FdeV
Link para o comentário
Compartilhar em outros sites

USA ESTE CODIGO TIU '-'

 

http://prnt.sc/a6c7w9

 

@EventHandler

    public void interact(PlayerInteractEvent e){

        Action eventAction = e.getAction();

        final Player player = e.getPlayer();

        if (pyro.contains(player.getName())) {

        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){

        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) 

        if ((!dly.contains(player))) {

        dly.add(player);

            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));

                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {

       

        public void run() {

        dly.remove(player);

       

        }

        }, Principal.cf.getConfig().getInt("Delay") * 20L);

        }

        } else {

            player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));

        }

        }

}

}

fdc, talvez seu codigo ta igual o meu, mas nao entendo o seu codigo (pois ta desorganizado), e vo postar oq ele tem q colocar (mesmo talvez sendo a msm coisa q vc fez, mas n sei):

  @EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
         if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
         if (player.getItemInHand().getType().equals(Material.STONE_HOE)){
                             player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                             if (!dly.contains(player)) {
                                 dly.add(player);
                                 Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
         
                 public void run() {
               dly.remove(player);
         
                 }
                 }, Principal.cf.getConfig().getInt("Delay") * 20L);
                                }else{
                                 player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                                }
                        }
                }
        }
}  

Edit: ata, n e q vc coloca desorganizado, e q o forum buga a organização, enfim, isso provavelmente funciona

Editado por Proyx
Link para o comentário
Compartilhar em outros sites

fdc, talvez seu codigo ta igual o meu, mas nao entendo o seu codigo (pois ta desorganizado), e vo postar oq ele tem q colocar (mesmo talvez sendo a msm coisa q vc fez, mas n sei):

  @EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
         if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
         if (player.getItemInHand().getType().equals(Material.STONE_HOE)){
                             player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                             if (!dly.contains(player)) {
                                 dly.add(player);
                                 Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
         
                 public void run() {
               dly.remove(player);
         
                 }
                 }, Principal.cf.getConfig().getInt("Delay") * 20L);
                                }else{
                                 player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                                }
                        }
                }
        }
}  

Edit: ata, n e q vc coloca desorganizado, e q o forum buga a organização, enfim, isso provavelmente funciona

 NO CASO O EO CODIGO QUE EU MANDEI SQ COM O BG DO [.CODE] CERTO? '-'

 

ME ENSINA A FAZER ISSO ._.

Editado por FdeV
Link para o comentário
Compartilhar em outros sites

fdc, talvez seu codigo ta igual o meu, mas nao entendo o seu codigo (pois ta desorganizado), e vo postar oq ele tem q colocar (mesmo talvez sendo a msm coisa q vc fez, mas n sei):

  @EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
         if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
         if (player.getItemInHand().getType().equals(Material.STONE_HOE)){
                             player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                             if (!dly.contains(player)) {
                                 dly.add(player);
                                 Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
         
                 public void run() {
               dly.remove(player);
         
                 }
                 }, Principal.cf.getConfig().getInt("Delay") * 20L);
                                }else{
                                 player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
                                }
                        }
                }
        }
}  

Edit: ata, n e q vc coloca desorganizado, e q o forum buga a organização, enfim, isso provavelmente funciona

Agora ta igual ao começo,

 

aparece a mensagem voce nao pode usar aguarde alguns segundos

 

e a bola de fogo é lançada

Link para o comentário
Compartilhar em outros sites

Agora ta igual ao começo,

 

aparece a mensagem voce nao pode usar aguarde alguns segundos

 

e a bola de fogo é lançada

NO CASO ESSA NÃO E A MINHA '-'

 

 

@EventHandler

public void interact(PlayerInteractEvent e){

Action eventAction = e.getAction();

final Player player = e.getPlayer();

if (pyro.contains(player.getName())) {

if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){

if (player.getItemInHand().getType().equals(Material.STONE_HOE))

if ((!dly.contains(player))) {

dly.add(player);

player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));

Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {

 

public void run() {

dly.remove(player);

 

}

}, Principal.cf.getConfig().getInt("Delay") * 20L);

}

} else {

player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));

}

}

}

}

Editado por FdeV
Link para o comentário
Compartilhar em outros sites

NO CASO ESSA NÃO E A MINHA '-'

 

 

[/code]@EventHandler

public void interact(PlayerInteractEvent e){

Action eventAction = e.getAction();

final Player player = e.getPlayer();

if (pyro.contains(player.getName())) {

if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){

if (player.getItemInHand().getType().equals(Material.STONE_HOE))

if ((!dly.contains(player))) {

dly.add(player);

player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));

Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {

 

public void run() {

dly.remove(player);

 

}

}, Principal.cf.getConfig().getInt("Delay") * 20L);

}

} else {

player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));

}

}

}

}

da pra organizar mias :/

Link para o comentário
Compartilhar em outros sites

dd


@EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) 
        if ((!dly.contains(player))) {
        dly.add(player);
            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
       
        public void run() {
        dly.remove(player);
       
        }
        }, Principal.cf.getConfig().getInt("Delay") * 20L);
        }
        } else {
            player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
        }
      }
}
}
 

vlw tiu ai teste

Editado por FdeV
Link para o comentário
Compartilhar em outros sites

 

dd


@EventHandler
    public void interact(PlayerInteractEvent e){
        Action eventAction = e.getAction();
        final Player player = e.getPlayer();
        if (pyro.contains(player.getName())) {
        if (eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.RIGHT_CLICK_BLOCK){
        if (player.getItemInHand().getType().equals(Material.STONE_HOE)) 
        if ((!dly.contains(player))) {
        dly.add(player);
            player.launchProjectile(Fireball.class).setVelocity(player.getLocation().getDirection().multiply(0.5));
                Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this, new Runnable() {
       
        public void run() {
        dly.remove(player);
       
        }
        }, Principal.cf.getConfig().getInt("Delay") * 20L);
        }
        } else {
            player.sendMessage(Principal.cf.getConfig().getString("MensagemDelay"));
        }
      }
}
}
 

vlw tiu ai teste

 

mesma coisa  :(

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...