如何在同一事件中执行多个ifs

时间:2015-04-11 18:41:25

标签: java if-statement bukkit

我在这里有这个事件,我希望它检查每个if和执行每个if。目前它每隔一段时间只执行一次。我希望它能贯穿每一个if语句并执行它,无论它是否真实。

  int i = 0;    
      while(i < Bukkit.getOnlinePlayers().length){if(Bukkit.getOnlinePlayers()[i].getPlayer().getLocation().distance(loc) <= 55){//i only want others if statemet ran if this is true
        if(plugin.claymore.get(uui).equals(uui)){
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(p.getName() + "Mistakes were made");
                 plugin.claymore.remove(uui);
                 } 
           if(plugin.claymore.containsKey(uui)){    
                 UUID bozo = plugin.claymore.get(uui);      
                 Player jjg = Bukkit.getPlayer(bozo);
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(jjg.getName() + "'s claymore killed"+ p.getName());
                 jjg.giveExpLevels(50);  
                 plugin.claymore.remove(uui);          
                 }
                if(plugin.claymore.containsValue(Bukkit.getOnlinePlayers()[i].getPlayer().getUniqueId())){
                 UUID bozzo = plugin.claymore.get(uui);      
                 Player jjhg = Bukkit.getPlayer(bozzo);
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(jjhg.getName() + "'s claymore killed"+ p.getName());
                 jjhg.giveExpLevels(50);  
                 plugin.claymore.remove(uui);      
                 } 
                 }                  
         else if(plugin.claymore.containsValue(Bukkit.getOnlinePlayers()[i].getPlayer().getUniqueId())){
                 UUID bozo = plugin.claymore.get(uui);      
                 Player jjg = Bukkit.getPlayer(bozo);
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(jjg.getName() + "'s claymore killed"+ p.getName());
                 jjg.giveExpLevels(50);  
                 plugin.claymore.remove(uui);  
                 }           
                       i++;      
                     }
                   }
                 }
               }

再一次,我希望检查每个if语句,然后转到下一个,不管if是否为true我想要所有ifs运行。

1 个答案:

答案 0 :(得分:0)

如果要删除所有else

,则要全部运行
  int i = 0;    
      while(i < Bukkit.getOnlinePlayers().length){if(Bukkit.getOnlinePlayers()[i].getPlayer().getLocation().distance(loc) <= 55){//i only want others if statemet ran if this is true
        if(plugin.claymore.get(uui).equals(uui)){
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(p.getName() + "Mistakes were made");
                 plugin.claymore.remove(uui);
                 } 
           if(plugin.claymore.containsKey(uui)){    
                 UUID bozo = plugin.claymore.get(uui);      
                 Player jjg = Bukkit.getPlayer(bozo);
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(jjg.getName() + "'s claymore killed"+ p.getName());
                 jjg.giveExpLevels(50);  
                 plugin.claymore.remove(uui);          
                 }
                if(plugin.claymore.containsValue(Bukkit.getOnlinePlayers()[i].getPlayer().getUniqueId())){
                 UUID bozzo = plugin.claymore.get(uui);      
                 Player jjhg = Bukkit.getPlayer(bozzo);
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(jjhg.getName() + "'s claymore killed"+ p.getName());
                 jjhg.giveExpLevels(50);  
                 plugin.claymore.remove(uui);      
                 } 
                 }                  
         if(plugin.claymore.containsValue(Bukkit.getOnlinePlayers()[i].getPlayer().getUniqueId())){
                 UUID bozo = plugin.claymore.get(uui);      
                 Player jjg = Bukkit.getPlayer(bozo);
                 Bukkit.getOnlinePlayers()[i].getPlayer().sendMessage(jjg.getName() + "'s claymore killed"+ p.getName());
                 jjg.giveExpLevels(50);  
                 plugin.claymore.remove(uui);  
                 }           
                       i++;      
                     }
                   }
                 }
               }