if(sender instanceof Player) { Player player = (Player) sender; // stuff here that requires the player object }