示例#1
0
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("fireball")) {
     if (!plugin.isAuthorized(cs, "rcmds.fireball")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(ChatColor.RED + "This command is only available to players!");
       return true;
     }
     Player p = (Player) cs;
     // Fireball fb = p.launchProjectile(Fireball.class);
     Vector dir = p.getEyeLocation().getDirection().multiply(2);
     Fireball fb =
         p.getWorld()
             .spawn(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ()), Fireball.class);
     fb.setDirection(dir);
     // fb.teleport(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ()));
     fb.setIsIncendiary(true);
     return true;
   }
   return false;
 }