Why is this code not working

Discussion in 'Plugin Development' started by Zankz, Dec 18, 2014.

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

    Zankz

    Why is this code not working.
    I am not getting any error messages!

    Code:
      
        @EventHandler
        public void noff(EntityDamageByEntityEvent e){
            Entity ed = e.getEntity();
            Entity eda = e.getDamager();
            if(ed instanceof Player){
                Player pd = (Player) ed;
                if(eda instanceof Player){
                Bukkit.broadcastMessage("PLAYER");
                Player pda = (Player) eda;
                if(Team.getRed().contains(pd) && Team.getRed().contains(pda) || Team.getGreen().contains(pd) && Team.getGreen().contains(pda)){
                    Bukkit.broadcastMessage("TEAM");
                   
                }else{
                    Bukkit.broadcastMessage("NTEAM");
                }
            }else{
            if(eda instanceof Arrow){
                Bukkit.broadcastMessage("SARROW");
                Arrow a = (Arrow) eda;
                Player ap =  (Player) a.getShooter();
               
                    if(Team.getRed().contains(pd) && Team.getRed().contains(ap) || Team.getGreen().contains(pd) && Team.getGreen().contains(ap)){
                        Bukkit.broadcastMessage("RARROW");
                     e.setCancelled(true);
                     e.setDamage(0.0);
                }else{
                   
                }
           
            }
            if(Main.gamestate == false){
                e.setCancelled(true);
            }
            }
        }
        }
    Btw the Bukkit.broadcastMessage stuff is so i can test it :)
     
  2. Offline

    mythbusterma

    @Zankz

    "Not working" is quite vague, what do you mean? Which of those statements are being reached?
     
  3. Offline

    Zankz

    @mythbusterma Sorry, when i hit my self with an arrow i get the "SARROW" part to fire not the "RARROW" part
     
  4. Offline

    mythbusterma

    @Zankz

    Well, first off, you can't assume whatever shot an arrow is a Player, often times it is not. Second, I would check those lists (sets?) you have there to make sure they actually contain you.
     
  5. Offline

    Zankz

    @mythbusterma can you please elebortate on the 2nd part of your relpy. Thanks!
     
  6. Offline

    mythbusterma

    @Zankz

    Well first of all, make accessor methods in your Team class instead of making whatever Collection you have in them static, second, print the size of each of those Collections to make sure they actually can contain you.
     
Thread Status:
Not open for further replies.

Share This Page